Skip to content

Commit e13d937

Browse files
committed
Fix: cleaning up
1 parent 685bc24 commit e13d937

File tree

5 files changed

+287
-140
lines changed

5 files changed

+287
-140
lines changed

opensecurity/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 2.76.54
18+
version: 2.76.55
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "2.76.54"
24+
appVersion: "2.76.55"
2525

2626
dependencies:
2727
- name: keda

opensecurity/templates/init/init-debug-job.yaml

Lines changed: 0 additions & 76 deletions
This file was deleted.

opensecurity/templates/init/init-job-configmap.yaml

Lines changed: 110 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,126 @@
33
apiVersion: v1
44
kind: ConfigMap
55
metadata:
6+
# Generate a unique name for the ConfigMap
67
name: {{ include "opensecurity.fullname" . }}-init-job-config
7-
namespace: {{ .Release.Namespace }}
8+
namespace: "{{ .Release.Namespace }}"
89
labels:
9-
{{ include "opensecurity.labels" . | nindent 4 }}
10+
# Include standard Helm labels
11+
{{- include "opensecurity.labels" . | nindent 4 }}
1012
app.kubernetes.io/component: init-job-config
1113
data:
12-
{{- $cfg := default (dict) .Values.opensecurity.initJob.config }}
13-
{{- $names := default (dict) .Values.opensecurity.initJob.envVarNames }}
14+
# --- IMPORTANT ---
15+
# This ConfigMap stores non-sensitive configuration.
16+
# Sensitive values like PGPASSWORD, DEFAULT_DEX_USER_PASSWORD
17+
# MUST be stored in a Kubernetes Secret and referenced directly in the Job/Pod spec.
18+
# DEX_PRIVATE_CLIENT_SECRET is included here with a default for compatibility,
19+
# but ideally should also be sourced from a secret if not using the default "SECRET".
20+
# ---
1421

15-
{{- /* Auth Service Name */}}
16-
{{- $authSvcKey := default "AUTH_SERVICE_NAME" (index $names "authServiceName") }}
17-
{{- $authSvcVal := default "core-service" (index $cfg "authServiceName") }}
22+
{{- /* bring config and envVarNames into safe maps */}}
23+
{{- $config := default (dict) .Values.opensecurity.initJob.config }}
24+
{{- $names := default (dict) .Values.opensecurity.initJob.envVarNames }}
25+
{{- $global := default (dict) .Values.global }}
26+
{{- /* Bring secrets config into a safe map for default checking */}}
27+
{{- $secrets := default (dict) .Values.opensecurity.initJob.secrets }}
28+
29+
30+
# --- Auth Service URL Components ---
31+
{{- $authSvcKey := default "AUTH_SERVICE_NAME" (get $names "authServiceName") }}
32+
{{- $authSvcVal := default "auth-service" (get $config "authServiceName") }}
1833
{{ $authSvcKey }}: {{ $authSvcVal | quote }}
1934

20-
{{- /* Auth Namespace */}}
21-
{{- $authNsKey := default "AUTH_NAMESPACE" (index $names "authNamespace") }}
22-
{{- $authNsVal := default .Release.Namespace (index $cfg "authNamespace") }}
35+
{{- $authNsKey := default "AUTH_NAMESPACE" (get $names "authNamespace") }}
36+
{{- $authNsVal := default .Release.Namespace (get $config "authNamespace") }}
2337
{{ $authNsKey }}: {{ $authNsVal | quote }}
2438

25-
{{- /* Auth Port */}}
26-
{{- $authPortKey := default "AUTH_SERVICE_PORT" (index $names "authPort") }}
27-
{{- $authPortVal := default "8251" (index $cfg "authPort") }}
39+
{{- $authPortKey := default "AUTH_SERVICE_PORT" (get $names "authPort") }}
40+
{{- $authPortVal := default "8251" (get $config "authPort") }}
2841
{{ $authPortKey }}: {{ $authPortVal | quote }}
2942

30-
{{- /* Optional Auth Health Path */}}
31-
{{- $authHealthVal := index $cfg "authHealthPath" }}
32-
{{- if $authHealthVal }}
33-
{{- $authHealthKey := default "AUTH_HEALTH_PATH" (index $names "authHealthPath") }}
34-
{{ $authHealthKey }}: {{ $authHealthVal | quote }}
43+
{{- with get $config "authHealthPath" }}
44+
{{- $authHealthKey := default "AUTH_HEALTH_PATH" (get $names "authHealthPath") }}
45+
{{ $authHealthKey }}: {{ . | quote }}
3546
{{- end }}
47+
48+
# --- Default Admin/Dex User ---
49+
{{- $adminEmailKey := default "DEFAULT_ADMIN_EMAIL" (get $names "defaultAdminEmail") }}
50+
{{- $adminEmailVal := default "[email protected]" (get $config "defaultAdminEmail") }}
51+
{{ $adminEmailKey }}: {{ $adminEmailVal | quote }}
52+
53+
{{- $dexEmailKey := default "DEFAULT_DEX_USER_EMAIL" (get $names "defaultDexUserEmail") }}
54+
{{- $dexEmailVal := default "[email protected]" (get $config "defaultDexUserEmail") }} # Get from values or fallback
55+
{{ $dexEmailKey }}: {{ $dexEmailVal | quote }}
56+
57+
{{- $dexUserNameKey := default "DEFAULT_DEX_USER_NAME" (get $names "defaultDexUserName") }}
58+
{{- $dexUserNameVal := default "admin" (get $config "defaultDexUserName") }} # Get from values or fallback
59+
{{ $dexUserNameKey }}: {{ $dexUserNameVal | quote }}
60+
61+
# --- PostgreSQL Connection Info (excluding password) ---
62+
{{- $pgSrc := default (dict) .Values.authDatabase }}
63+
{{- $pgHost := default (printf "%s-postgresql-primary.%s.svc.cluster.local" $.Release.Name $.Release.Namespace) (get $pgSrc "host") }}
64+
{{- $pgPort := default "5432" (get $pgSrc "port") }}
65+
{{- $pgDb := default "auth" (get $pgSrc "name") }}
66+
{{- $pgUser := default "postgres" (get $pgSrc "user") }} # User is set here
67+
{{- $pgSsl := default "disable" (get $pgSrc "sslMode") }}
68+
69+
{{- $pgHostKey := default "PGHOST" (get $names "pgHost") }}
70+
{{ $pgHostKey }}: {{ $pgHost | quote }}
71+
72+
{{- $pgPortKey := default "PGPORT" (get $names "pgPort") }}
73+
{{ $pgPortKey }}: {{ $pgPort | quote }}
74+
75+
{{- $pgDbKey := default "PGDATABASE" (get $names "pgDatabase") }}
76+
{{ $pgDbKey }}: {{ $pgDb | quote }}
77+
78+
{{- $pgUserKey := default "PGUSER" (get $names "pgUser") }}
79+
{{ $pgUserKey }}: {{ $pgUser | quote }} # Value from $pgUser variable above
80+
81+
{{- $pgSslKey := default "PGSSLMODE" (get $names "pgSslMode") }}
82+
{{ $pgSslKey }}: {{ $pgSsl | quote }}
83+
84+
# --- Dex Configuration ---
85+
{{- $dexGrpcKey := default "DEX_GRPC_ADDR" (get $names "dexGrpcAddr") }}
86+
{{- $dexGrpcVal := default (printf "%s-dex.%s.svc.cluster.local:5557" $.Release.Name $.Release.Namespace) (get $config "dexGrpcAddr") }}
87+
{{ $dexGrpcKey }}: {{ $dexGrpcVal | quote }}
88+
89+
{{- $dexPublicUrisKey := default "DEX_PUBLIC_CLIENT_REDIRECT_URIS" (get $names "dexPublicClientRedirectUris") }}
90+
{{- $dexPublicUrisVal := default (printf "https://%s/callback,http://%s/callback,http://localhost:3000/callback,http://localhost:8080/callback" (get $global "domain") (get $global "domain")) (get $config "dexPublicClientRedirectUris") }}
91+
{{ $dexPublicUrisKey }}: {{ $dexPublicUrisVal | quote }}
92+
93+
{{- $dexPrivateUrisKey := default "DEX_PRIVATE_CLIENT_REDIRECT_URIS" (get $names "dexPrivateClientRedirectUris") }}
94+
{{- $dexPrivateUrisVal := default (printf "https://%s/callback" (get $global "domain")) (get $config "dexPrivateClientRedirectUris") }}
95+
{{ $dexPrivateUrisKey }}: {{ $dexPrivateUrisVal | quote }}
96+
97+
{{- $dexPublicClientIdKey := default "DEX_PUBLIC_CLIENT_ID" (get $names "dexPublicClientId") }}
98+
{{- $dexPublicClientIdVal := default "public-client" (get $config "dexPublicClientId") }} # Default 'public-client'
99+
{{ $dexPublicClientIdKey }}: {{ $dexPublicClientIdVal | quote }}
100+
101+
{{- $dexPrivateClientIdKey := default "DEX_PRIVATE_CLIENT_ID" (get $names "dexPrivateClientId") }}
102+
{{- $dexPrivateClientIdVal := default "private-client" (get $config "dexPrivateClientId") }} # Provide a default or require in values
103+
{{ $dexPrivateClientIdKey }}: {{ $dexPrivateClientIdVal | quote }}
104+
105+
{{- $dexHttpHealthKey := default "DEX_HTTP_HEALTH_URL" (get $names "dexHttpHealthUrl") }}
106+
{{- $dexHttpHealthVal := default (printf "http://%s-dex.%s.svc.cluster.local:5556/dex/healthz" $.Release.Name $.Release.Namespace) (get $config "dexHttpHealthUrl") }} # Construct default health URL
107+
{{ $dexHttpHealthKey }}: {{ $dexHttpHealthVal | quote }}
108+
109+
# --- BEGIN: Add Dex Private Client Secret with Default ---
110+
{{- $dexPrivSecretKey := default "DEX_PRIVATE_CLIENT_SECRET" (get $names "dexPrivateClientSecret") }}
111+
{{- /* Get value from secrets if defined, otherwise default to "SECRET" */}}
112+
{{- $dexPrivSecretVal := get $secrets "dexPrivateClientSecret" | default "SECRET" }}
113+
{{ $dexPrivSecretKey }}: {{ $dexPrivSecretVal | quote }}
114+
# --- END: Add Dex Private Client Secret with Default ---
115+
116+
# --- Other Hardcoded/Constructed Values ---
117+
{{- $workspaceNameKey := default "WORKSPACE_NAME" (get $names "workspaceName") }}
118+
{{ $workspaceNameKey }}: "main" # Hardcoded as per snippet
119+
120+
{{- $dexCallbackKey := default "DEX_CALLBACK_URL" (get $names "dexCallbackUrl") }}
121+
{{- $dexCallbackVal := default (printf "https://%s/dex/callback,http://%s/dex/callback,http://localhost:3000/dex/callback,http://localhost:8080/dex/callback" (get $global "domain") (get $global "domain")) (get $config "dexCallbackUrl") }}
122+
{{ $dexCallbackKey }}: {{ $dexCallbackVal | quote }}
123+
124+
{{- $dexAuthDomainKey := default "DEX_AUTH_DOMAIN" (get $names "dexAuthDomain") }}
125+
{{- $dexAuthDomainVal := default (printf "http://%s-dex.%s.svc.cluster.local:5556/dex" $.Release.Name $.Release.Namespace) (get $config "dexAuthDomain") }}
126+
{{ $dexAuthDomainKey }}: {{ $dexAuthDomainVal | quote }}
127+
36128
{{- end }}

0 commit comments

Comments
 (0)