diff --git a/charts/guac/Chart.yaml b/charts/guac/Chart.yaml index f9fec70..daf6dd5 100644 --- a/charts/guac/Chart.yaml +++ b/charts/guac/Chart.yaml @@ -9,8 +9,8 @@ maintainers: email: guac-info@kusari.dev type: application -version: 0.7.0 -appVersion: "v0.14.0" +version: 0.8.0 +appVersion: "v1.0.1" dependencies: - name: nats diff --git a/charts/guac/README.md b/charts/guac/README.md index 518e0e7..fad2a22 100644 --- a/charts/guac/README.md +++ b/charts/guac/README.md @@ -255,6 +255,7 @@ This section contains parameters for configuring the different GUAC components. | `guac.pubSubAddr` | String gocloud connection string for pubsub configured via https://gocloud.dev/howto/pubsub/ | `undefined` | | `guac.collectorPublishToQueue` | Whether to publish ingestion message to pubsub queue | `true` | | `guac.blobAddr` | gocloud connection string for blob store configured via https://gocloud.dev/howto/blob/ | `undefined` | +| `guac.customLabels` | Custom labels to apply to all GUAC resources | `{}` | | `guac.additionalResources` | | `{}` | ### nats @@ -312,7 +313,7 @@ For running the unit tests, install the unittest plugin. To run unit tests -`helm unittest charts/guac -3` +`helm unittest charts/guac` To run Helm chart-testing (ct) lint and install tests diff --git a/charts/guac/schema.json b/charts/guac/schema.json index 336c781..95af710 100644 --- a/charts/guac/schema.json +++ b/charts/guac/schema.json @@ -1013,6 +1013,11 @@ "type": "object", "description": "", "default": {} + }, + "customLabels": { + "type": "object", + "description": "custom labels for all resources", + "default": {} } } }, diff --git a/charts/guac/templates/_helpers.tpl b/charts/guac/templates/_helpers.tpl index a4a6282..c9107e6 100644 --- a/charts/guac/templates/_helpers.tpl +++ b/charts/guac/templates/_helpers.tpl @@ -35,6 +35,15 @@ Create chart name and version as used by the chart label. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} +{{/* +User defined labels +*/}} +{{- define "guac.common.labels" -}} +{{- if .Values.guac.customLabels -}} +{{- toYaml .Values.guac.customLabels }} +{{- end }} +{{- end }} + {{/* Common labels */}} @@ -45,6 +54,9 @@ helm.sh/chart: {{ include "guac.chart" . }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- if .Values.guac.customLabels }} +{{ toYaml .Values.guac.customLabels }} +{{- end }} {{- end }} {{/* diff --git a/charts/guac/templates/cd-certifier-deployment.yaml b/charts/guac/templates/cd-certifier-deployment.yaml index b29c44e..2000a90 100644 --- a/charts/guac/templates/cd-certifier-deployment.yaml +++ b/charts/guac/templates/cd-certifier-deployment.yaml @@ -24,7 +24,7 @@ spec: template: metadata: labels: - {{- include "guac.selectorLabels" . | nindent 8 }} + {{- include "guac.labels" . | nindent 8 }} app.kubernetes.io/name: {{ .Values.guac.cdCertifier.name }} app.kubernetes.io/component: {{ .Values.guac.cdCertifier.name }} spec: diff --git a/charts/guac/templates/collectsub-deployment.yaml b/charts/guac/templates/collectsub-deployment.yaml index f0f3dbb..e660e4a 100644 --- a/charts/guac/templates/collectsub-deployment.yaml +++ b/charts/guac/templates/collectsub-deployment.yaml @@ -24,7 +24,7 @@ spec: template: metadata: labels: - {{- include "guac.selectorLabels" . | nindent 8 }} + {{- include "guac.labels" . | nindent 8 }} app.kubernetes.io/name: {{ .Values.guac.collectSub.name }} app.kubernetes.io/component: {{ .Values.guac.collectSub.name }} spec: diff --git a/charts/guac/templates/depsdev-collector-deployment.yaml b/charts/guac/templates/depsdev-collector-deployment.yaml index c537ce1..6694b8f 100644 --- a/charts/guac/templates/depsdev-collector-deployment.yaml +++ b/charts/guac/templates/depsdev-collector-deployment.yaml @@ -24,7 +24,7 @@ spec: template: metadata: labels: - {{- include "guac.selectorLabels" . | nindent 8 }} + {{- include "guac.labels" . | nindent 8 }} app.kubernetes.io/name: {{ .Values.guac.depsDevCollector.name }} app.kubernetes.io/component: {{ .Values.guac.depsDevCollector.name }} spec: diff --git a/charts/guac/templates/graphql-server-deployment.yaml b/charts/guac/templates/graphql-server-deployment.yaml index 10f925b..f0addf2 100644 --- a/charts/guac/templates/graphql-server-deployment.yaml +++ b/charts/guac/templates/graphql-server-deployment.yaml @@ -24,7 +24,7 @@ spec: template: metadata: labels: - {{- include "guac.selectorLabels" . | nindent 8 }} + {{- include "guac.labels" . | nindent 8 }} app.kubernetes.io/name: {{ .Values.guac.graphqlServer.name }} app.kubernetes.io/component: {{ .Values.guac.graphqlServer.name }} spec: diff --git a/charts/guac/templates/guac-cm.yaml b/charts/guac/templates/guac-cm.yaml index 2ca32e1..699be72 100644 --- a/charts/guac/templates/guac-cm.yaml +++ b/charts/guac/templates/guac-cm.yaml @@ -6,6 +6,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: guac-cm + labels: + {{- include "guac.labels" . | nindent 4 }} data: guac.yaml: | diff --git a/charts/guac/templates/guacrest-deployment.yaml b/charts/guac/templates/guacrest-deployment.yaml index fe2a516..4ce43cd 100644 --- a/charts/guac/templates/guacrest-deployment.yaml +++ b/charts/guac/templates/guacrest-deployment.yaml @@ -24,7 +24,7 @@ spec: template: metadata: labels: - {{- include "guac.selectorLabels" . | nindent 8 }} + {{- include "guac.labels" . | nindent 8 }} app.kubernetes.io/name: {{ .Values.guac.restApi.name }} app.kubernetes.io/component: {{ .Values.guac.restApi.name }} spec: diff --git a/charts/guac/templates/ingest-guac-data-job.yaml b/charts/guac/templates/ingest-guac-data-job.yaml index 9da52dc..09f54d4 100644 --- a/charts/guac/templates/ingest-guac-data-job.yaml +++ b/charts/guac/templates/ingest-guac-data-job.yaml @@ -78,6 +78,7 @@ kind: ConfigMap metadata: name: {{ .Values.guac.sampleData.jobName }} labels: + {{- include "guac.labels" . | nindent 4 }} app.kubernetes.io/name: {{ .Values.guac.sampleData.jobName }} app.kubernetes.io/component: {{ .Values.guac.sampleData.jobName }} app.kubernetes.io/instance: {{ .Release.Name | quote }} @@ -126,7 +127,7 @@ data: echo running guacone collect... time /tmp/guacone collect files ${SHARED_DATA}/guac-data/top-dh-sboms/zookeeper.json # for d in guac-data/docs - # do + # do # done diff --git a/charts/guac/templates/ingestor-deployment.yaml b/charts/guac/templates/ingestor-deployment.yaml index 5528899..4083b03 100644 --- a/charts/guac/templates/ingestor-deployment.yaml +++ b/charts/guac/templates/ingestor-deployment.yaml @@ -24,7 +24,7 @@ spec: template: metadata: labels: - {{- include "guac.selectorLabels" . | nindent 8 }} + {{- include "guac.labels" . | nindent 8 }} app.kubernetes.io/name: {{ .Values.guac.ingestor.name }} app.kubernetes.io/component: {{ .Values.guac.ingestor.name }} spec: diff --git a/charts/guac/templates/ingressroute.yaml b/charts/guac/templates/ingressroute.yaml index 1c482bf..2023b41 100644 --- a/charts/guac/templates/ingressroute.yaml +++ b/charts/guac/templates/ingressroute.yaml @@ -5,6 +5,8 @@ kind: IngressRoute metadata: name: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }} + labels: + {{- include "guac.labels" . | nindent 4 }} spec: entryPoints: {{- range .Values.guac.traefikIngressRoute.entryPoints }} diff --git a/charts/guac/templates/oci-collector-deployment.yaml b/charts/guac/templates/oci-collector-deployment.yaml index 400abec..7fb2d1e 100644 --- a/charts/guac/templates/oci-collector-deployment.yaml +++ b/charts/guac/templates/oci-collector-deployment.yaml @@ -24,7 +24,7 @@ spec: template: metadata: labels: - {{- include "guac.selectorLabels" . | nindent 8 }} + {{- include "guac.labels" . | nindent 8 }} app.kubernetes.io/name: {{ .Values.guac.ociCollector.name }} app.kubernetes.io/component: {{ .Values.guac.ociCollector.name }} spec: diff --git a/charts/guac/templates/osv-certifier-deployment.yaml b/charts/guac/templates/osv-certifier-deployment.yaml index 2837e39..d792ef4 100644 --- a/charts/guac/templates/osv-certifier-deployment.yaml +++ b/charts/guac/templates/osv-certifier-deployment.yaml @@ -24,7 +24,7 @@ spec: template: metadata: labels: - {{- include "guac.selectorLabels" . | nindent 8 }} + {{- include "guac.labels" . | nindent 8 }} app.kubernetes.io/name: {{ .Values.guac.osvCertifier.name }} app.kubernetes.io/component: {{ .Values.guac.osvCertifier.name }} spec: diff --git a/charts/guac/templates/scorecard-certifier-deployment.yaml b/charts/guac/templates/scorecard-certifier-deployment.yaml index 4b8f5f9..8caf57d 100644 --- a/charts/guac/templates/scorecard-certifier-deployment.yaml +++ b/charts/guac/templates/scorecard-certifier-deployment.yaml @@ -24,7 +24,7 @@ spec: template: metadata: labels: - {{- include "guac.selectorLabels" . | nindent 8 }} + {{- include "guac.labels" . | nindent 8 }} app.kubernetes.io/name: {{ .Values.guac.scorecardCertifier.name }} app.kubernetes.io/component: {{ .Values.guac.scorecardCertifier.name }} spec: diff --git a/charts/guac/templates/visualizer-deployment.yaml b/charts/guac/templates/visualizer-deployment.yaml index 1128a99..fd0694c 100644 --- a/charts/guac/templates/visualizer-deployment.yaml +++ b/charts/guac/templates/visualizer-deployment.yaml @@ -24,7 +24,7 @@ spec: template: metadata: labels: - {{- include "guac.selectorLabels" . | nindent 8 }} + {{- include "guac.labels" . | nindent 8 }} app.kubernetes.io/name: {{ .Values.guac.visualizer.name }} app.kubernetes.io/component: {{ .Values.guac.visualizer.name }} spec: diff --git a/charts/guac/templates/visualizer-proxy-cm.yaml b/charts/guac/templates/visualizer-proxy-cm.yaml index 084bc2f..b706e44 100644 --- a/charts/guac/templates/visualizer-proxy-cm.yaml +++ b/charts/guac/templates/visualizer-proxy-cm.yaml @@ -5,6 +5,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: visualizer-proxy-cm + labels: + {{- include "guac.labels" . | nindent 4 }} data: default.conf: | server { diff --git a/charts/guac/tests/customlabels_all_resources_test.yaml b/charts/guac/tests/customlabels_all_resources_test.yaml new file mode 100644 index 0000000..77cf7ae --- /dev/null +++ b/charts/guac/tests/customlabels_all_resources_test.yaml @@ -0,0 +1,356 @@ +# Copyright Kusari, Inc. and GUAC contributors +# Licensed under the MIT license. See LICENSE file in the project root for details. +suite: Custom Labels on All Resources tests +templates: + - graphql-server-deployment.yaml + - graphql-server-service.yaml + - graphql-server-sa.yaml + - guacrest-deployment.yaml + - guacrest-service.yaml + - guacrest-sa.yaml + - ingestor-deployment.yaml + - ingestor-sa.yaml + - collectsub-deployment.yaml + - collectsub-service.yaml + - collectsub-sa.yaml + - oci-collector-deployment.yaml + - oci-collector-sa.yaml + - depsdev-collector-deployment.yaml + - depsdev-collector-sa.yaml + - osv-certifier-deployment.yaml + - osv-certifier-sa.yaml + - cd-certifier-deployment.yaml + - cd-certifier-sa.yaml + - visualizer-deployment.yaml + - visualizer-service.yaml + - scorecard-certifier-deployment.yaml + - scorecard-certifier-sa.yaml + - guac-cm.yaml + - api-only-ingress.yaml + - ingress.yaml + - ingressroute.yaml + +tests: + - it: should include customLabels in graphql-server deployment + template: graphql-server-deployment.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in guacrest deployment + template: guacrest-deployment.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in ingestor deployment + template: ingestor-deployment.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in collectsub deployment + template: collectsub-deployment.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in oci-collector deployment + template: oci-collector-deployment.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in depsdev-collector deployment + template: depsdev-collector-deployment.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in osv-certifier deployment + template: osv-certifier-deployment.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in cd-certifier deployment + template: cd-certifier-deployment.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in visualizer deployment + template: visualizer-deployment.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in graphql-server service + template: graphql-server-service.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in guacrest service + template: guacrest-service.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in collectsub service + template: collectsub-service.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in visualizer service + template: visualizer-service.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in graphql-server service account + template: graphql-server-sa.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in guacrest service account + template: guacrest-sa.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in ingestor service account + template: ingestor-sa.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in collectsub service account + template: collectsub-sa.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in oci-collector service account + template: oci-collector-sa.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in depsdev-collector service account + template: depsdev-collector-sa.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in osv-certifier service account + template: osv-certifier-sa.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in cd-certifier service account + template: cd-certifier-sa.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in scorecard-certifier deployment + template: scorecard-certifier-deployment.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in scorecard-certifier service account + template: scorecard-certifier-sa.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in guac configmap + template: guac-cm.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in ingress + template: ingress.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in api-only-ingress + template: api-only-ingress.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 + + - it: should include customLabels in traefik ingressroute + template: ingressroute.yaml + values: + - ./values_customlabels.yaml + asserts: + - equal: + path: metadata.labels.customlabel-1 + value: value-1 + - equal: + path: metadata.labels.customlabel-2 + value: value-2 diff --git a/charts/guac/tests/values_customlabels.yaml b/charts/guac/tests/values_customlabels.yaml new file mode 100644 index 0000000..e8aa296 --- /dev/null +++ b/charts/guac/tests/values_customlabels.yaml @@ -0,0 +1,18 @@ +# Copyright Kusari, Inc. and GUAC contributors +# Licensed under the MIT license. See LICENSE file in the project root for details. +guac: + customLabels: + customlabel-1: value-1 + customlabel-2: value-2 + + ingress: + enabled: true + + apiOnlyIngress: + enabled: true + + traefikIngressRoute: + enabled: true + + scorecardCertifier: + enabled: true diff --git a/charts/guac/values.yaml b/charts/guac/values.yaml index 8f4a5a3..5c4c242 100644 --- a/charts/guac/values.yaml +++ b/charts/guac/values.yaml @@ -175,6 +175,7 @@ imagePullSecrets: ## @param guac.pubSubAddr [nullable] String gocloud connection string for pubsub configured via https://gocloud.dev/howto/pubsub/ ## @param guac.collectorPublishToQueue Whether to publish ingestion message to pubsub queue ## @param guac.blobAddr [nullable] gocloud connection string for blob store configured via https://gocloud.dev/howto/blob/ +## @param guac.customLabels [object] Custom labels to apply to all GUAC resources ## @param guac.additionalResources guac: @@ -485,6 +486,8 @@ guac: # blobAddr: s3://[bucket_name]?region=[aws_region] # blobAddr: file:///tmp/blobstore?no_tmp_dir=true + customLabels: {} + additionalResources: {}