Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing volumemount for ca cert, tls #138

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/snyk-broker/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: snyk-broker
version: 2.8.1
version: 2.8.2
description: A Helm chart for Kubernetes
type: application
2 changes: 1 addition & 1 deletion charts/snyk-broker/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Login to the Snyk UI to start onboarding projects: https://app.snyk.io
{{ $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}}
{{- if .Values.useExternalSecrets }}
### Secret Creation Disabled ###

Ensure secrets are present on your cluster in the {{.Release.Namespace}} namespace:
Expand Down
4 changes: 2 additions & 2 deletions charts/snyk-broker/templates/broker_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ spec:
mountPath: /home/node/private
readOnly: true
{{- end }}
{{- if or (.Values.caCert) (.Values.caCertFile) }}
{{- if or (.Values.caCert) (.Values.caCertFile) (and .Values.caCertFileSecret.key .Values.caCertFileSecret.name ) }}
- name: {{ include "snyk-broker.fullname" . }}-cacert-volume
mountPath: /home/node/cacert
readOnly: true
{{- end }}
{{- if and (.Values.httpsCert) (.Values.httpsKey) }}
{{- if or ( and (.Values.httpsCert) (.Values.httpsKey) ) (and .Values.httpsSecret.key .Values.httpsSecret.name ) }}
- name: {{ include "snyk-broker.fullname" . }}-tls-secret-volume
mountPath: /home/node/tls-cert/
readOnly: true
Expand Down
25 changes: 25 additions & 0 deletions charts/snyk-broker/tests/broker_deployment_ca_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,28 @@ tests:
caCertFile: "\n \n-----BEGIN RSA PRIVATE KEY-----\nCERTIFICATE GOES HERE\n-----END RSA PRIVATE KEY-----\n\n\n" #gitleaks:allow
asserts:
- failedTemplate: {}

- it: correctly mounts an external CA secret
set:
useExternalSecrets: true
caCertFileSecret:
name: secret-ca-cert
key: caCert
asserts:
- contains:
path: spec.template.spec.volumes
content:
name: RELEASE-NAME-snyk-broker-cacert-volume
secret:
secretName: secret-ca-cert
template: broker_deployment.yaml
- exists:
path: spec.template.spec.containers[0].volumeMounts
template: broker_deployment.yaml
- contains:
path: spec.template.spec.containers[0].volumeMounts
content:
name: RELEASE-NAME-snyk-broker-cacert-volume
mountPath: /home/node/cacert
readOnly: true
template: broker_deployment.yaml
49 changes: 49 additions & 0 deletions charts/snyk-broker/tests/broker_deployment_tls_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: Broker with TLS
chart:
version: 0.0.0
templates:
- broker_deployment.yaml
- ingress.yaml
values:
- ./fixtures/default_values.yaml
- ./fixtures/default_values_https_enabled.yaml

tests:
- it: sets https correctly
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: HTTPS_CERT
value: /home/node/tls-cert/tls.crt
template: broker_deployment.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: HTTPS_KEY
value: /home/node/tls-cert/tls.key
template: broker_deployment.yaml
- it: uses an external tls secret
set:
useExternalSecrets: true
httpsSecret:
name: my-ingress-cert
asserts:
- contains:
path: spec.template.spec.volumes
content:
name: RELEASE-NAME-snyk-broker-tls-secret-volume
secret:
secretName: my-ingress-cert
template: broker_deployment.yaml
- exists:
path: spec.template.spec.containers[0].volumeMounts
template: broker_deployment.yaml
- contains:
path: spec.template.spec.containers[0].volumeMounts
content:
name: RELEASE-NAME-snyk-broker-tls-secret-volume
mountPath: /home/node/tls-cert/
readOnly: true
template: broker_deployment.yaml
Loading