-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
284 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
snyk-universal-broker/templates/commit-signing-secret.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{{- if and .Values.commitSigning.enabled ( not .Values.commitSigningSecret.name ) }} | ||
{{- $unsetKeys:= list -}} | ||
{{- range ( unset .Values.commitSigning "enabled" | keys ) -}} | ||
{{- if not (get $.Values.commitSigning . ) }} | ||
{{- $unsetKeys = append $unsetKeys . -}} | ||
{{- end }} | ||
{{- end }} | ||
{{- if gt (len $unsetKeys) 0 -}} | ||
{{- fail (printf "Missing value(s) under .Values.commitSigning for: %s" (join "," $unsetKeys) ) }} | ||
{{- end }} | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: {{ include "snyk-broker.commitSigningSecretName" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} | ||
data: | ||
GPG_PRIVATE_KEY: {{ .Values.commitSigning.gpgPrivateKey | b64enc }} | ||
GPG_PASSPHRASE: {{ .Values.commitSigning.passphrase | b64enc }} | ||
GIT_COMMITER_NAME: {{ .Values.commitSigning.name | b64enc }} | ||
GIT_COMMITER_EMAIL: {{ .Values.commitSigning.email | b64enc }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json | ||
suite: Commit Signing | ||
templates: | ||
- statefulset.yaml | ||
- commit-signing-secret.yaml | ||
values: | ||
- ../values.yaml | ||
- fixtures/default_values.yaml | ||
|
||
tests: | ||
- it: enables commit signing with inline private key | ||
set: | ||
commitSigning: | ||
enabled: true | ||
name: "Bot" | ||
email: "bot@corp.io" | ||
passphrase: "fake" | ||
gpgPrivateKey: "-----BEGIN GPG PRIVATE KEY BLOCK-----\nFAKE\n-----END GPG PRIVATE KEY BLOCK-----" | ||
asserts: | ||
- contains: | ||
path: spec.template.spec.containers[0].envFrom | ||
content: | ||
secretRef: | ||
name: RELEASE-NAME-commit-signing-secret | ||
template: statefulset.yaml | ||
- equal: | ||
path: data.GPG_PRIVATE_KEY | ||
value: LS0tLS1CRUdJTiBHUEcgUFJJVkFURSBLRVkgQkxPQ0stLS0tLQpGQUtFCi0tLS0tRU5EIEdQRyBQUklWQVRFIEtFWSBCTE9DSy0tLS0t | ||
template: commit-signing-secret.yaml | ||
- equal: | ||
path: data.GPG_PASSPHRASE | ||
value: ZmFrZQ== | ||
template: commit-signing-secret.yaml | ||
- equal: | ||
path: data.GIT_COMMITER_NAME | ||
value: Qm90 | ||
template: commit-signing-secret.yaml | ||
- equal: | ||
path: data.GIT_COMMITER_EMAIL | ||
value: Ym90QGNvcnAuaW8= | ||
template: commit-signing-secret.yaml | ||
|
||
- it: enables commit signing with multiline private key | ||
set: | ||
commitSigning: | ||
enabled: true | ||
name: "Bot" | ||
email: "bot@corp.io" | ||
passphrase: "fake" | ||
gpgPrivateKey: |- | ||
-----BEGIN GPG PRIVATE KEY BLOCK----- | ||
FAKE | ||
-----END GPG PRIVATE KEY BLOCK----- | ||
asserts: | ||
- contains: | ||
path: spec.template.spec.containers[0].envFrom | ||
content: | ||
secretRef: | ||
name: RELEASE-NAME-commit-signing-secret | ||
template: statefulset.yaml | ||
- equal: | ||
path: data.GPG_PRIVATE_KEY | ||
value: LS0tLS1CRUdJTiBHUEcgUFJJVkFURSBLRVkgQkxPQ0stLS0tLQpGQUtFCi0tLS0tRU5EIEdQRyBQUklWQVRFIEtFWSBCTE9DSy0tLS0t | ||
template: commit-signing-secret.yaml | ||
- equal: | ||
path: data.GPG_PASSPHRASE | ||
value: ZmFrZQ== | ||
template: commit-signing-secret.yaml | ||
- equal: | ||
path: data.GIT_COMMITER_NAME | ||
value: Qm90 | ||
template: commit-signing-secret.yaml | ||
- equal: | ||
path: data.GIT_COMMITER_EMAIL | ||
value: Ym90QGNvcnAuaW8= | ||
template: commit-signing-secret.yaml | ||
|
||
- it: fails if one of the commit signing values is missing and no external secret is specified | ||
set: | ||
commitSigning: | ||
enabled: true | ||
name: "Bot" | ||
email: "bot@corp.io" | ||
gpgPrivateKey: "-----BEGIN GPG PRIVATE KEY BLOCK-----\nFAKE\n-----END GPG PRIVATE KEY BLOCK-----" | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: "Missing value(s) under .Values.commitSigning for: passphrase" | ||
template: commit-signing-secret.yaml | ||
|
||
- it: uses an external secret if specified | ||
set: | ||
commitSigning: | ||
enabled: true | ||
commitSigningSecret: | ||
name: "my-commit-signing-secret" | ||
asserts: | ||
- contains: | ||
path: spec.template.spec.containers[0].envFrom | ||
content: | ||
secretRef: | ||
name: my-commit-signing-secret | ||
template: statefulset.yaml | ||
|
||
- it: uses an external secret if specified, ignoring any values set under commitSigning | ||
set: | ||
commitSigning: | ||
enabled: true | ||
name: "Bot" | ||
email: "bot@corp.io" | ||
commitSigningSecret: | ||
name: "my-commit-signing-secret" | ||
asserts: | ||
- contains: | ||
path: spec.template.spec.containers[0].envFrom | ||
content: | ||
secretRef: | ||
name: my-commit-signing-secret | ||
template: statefulset.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters