Skip to content

Commit ef1c555

Browse files
source code for env promotion
1 parent d3948d4 commit ef1c555

File tree

5 files changed

+108
-0
lines changed

5 files changed

+108
-0
lines changed

source-code-configmap/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM golang:1.15.1-alpine3.12 AS build-env
2+
3+
WORKDIR /tmp/simple-go-app
4+
5+
COPY . .
6+
7+
RUN CGO_ENABLED=0 GOOS=linux go build
8+
9+
FROM scratch
10+
COPY --from=build-env /tmp/simple-go-app/gitops-promotion-source-code /app/gitops-promotion-source-code
11+
12+
# COPY settings.ini /config/settings.ini
13+
14+
15+
EXPOSE 8080
16+
CMD ["/app/gitops-promotion-source-code"]

source-code-configmap/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/kostis-codefresh/gitops-promotion-source-code
2+
3+
go 1.17

source-code-configmap/go.sum

Whitespace-only changes.

source-code-configmap/settings.ini

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# possible values : production, development, staging, qa
2+
app_mode = development
3+
4+
[security]
5+
# Path to SSL certificates
6+
certificates = /etc/ssl/dev
7+
8+
[paypal]
9+
paypal_url = https://development.paypal.example.com
10+
11+
[mysql]
12+
db_user = devuser
13+
db_password = devpassword
14+
15+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
"os"
7+
)
8+
9+
type configurationListHandler struct {
10+
version string
11+
environment string
12+
environment_type string
13+
region string
14+
paypal_url string
15+
db_user string
16+
db_password string
17+
gpu_enabled string
18+
ui_theme string
19+
cache_size string
20+
page_limit string
21+
sorting string
22+
number_of_buckets string
23+
}
24+
25+
func (h *configurationListHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
26+
w.Header().Set("Content-Type", "text/html; charset=utf-8")
27+
fmt.Fprintf(w, "<h2>I am a GO application running inside Kubernetes.<h2> <h3>My properties are:</h3><ul>")
28+
fmt.Fprintf(w, "<li>version: "+h.version+"</li>")
29+
fmt.Fprintf(w, "<li>environment: "+h.environment+"</li>")
30+
fmt.Fprintf(w, "<li>environment_type: "+h.environment_type+"</li>")
31+
fmt.Fprintf(w, "<li>region: "+h.region+"</li>")
32+
fmt.Fprintf(w, "<li>paypal_url: "+h.paypal_url+"</li>")
33+
fmt.Fprintf(w, "<li>db_user: "+h.db_user+"</li>")
34+
fmt.Fprintf(w, "<li>db_password: "+h.db_password+"</li>")
35+
fmt.Fprintf(w, "<li>gpu_enabled: "+h.gpu_enabled+"</li>")
36+
fmt.Fprintf(w, "<li>ui_theme: "+h.ui_theme+"</li>")
37+
fmt.Fprintf(w, "<li>cache_size: "+h.cache_size+"</li>")
38+
fmt.Fprintf(w, "<li>page_limit: "+h.page_limit+"</li>")
39+
fmt.Fprintf(w, "<li>sorting: "+h.sorting+"</li>")
40+
fmt.Fprintf(w, "<li>number_of_buckets: "+h.number_of_buckets+"</li>")
41+
fmt.Fprintf(w, "</ol>")
42+
43+
}
44+
45+
func healthHandler(w http.ResponseWriter, r *http.Request) {
46+
fmt.Fprintf(w, "OK\n")
47+
48+
}
49+
50+
func main() {
51+
52+
clh := configurationListHandler{}
53+
clh.version = "3.0"
54+
clh.environment = os.Getenv("ENV")
55+
clh.environment_type = os.Getenv("ENV_TYPE")
56+
clh.region = os.Getenv("REGION")
57+
clh.paypal_url = os.Getenv("PAYPAL_URL")
58+
clh.db_user = os.Getenv("DB_USER")
59+
clh.db_password = os.Getenv("DB_PASSWORD")
60+
clh.gpu_enabled = os.Getenv("GPU_ENABLED")
61+
clh.ui_theme = os.Getenv("UI_THEME")
62+
clh.cache_size = os.Getenv("CACHE_SIZE")
63+
clh.page_limit = os.Getenv("PAGE_LIMIT")
64+
clh.sorting = os.Getenv("SORTING")
65+
clh.number_of_buckets = os.Getenv("N_BUCKETS")
66+
67+
fmt.Println("Simple web server is starting on port 8080...")
68+
http.Handle("/", &clh)
69+
http.HandleFunc("/health", healthHandler)
70+
err := http.ListenAndServe(":8080", nil)
71+
if err != nil {
72+
fmt.Printf("Failed to start server at port 8080: %v", err)
73+
}
74+
}

0 commit comments

Comments
 (0)