Skip to content

Commit

Permalink
feat: support usage of external/custom name secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
soniqua committed Aug 30, 2024
1 parent 10d852c commit ebb67e7
Show file tree
Hide file tree
Showing 14 changed files with 1,116 additions and 478 deletions.
14 changes: 13 additions & 1 deletion charts/snyk-broker/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Thank you for installing the Snyk Broker

{{- if eq .Values.brokerServerUrl "https://broker.snyk.io" }}
Login to the Snyk UI to start onboarding projects: https://app.snyk.io
{{ else }}
{{ $tenant := regexFind "[a-z]+.snyk.io" .Values.brokerServerUrl }}
{{ printf "Login to the Snyk UI to start onboarding projects: https://app.%s" $tenant }}
{{ end }}
{{- if not .Values.useExternalSecrets}}
### Secret Creation Disabled ###

Ensure secrets are present on your cluster in the {{.Release.Namespace}} namespace:

-> NAME:KEY <VALUE>
{{- include "snyk-broker.requiredSecrets" . }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/snyk-broker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ include "snyk-broker.genericSecretName" (dict "Context" $ "secretName" "secret-n
{{- end -}}

{{- define "snyk-broker.tlsSecretName" -}}
{{- include "snyk-broker.genericSecretName" (dict "Context" . "secretName" "tls-secret" ) -}}
{{- .Values.httpsSecret.name | default ( include "snyk-broker.genericSecretName" (dict "Context" . "secretName" "tls-secret" ) ) -}}
{{- end }}

{{- define "snyk-broker.caCertSecretName" -}}
{{- include "snyk-broker.genericSecretName" (dict "Context" . "secretName" "cacert-secret" ) -}}
{{- .Values.caCertFileSecret.name | default ( include "snyk-broker.genericSecretName" (dict "Context" . "secretName" "cacert-secret" ) ) -}}
{{- end }}

{{/*
Expand Down
25 changes: 25 additions & 0 deletions charts/snyk-broker/templates/_notes.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{/*
*/}}
{{- define "snyk-broker.requiredSecrets" -}}
{{- $scmTemplates := (list "scmTokenOrPool") }}
{{- $artifactoryTemplates := (list "artifactoryUrl" "brokerClientValidationUrl" ) }}
{{- $nexusTemplates := (list "baseNexusUrl" "nexusUrl" "brokerClientValidationUrl" )}}
{{- $containerRegistryAgentTemplates := (list "scmToken" )}}
{{- $templatesPerType := (dict "github-com" $scmTemplates "github-enterprise" $scmTemplates "gitlab" $scmTemplates "bitbucket-server" $scmTemplates "bitbucket-server-bearer-auth" $scmTemplates "azure-repos" $scmTemplates "artifactory" $artifactoryTemplates "nexus" $nexusTemplates "jira" $scmTemplates "jira-bearer-auth" $scmTemplates "container-registry-agent" $containerRegistryAgentTemplates ) }}
{{- if not .Values.useExternalSecrets -}}
{{- range (get $templatesPerType .Values.scmType ) }}
{{- $secretObject := (first (fromYamlArray (include (printf "snyk-broker.%s" . ) $ ))) }}
{{- $envName := $secretObject.name }}
{{- $name := $secretObject.valueFrom.secretKeyRef.name }}
{{- $key := $secretObject.valueFrom.secretKeyRef.key }}
{{ printf "-> %s:%s <%s>" $name $key $envName }}
{{- end }}
{{- if .Values.httpsSecret.name }}
{{ printf "-> %s:%s <your-certificate>" .Values.httpsSecret.name "tls.crt" }}
{{ printf "-> %s:%s <your-certificate-key>" .Values.httpsSecret.name "tls.key" }}
{{- end }}
{{- if (and .Values.caCertFileSecret.name .Values.caCertFileSecret.key ) }}
{{ printf "-> %s:%s <your-pem-certificate-material>" .Values.caCertFileSecret.name .Values.caCertFileSecret.key }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit ebb67e7

Please sign in to comment.