diff --git a/Dockerfile b/Dockerfile index 57262d9..adcdd43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,18 +24,18 @@ COPY --from=alpine /zoneinfo.zip / # tls certificates COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -ENV CH_SOLUTIONS="impl" \ - CH_SOLUTIONS_MIGRATIONS_PATH="migrations" \ - CH_SOLUTIONS_TEXTLOG="true" \ - CH_SOLUTIONS_DEBUG="true" \ - CH_SOLUTIONS_DB="postgres" \ - CH_SOLUTIONS_PG_LOGIN="solutions" \ - CH_SOLUTIONS_PG_PASSWORD="" \ - CH_SOLUTIONS_PG_ADDR="postgres:5432" \ - CH_SOLUTIONS_PG_DBNAME="usermanager" \ - CH_SOLUTIONS_PG_NOSSL=true \ - CH_SOLUTIONS_KUBE_API_URL="http://kube-api:1214" \ - CH_SOLUTIONS_RESOURCE_URL="http://resource-service:1213" +ENV SOLUTIONS="impl" \ + MIGRATIONS_PATH="migrations" \ + TEXTLOG="true" \ + DEBUG="true" \ + DB="postgres" \ + PG_LOGIN="solutions" \ + PG_PASSWORD="" \ + PG_ADDR="postgres:5432" \ + PG_DBNAME="usermanager" \ + PG_NOSSL=true \ + KUBE_API_URL="http://kube-api:1214" \ + RESOURCE_URL="http://resource-service:1213" EXPOSE 6767 diff --git a/charts/solutions/templates/deployment.yaml b/charts/solutions/templates/deployment.yaml index dfc3c26..7f02410 100644 --- a/charts/solutions/templates/deployment.yaml +++ b/charts/solutions/templates/deployment.yaml @@ -32,35 +32,35 @@ spec: - name: {{ $key }} value: {{ $val | quote }} {{ end }}{{- end }} - {{- if .Values.env.local.CH_SOLUTIONS_PG_ADDR }} - - name: CH_SOLUTIONS_PG_ADDR - value: "{{ .Values.env.local.CH_SOLUTIONS_PG_ADDR }}" + {{- if .Values.env.local.PG_ADDR }} + - name: PG_ADDR + value: "{{ .Values.env.local.PG_ADDR }}" {{- else }} - - name: CH_SOLUTIONS_PG_ADDR + - name: PG_ADDR value: "{{ .Release.Name }}-postgresql:5432" {{- end }} - {{- if .Values.env.local.CH_SOLUTIONS_KUBE_API_URL }} - - name: CH_SOLUTIONS_KUBE_API_URL - value: "{{ .Values.env.local.CH_SOLUTIONS_KUBE_API_URL }}" + {{- if .Values.env.local.KUBE_API_URL }} + - name: KUBE_API_URL + value: "{{ .Values.env.local.KUBE_API_URL }}" {{- else }} - - name: CH_SOLUTIONS_KUBE_API_URL + - name: KUBE_API_URL value: "http://{{ .Release.Name }}-kube:1214" {{- end }} - {{- if .Values.env.local.CH_SOLUTIONS_RESOURCE_URL }} - - name: CH_SOLUTIONS_RESOURCE_URL - value: "{{ .Values.env.local.CH_SOLUTIONS_RESOURCE_URL }}" + {{- if .Values.env.local.RESOURCE_URL }} + - name: RESOURCE_URL + value: "{{ .Values.env.local.RESOURCE_URL }}" {{- else }} - - name: CH_SOLUTIONS_RESOURCE_URL + - name: RESOURCE_URL value: "http://{{ .Release.Name }}-resource:1213" {{- end }} - {{- if .Values.env.local.CH_SOLUTIONS_PG_PASSWORD }} - - name: CH_SOLUTIONS_PG_PASSWORD + {{- if .Values.env.local.PG_PASSWORD }} + - name: PG_PASSWORD valueFrom: secretKeyRef: name: {{ template "fullname" . }} key: pg-password {{- else if .Values.tags.platformdb }} - - name: CH_SOLUTIONS_PG_PASSWORD + - name: PG_PASSWORD valueFrom: secretKeyRef: name: {{ .Release.Name }}-postgresql diff --git a/charts/solutions/templates/secret.yaml b/charts/solutions/templates/secret.yaml index a4afe0a..a1c38be 100644 --- a/charts/solutions/templates/secret.yaml +++ b/charts/solutions/templates/secret.yaml @@ -1,4 +1,4 @@ -{{- if .Values.env.local.CH_SOLUTIONS_PG_PASSWORD }} +{{- if .Values.env.local.PG_PASSWORD }} apiVersion: v1 kind: Secret metadata: @@ -10,7 +10,7 @@ metadata: heritage: {{ .Release.Service }} type: Opaque data: - {{- if .Values.env.local.CH_SOLUTIONS_PG_PASSWORD }} - pg-password: {{ .Values.env.local.CH_SOLUTIONS_PG_PASSWORD | b64enc }} + {{- if .Values.env.local.PG_PASSWORD }} + pg-password: {{ .Values.env.local.PG_PASSWORD | b64enc }} {{- end }} {{- end }} diff --git a/charts/solutions/values.yaml b/charts/solutions/values.yaml index 244b911..e4b3694 100644 --- a/charts/solutions/values.yaml +++ b/charts/solutions/values.yaml @@ -17,17 +17,17 @@ service: env: global: - CH_SOLUTIONS_DEBUG: "false" - CH_SOLUTIONS_TEXTLOG: "false" - CH_SOLUTIONS_DB: "postgres" - CH_SOLUTIONS_PG_LOGIN: "solutions" - CH_SOLUTIONS_PG_DBNAME: "solutions" - CH_SOLUTIONS_PG_NOSSL: "true" + DEBUG: "false" + TEXTLOG: "false" + DB: "postgres" + PG_LOGIN: "solutions" + PG_DBNAME: "solutions" + PG_NOSSL: "true" local: - CH_SOLUTIONS_PG_ADDR: "postgres-master.postgres.svc:5432" - CH_SOLUTIONS_KUBE_API_URL: "http://kube:1214" - CH_SOLUTIONS_RESOURCE_URL: "http://resource:1213" - CH_SOLUTIONS_PG_PASSWORD: + PG_ADDR: "postgres-master.postgres.svc.cluster.local:5432" + KUBE_API_URL: "http://kube-api:1214" + RESOURCE_URL: "http://resource-service:1213" + PG_PASSWORD: postgresql: persistence: diff --git a/cmd/solutions/config.go b/cmd/solutions/config.go index 0dd288f..5a45b21 100644 --- a/cmd/solutions/config.go +++ b/cmd/solutions/config.go @@ -32,78 +32,78 @@ const ( var flags = []cli.Flag{ cli.StringFlag{ - EnvVar: "CH_SOLUTIONS_PORT", + EnvVar: "PORT", Name: portFlag, Value: "6767", Usage: "port for solutions server", }, cli.StringFlag{ - EnvVar: "CH_SOLUTIONS", + EnvVar: "SOLUTIONS", Name: solutionsFlag, Value: "impl", Usage: "Solutions impl", }, cli.BoolFlag{ - EnvVar: "CH_SOLUTIONS_DEBUG", + EnvVar: "DEBUG", Name: debugFlag, Usage: "Start the server in Debug mode", }, cli.BoolFlag{ - EnvVar: "CH_SOLUTIONS_TEXTLOG", + EnvVar: "TEXTLOG", Name: textlogFlag, Usage: "Display output log in text format", }, cli.StringFlag{ - EnvVar: "CH_SOLUTIONS_DB", + EnvVar: "DB", Name: dbFlag, Value: "postgres", Usage: "DB for project", }, cli.StringFlag{ - EnvVar: "CH_SOLUTIONS_PG_LOGIN", + EnvVar: "PG_LOGIN", Name: dbPGLoginFlag, Usage: "DB Login (PostgreSQL)", }, cli.StringFlag{ - EnvVar: "CH_SOLUTIONS_PG_PASSWORD", + EnvVar: "PG_PASSWORD", Name: dbPGPasswordFlag, Usage: "DB Password (PostgreSQL)", }, cli.StringFlag{ - EnvVar: "CH_SOLUTIONS_PG_ADDR", + EnvVar: "PG_ADDR", Name: dbPGAddrFlag, Usage: "DB Address (PostgreSQL)", }, cli.StringFlag{ - EnvVar: "CH_SOLUTIONS_PG_DBNAME", + EnvVar: "PG_DBNAME", Name: dbPGNameFlag, Usage: "DB name (PostgreSQL)", }, cli.BoolFlag{ - EnvVar: "CH_SOLUTIONS_PG_NOSSL", + EnvVar: "PG_NOSSL", Name: dbPGNoSSLFlag, Usage: "DB disable ssl (PostgreSQL)", }, cli.StringFlag{ - EnvVar: "CH_SOLUTIONS_MIGRATIONS_PATH", + EnvVar: "MIGRATIONS_PATH", Name: dbMigrationsFlag, Value: "../../pkg/migrations/", Usage: "Location of DB migrations", }, cli.StringFlag{ - EnvVar: "CH_SOLUTIONS_KUBE_API_URL", + EnvVar: "KUBE_API_URL", Name: kubeURLFlag, Value: "http://kube-api:1214", Usage: "Kube-API service URL", }, cli.StringFlag{ - EnvVar: "CH_SOLUTIONS_RESOURCE_URL", + EnvVar: "RESOURCE_URL", Name: resourceURLFlag, Value: "http://resource-service:1213", Usage: "Resource service URL", }, cli.BoolFlag{ - EnvVar: "CH_SOLUTIONS_CORS", + EnvVar: "CORS", Name: "cors", Usage: "enable CORS", }, diff --git a/pkg/router/router.go b/pkg/router/router.go index 21d4b19..d3f29ec 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -25,7 +25,7 @@ func CreateRouter(ss *server.SolutionsService, status *model.ServiceStatus, enab e := gin.New() e.GET("/status", httputil.ServiceStatus(status)) initMiddlewares(e, ss) - initRoutes(e, status, enableCORS) + initRoutes(e, enableCORS) return e } @@ -41,7 +41,7 @@ func initMiddlewares(e *gin.Engine, ss *server.SolutionsService) { } // SetupRoutes sets up http router needed to handle requests from clients. -func initRoutes(app *gin.Engine, status *model.ServiceStatus, enableCORS bool) { +func initRoutes(app *gin.Engine, enableCORS bool) { requireIdentityHeaders := httputil.RequireHeaders(solerrors.ErrRequiredHeadersNotProvided, httputil.UserIDXHeader, httputil.UserRoleXHeader) if enableCORS {