From f22307ebf510a09255096522779cdcc5dece3fbf Mon Sep 17 00:00:00 2001 From: Robert Seedorff Date: Mon, 12 Apr 2021 12:42:05 +0200 Subject: [PATCH] Fixed HelmChart Temaplates to use the correct chart name and labels. --- .../declerative-subsequent-scans-hook.yaml | 4 +++- .../templates/_helpers.tpl | 16 ++++++++-------- .../templates/finding-post-processing-hook.yaml | 4 +++- .../generic-webhook/templates/webhook-hook.yaml | 4 +++- .../templates/_helpers.tpl | 2 +- .../templates/persistence-provider.yaml | 3 ++- .../templates/persistence-provider.yaml | 3 ++- hooks/teams-webhook/templates/teams-hook.yaml | 2 ++ hooks/update-field/templates/_helpers.tpl | 16 ++++++++-------- .../templates/update-field-hook.yaml | 4 +++- 10 files changed, 35 insertions(+), 23 deletions(-) diff --git a/hooks/declarative-subsequent-scans/templates/declerative-subsequent-scans-hook.yaml b/hooks/declarative-subsequent-scans/templates/declerative-subsequent-scans-hook.yaml index 4802060c04..93a9378bb6 100644 --- a/hooks/declarative-subsequent-scans/templates/declerative-subsequent-scans-hook.yaml +++ b/hooks/declarative-subsequent-scans/templates/declerative-subsequent-scans-hook.yaml @@ -2,8 +2,10 @@ apiVersion: "execution.securecodebox.io/v1" kind: ScanCompletionHook metadata: name: {{ include "declarative-subsequent-scans.fullname" . }} + labels: + {{- include "declarative-subsequent-scans.labels" . | nindent 4 }} spec: type: ReadOnly image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.Version }}" ttlSecondsAfterFinished: {{ .Values.hookJob.ttlSecondsAfterFinished }} - serviceAccountName: declarative-combined-scans \ No newline at end of file + serviceAccountName: declarative-combined-scans diff --git a/hooks/finding-post-processing/templates/_helpers.tpl b/hooks/finding-post-processing/templates/_helpers.tpl index 6371182475..a55808a797 100644 --- a/hooks/finding-post-processing/templates/_helpers.tpl +++ b/hooks/finding-post-processing/templates/_helpers.tpl @@ -17,7 +17,7 @@ limitations under the License. {{/* Expand the name of the chart. */}} -{{- define "add-attribute.name" -}} +{{- define "finding-post-processing.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} @@ -26,7 +26,7 @@ Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). If release name contains chart name it will be used as a full name. */}} -{{- define "add-attribute.fullname" -}} +{{- define "finding-post-processing.fullname" -}} {{- if .Values.fullnameOverride -}} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} {{- else -}} @@ -42,16 +42,16 @@ If release name contains chart name it will be used as a full name. {{/* Create chart name and version as used by the chart label. */}} -{{- define "add-attribute.chart" -}} +{{- define "finding-post-processing.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} {{/* Common labels */}} -{{- define "add-attribute.labels" -}} -helm.sh/chart: {{ include "add-attribute.chart" . }} -{{ include "add-attribute.selectorLabels" . }} +{{- define "finding-post-processing.labels" -}} +helm.sh/chart: {{ include "finding-post-processing.chart" . }} +{{ include "finding-post-processing.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -61,7 +61,7 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Selector labels */}} -{{- define "add-attribute.selectorLabels" -}} -app.kubernetes.io/name: {{ include "add-attribute.name" . }} +{{- define "finding-post-processing.selectorLabels" -}} +app.kubernetes.io/name: {{ include "finding-post-processing.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end -}} diff --git a/hooks/finding-post-processing/templates/finding-post-processing-hook.yaml b/hooks/finding-post-processing/templates/finding-post-processing-hook.yaml index 206ea30f5b..72208da12e 100644 --- a/hooks/finding-post-processing/templates/finding-post-processing-hook.yaml +++ b/hooks/finding-post-processing/templates/finding-post-processing-hook.yaml @@ -15,7 +15,9 @@ apiVersion: "execution.securecodebox.io/v1" kind: ScanCompletionHook metadata: - name: {{ .Release.Name }} + name: {{ include "finding-post-processing.fullname" . }} + labels: + {{- include "finding-post-processing.labels" . | nindent 4 }} spec: type: ReadAndWrite image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.Version }}" diff --git a/hooks/generic-webhook/templates/webhook-hook.yaml b/hooks/generic-webhook/templates/webhook-hook.yaml index 98415bc9ee..10aa86ce26 100644 --- a/hooks/generic-webhook/templates/webhook-hook.yaml +++ b/hooks/generic-webhook/templates/webhook-hook.yaml @@ -2,10 +2,12 @@ apiVersion: "execution.securecodebox.io/v1" kind: ScanCompletionHook metadata: name: {{ include "generic-webhook.fullname" . }} + labels: + {{- include "generic-webhook.labels" . | nindent 4 }} spec: type: ReadOnly image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.Version }}" ttlSecondsAfterFinished: {{ .Values.hookJob.ttlSecondsAfterFinished }} env: - name: WEBHOOK_URL - value: {{ .Values.webhookUrl | quote }} \ No newline at end of file + value: {{ .Values.webhookUrl | quote }} diff --git a/hooks/persistence-defectdojo/templates/_helpers.tpl b/hooks/persistence-defectdojo/templates/_helpers.tpl index 2a3c9b5f01..dbc2230c17 100644 --- a/hooks/persistence-defectdojo/templates/_helpers.tpl +++ b/hooks/persistence-defectdojo/templates/_helpers.tpl @@ -35,7 +35,7 @@ Create chart name and version as used by the chart label. Common labels */}} {{- define "persistence-defectdojo.labels" -}} -helm.sh/chart: {{ include "defectdojo-elastic.chart" . }} +helm.sh/chart: {{ include "persistence-defectdojo.chart" . }} {{ include "persistence-defectdojo.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} diff --git a/hooks/persistence-defectdojo/templates/persistence-provider.yaml b/hooks/persistence-defectdojo/templates/persistence-provider.yaml index 4e8e3eb60b..30e7507ecb 100644 --- a/hooks/persistence-defectdojo/templates/persistence-provider.yaml +++ b/hooks/persistence-defectdojo/templates/persistence-provider.yaml @@ -1,8 +1,9 @@ apiVersion: "execution.securecodebox.io/v1" kind: ScanCompletionHook metadata: - name: {{ .Release.Name }} + name: {{ include "persistence-defectdojo.fullname" . }} labels: + {{- include "persistence-defectdojo.labels" . | nindent 4 }} type: Unstructured spec: {{- if .Values.defectdojo.syncFindingsBack }} diff --git a/hooks/persistence-elastic/templates/persistence-provider.yaml b/hooks/persistence-elastic/templates/persistence-provider.yaml index 4ff34942d6..99af75e803 100644 --- a/hooks/persistence-elastic/templates/persistence-provider.yaml +++ b/hooks/persistence-elastic/templates/persistence-provider.yaml @@ -1,8 +1,9 @@ apiVersion: "execution.securecodebox.io/v1" kind: ScanCompletionHook metadata: - name: {{ .Release.Name }} + name: {{ include "persistence-elastic.fullname" . }} labels: + {{- include "persistence-elastic.labels" . | nindent 4 }} type: Structured spec: type: ReadOnly diff --git a/hooks/teams-webhook/templates/teams-hook.yaml b/hooks/teams-webhook/templates/teams-hook.yaml index 13291d8359..d1921cdc7d 100644 --- a/hooks/teams-webhook/templates/teams-hook.yaml +++ b/hooks/teams-webhook/templates/teams-hook.yaml @@ -2,6 +2,8 @@ apiVersion: "execution.securecodebox.io/v1" kind: ScanCompletionHook metadata: name: {{ include "teams-webhook.fullname" . }} + labels: + {{- include "teams-webhook.labels" . | nindent 4 }} spec: type: ReadOnly image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.Version }}" diff --git a/hooks/update-field/templates/_helpers.tpl b/hooks/update-field/templates/_helpers.tpl index 17523abcc6..6dddc3f0a1 100644 --- a/hooks/update-field/templates/_helpers.tpl +++ b/hooks/update-field/templates/_helpers.tpl @@ -2,7 +2,7 @@ {{/* Expand the name of the chart. */}} -{{- define "add-attribute.name" -}} +{{- define "update-field.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} @@ -11,7 +11,7 @@ Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). If release name contains chart name it will be used as a full name. */}} -{{- define "add-attribute.fullname" -}} +{{- define "update-field.fullname" -}} {{- if .Values.fullnameOverride -}} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} {{- else -}} @@ -27,16 +27,16 @@ If release name contains chart name it will be used as a full name. {{/* Create chart name and version as used by the chart label. */}} -{{- define "add-attribute.chart" -}} +{{- define "update-field.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} {{/* Common labels */}} -{{- define "add-attribute.labels" -}} -helm.sh/chart: {{ include "add-attribute.chart" . }} -{{ include "add-attribute.selectorLabels" . }} +{{- define "update-field.labels" -}} +helm.sh/chart: {{ include "update-field.chart" . }} +{{ include "update-field.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -46,7 +46,7 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Selector labels */}} -{{- define "add-attribute.selectorLabels" -}} -app.kubernetes.io/name: {{ include "add-attribute.name" . }} +{{- define "update-field.selectorLabels" -}} +app.kubernetes.io/name: {{ include "update-field.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end -}} diff --git a/hooks/update-field/templates/update-field-hook.yaml b/hooks/update-field/templates/update-field-hook.yaml index e20f76c406..7ae08bca93 100644 --- a/hooks/update-field/templates/update-field-hook.yaml +++ b/hooks/update-field/templates/update-field-hook.yaml @@ -1,7 +1,9 @@ apiVersion: "execution.securecodebox.io/v1" kind: ScanCompletionHook metadata: - name: {{ .Release.Name }} + name: {{ include "update-field.fullname" . }} + labels: + {{- include "update-field.labels" . | nindent 4 }} spec: type: ReadAndWrite image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.Version }}"