Skip to content

Commit

Permalink
fix: [SMP-2377]: Create a secret key inside an existing secret if doe…
Browse files Browse the repository at this point in the history
…snt exist (#74)

* fix: [SMP-2377]: Create a secret key inside an existing secret if doesnt exist

* Update Chart.yaml
  • Loading branch information
arya-harness authored Dec 28, 2023
1 parent ffb88df commit baa3d7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: library
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.3.2
version: 1.3.3

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
18 changes: 16 additions & 2 deletions src/common/templates/_secrets.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,21 @@
{{- if hasKey $secretData .key }}
{{- $password = index $secretData .key | quote }}
{{- else }}
{{- printf "\nPASSWORDS ERROR: The secret \"%s\" does not contain the key \"%s\"\n" .secret .key | fail -}}
{{- if $providedPasswordValue }}
{{- $password = $providedPasswordValue | toString | b64enc | quote }}
{{- else }}
{{- if .context.Values.enabled }}
{{- $subchart = $chartName }}
{{- end -}}
{{- if .strong }}
{{- $subStr := list (lower (randAlpha 1)) (randNumeric 1) (upper (randAlpha 1)) | join "_" }}
{{- $password = randAscii $passwordLength }}
{{- $password = regexReplaceAllLiteral "\\W" $password "@" | substr 5 $passwordLength }}
{{- $password = printf "%s%s" $subStr $password | toString | shuffle | b64enc | quote }}
{{- else }}
{{- $password = randAlphaNum $passwordLength | b64enc | quote }}
{{- end }}
{{- end -}}
{{- end -}}
{{- else if $providedPasswordValue }}
{{- $password = $providedPasswordValue | toString | b64enc | quote }}
Expand All @@ -31,4 +45,4 @@
{{- end }}
{{- end -}}
{{- printf "%s" $password -}}
{{- end -}}
{{- end -}}

0 comments on commit baa3d7c

Please sign in to comment.