Skip to content

Commit

Permalink
fix: move ca to secret, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
soniqua committed Jul 15, 2024
1 parent 99aa6f9 commit 92a98a4
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 795 deletions.
20 changes: 15 additions & 5 deletions charts/snyk-broker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,22 @@ Create the name of the broker service to use
{{- end -}}

{{/*
Create TLS secret name
Create a secret name.
Pass a dict of Context ($) and secretName:
include "snyk-broker.genericSecretName" (dict "Context" $ "secretName" "secret-name")
*/}}
{{- define "tls-secret-name" -}}
{{- if not .Values.disableSuffixes -}}
{{ include "snyk-broker.fullname" .}}-tls-secret
{{- define "snyk-broker.genericSecretName" -}}
{{- if not .Context.Values.disableSuffixes -}}
{{ printf "%s-%s" ( include "snyk-broker.fullname" .Context ) .secretName }}
{{- else -}}
tls-secret
{{- printf "snyk-broker-%s" .secretName }}
{{- end -}}
{{- end -}}

{{- define "snyk-broker.tlsSecretName" -}}
{{- include "snyk-broker.genericSecretName" (dict "Context" . "secretName" "tls-secret" ) -}}
{{- end }}

{{- define "snyk-broker.caCertSecretName" -}}
{{- include "snyk-broker.genericSecretName" (dict "Context" . "secretName" "cacert-secret" ) -}}
{{- end }}
6 changes: 3 additions & 3 deletions charts/snyk-broker/templates/broker_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,13 @@ spec:
{{- end }}
{{- if or (.Values.caCert) (.Values.caCertFile) }}
- name: {{ include "snyk-broker.fullname" . }}-cacert-volume
configMap:
name: {{ include "snyk-broker.fullname" . }}-cacert-configmap{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }}
secret:
name: {{ include "snyk-broker.caCertSecretName" . }}
{{- end }}
{{- if and (.Values.httpsCert) (.Values.httpsKey) }}
- name: {{ include "snyk-broker.fullname" . }}-tls-secret-volume
secret:
secretName: {{ include "tls-secret-name" . }}
secretName: {{ include "snyk-broker.tlsSecretName" . }}
{{- end }}
{{- if .Values.extraVolumes }}
{{ tpl (toYaml .Values.extraVolumes | indent 6) . }}
Expand Down
23 changes: 0 additions & 23 deletions charts/snyk-broker/templates/cacert_configmap.yaml

This file was deleted.

18 changes: 17 additions & 1 deletion charts/snyk-broker/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,26 @@ stringData:
apiVersion: v1
kind: Secret
metadata:
name: {{ include "tls-secret-name" . }}
name: {{ include "snyk-broker.tlsSecretName" . }}
type: kubernetes.io/tls
data:
tls.crt: {{ (.Files.Get .Values.httpsCert) | b64enc | quote }}
tls.key: {{ (.Files.Get .Values.httpsKey) | b64enc | quote }}
---
{{- end }}
{{- if or .Values.caCert .Values.caCertFile }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "snyk-broker.caCertSecretName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "snyk-broker.labels" . | nindent 4 }}
data:
{{- if and .Values.caCert (not .Values.caCertFile) }}
{{ (.Files.Glob .Values.caCert).AsSecrets | nindent 2 }}
{{- else if and .Values.caCertFile (not .Values.caCert) }}
cacert: {{ .Values.caCertFile | b64enc | nindent 4}}
{{- end }}
---
{{- end }}
Loading

0 comments on commit 92a98a4

Please sign in to comment.