From 8d34b58ec2506674dd57a45e0dd46d2d2a061798 Mon Sep 17 00:00:00 2001 From: roth-wine Date: Thu, 17 Oct 2024 12:56:41 +0200 Subject: [PATCH] fix(charts/flux2,crds): crds.annotations got respected now In the flux2 helm chart there is already the possibility to set the value `crds.annotations`. Unfortunately, this value is not used anywhere because the corresponding templates are missing in the crds. With this merge request I want to add templating to the generated crds so that this value can not only be set without meaning, but also so that the annotations in the crds can actually be customised. Signed-off-by: roth-wine --- charts/flux2/Chart.yaml | 4 ++-- charts/flux2/README.md | 2 +- charts/flux2/templates/helm-controller.crds.yaml | 3 +++ .../image-automation-controller.crds.yaml | 3 +++ .../image-reflector-controller.crds.yaml | 6 ++++++ .../templates/kustomize-controller.crds.yaml | 3 +++ .../templates/notification-controller.crds.yaml | 9 +++++++++ .../flux2/templates/source-controller.crds.yaml | 15 +++++++++++++++ .../__snapshot__/helm-controller_test.yaml.snap | 2 +- .../image-automation-controller_test.yaml.snap | 2 +- .../image-reflector-controller_test.yaml.snap | 2 +- .../kustomize-controller-secret_test.yaml.snap | 2 +- .../kustomize-controller_test.yaml.snap | 2 +- .../notification-controller_test.yaml.snap | 2 +- .../__snapshot__/pre-install-job_test.yaml.snap | 4 ++-- .../__snapshot__/source-controller_test.yaml.snap | 2 +- hack/generate.sh | 1 + 17 files changed, 52 insertions(+), 12 deletions(-) diff --git a/charts/flux2/Chart.yaml b/charts/flux2/Chart.yaml index b2bf66a..adf5ee5 100644 --- a/charts/flux2/Chart.yaml +++ b/charts/flux2/Chart.yaml @@ -1,6 +1,6 @@ annotations: artifacthub.io/changes: | - - "[Chore]: Update App Version to upstream 2.4.0" + - "fix(charts/flux2,crds): crds.annotations got respected now" apiVersion: v2 appVersion: 2.4.0 description: A Helm chart for flux2 @@ -8,4 +8,4 @@ name: flux2 sources: - https://github.com/fluxcd-community/helm-charts type: application -version: 2.14.0 +version: 2.14.1 diff --git a/charts/flux2/README.md b/charts/flux2/README.md index 83e06c3..6c89a75 100644 --- a/charts/flux2/README.md +++ b/charts/flux2/README.md @@ -1,6 +1,6 @@ # flux2 -![Version: 2.14.0](https://img.shields.io/badge/Version-2.14.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.4.0](https://img.shields.io/badge/AppVersion-2.4.0-informational?style=flat-square) +![Version: 2.14.1](https://img.shields.io/badge/Version-2.14.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.4.0](https://img.shields.io/badge/AppVersion-2.4.0-informational?style=flat-square) A Helm chart for flux2 diff --git a/charts/flux2/templates/helm-controller.crds.yaml b/charts/flux2/templates/helm-controller.crds.yaml index 0092a3d..7b9e83a 100644 --- a/charts/flux2/templates/helm-controller.crds.yaml +++ b/charts/flux2/templates/helm-controller.crds.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: helm-controller diff --git a/charts/flux2/templates/image-automation-controller.crds.yaml b/charts/flux2/templates/image-automation-controller.crds.yaml index dd0c6ad..351e268 100644 --- a/charts/flux2/templates/image-automation-controller.crds.yaml +++ b/charts/flux2/templates/image-automation-controller.crds.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: image-automation-controller diff --git a/charts/flux2/templates/image-reflector-controller.crds.yaml b/charts/flux2/templates/image-reflector-controller.crds.yaml index 4222253..a394315 100644 --- a/charts/flux2/templates/image-reflector-controller.crds.yaml +++ b/charts/flux2/templates/image-reflector-controller.crds.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: image-reflector-controller @@ -415,6 +418,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: image-reflector-controller diff --git a/charts/flux2/templates/kustomize-controller.crds.yaml b/charts/flux2/templates/kustomize-controller.crds.yaml index 4ca9a06..e32a56a 100644 --- a/charts/flux2/templates/kustomize-controller.crds.yaml +++ b/charts/flux2/templates/kustomize-controller.crds.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: kustomize-controller diff --git a/charts/flux2/templates/notification-controller.crds.yaml b/charts/flux2/templates/notification-controller.crds.yaml index ee7a2e6..8aff5b6 100644 --- a/charts/flux2/templates/notification-controller.crds.yaml +++ b/charts/flux2/templates/notification-controller.crds.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: notification-controller @@ -586,6 +589,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: notification-controller @@ -1128,6 +1134,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: notification-controller diff --git a/charts/flux2/templates/source-controller.crds.yaml b/charts/flux2/templates/source-controller.crds.yaml index 44a63da..6cd3c2f 100644 --- a/charts/flux2/templates/source-controller.crds.yaml +++ b/charts/flux2/templates/source-controller.crds.yaml @@ -3,6 +3,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: source-controller @@ -994,6 +997,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: source-controller @@ -2258,6 +2264,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: source-controller @@ -3241,6 +3250,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: source-controller @@ -4092,6 +4104,9 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: + {{- with .Values.crds.annotations }} + {{- . | toYaml | nindent 4 }} + {{- end }} controller-gen.kubebuilder.io/version: v0.16.1 labels: app.kubernetes.io/component: source-controller diff --git a/charts/flux2/tests/__snapshot__/helm-controller_test.yaml.snap b/charts/flux2/tests/__snapshot__/helm-controller_test.yaml.snap index 4cbdb8c..777115f 100644 --- a/charts/flux2/tests/__snapshot__/helm-controller_test.yaml.snap +++ b/charts/flux2/tests/__snapshot__/helm-controller_test.yaml.snap @@ -10,7 +10,7 @@ should match snapshot of default values: app.kubernetes.io/part-of: flux app.kubernetes.io/version: 2.4.0 control-plane: controller - helm.sh/chart: flux2-2.14.0 + helm.sh/chart: flux2-2.14.1 labeltestkey: labeltestvalue labeltestkey2: labeltestvalue2 name: helm-controller diff --git a/charts/flux2/tests/__snapshot__/image-automation-controller_test.yaml.snap b/charts/flux2/tests/__snapshot__/image-automation-controller_test.yaml.snap index 48aef29..8829e24 100644 --- a/charts/flux2/tests/__snapshot__/image-automation-controller_test.yaml.snap +++ b/charts/flux2/tests/__snapshot__/image-automation-controller_test.yaml.snap @@ -10,7 +10,7 @@ should match snapshot of default values: app.kubernetes.io/part-of: flux app.kubernetes.io/version: 2.4.0 control-plane: controller - helm.sh/chart: flux2-2.14.0 + helm.sh/chart: flux2-2.14.1 name: image-automation-controller spec: replicas: 1 diff --git a/charts/flux2/tests/__snapshot__/image-reflector-controller_test.yaml.snap b/charts/flux2/tests/__snapshot__/image-reflector-controller_test.yaml.snap index 0e1a496..76724d4 100644 --- a/charts/flux2/tests/__snapshot__/image-reflector-controller_test.yaml.snap +++ b/charts/flux2/tests/__snapshot__/image-reflector-controller_test.yaml.snap @@ -10,7 +10,7 @@ should match snapshot of default values: app.kubernetes.io/part-of: flux app.kubernetes.io/version: 2.4.0 control-plane: controller - helm.sh/chart: flux2-2.14.0 + helm.sh/chart: flux2-2.14.1 name: image-reflector-controller spec: replicas: 1 diff --git a/charts/flux2/tests/__snapshot__/kustomize-controller-secret_test.yaml.snap b/charts/flux2/tests/__snapshot__/kustomize-controller-secret_test.yaml.snap index de91e0f..752c93b 100644 --- a/charts/flux2/tests/__snapshot__/kustomize-controller-secret_test.yaml.snap +++ b/charts/flux2/tests/__snapshot__/kustomize-controller-secret_test.yaml.snap @@ -10,7 +10,7 @@ should match snapshot of default values: app.kubernetes.io/managed-by: Helm app.kubernetes.io/part-of: flux app.kubernetes.io/version: 2.4.0 - helm.sh/chart: flux2-2.14.0 + helm.sh/chart: flux2-2.14.1 name: test1 namespace: NAMESPACE type: Opaque diff --git a/charts/flux2/tests/__snapshot__/kustomize-controller_test.yaml.snap b/charts/flux2/tests/__snapshot__/kustomize-controller_test.yaml.snap index a2ac386..fdf69fc 100644 --- a/charts/flux2/tests/__snapshot__/kustomize-controller_test.yaml.snap +++ b/charts/flux2/tests/__snapshot__/kustomize-controller_test.yaml.snap @@ -10,7 +10,7 @@ should match snapshot of default values: app.kubernetes.io/part-of: flux app.kubernetes.io/version: 2.4.0 control-plane: controller - helm.sh/chart: flux2-2.14.0 + helm.sh/chart: flux2-2.14.1 name: kustomize-controller spec: replicas: 1 diff --git a/charts/flux2/tests/__snapshot__/notification-controller_test.yaml.snap b/charts/flux2/tests/__snapshot__/notification-controller_test.yaml.snap index 176e287..abe23cf 100644 --- a/charts/flux2/tests/__snapshot__/notification-controller_test.yaml.snap +++ b/charts/flux2/tests/__snapshot__/notification-controller_test.yaml.snap @@ -10,7 +10,7 @@ should match snapshot of default values: app.kubernetes.io/part-of: flux app.kubernetes.io/version: 2.4.0 control-plane: controller - helm.sh/chart: flux2-2.14.0 + helm.sh/chart: flux2-2.14.1 name: notification-controller spec: replicas: 1 diff --git a/charts/flux2/tests/__snapshot__/pre-install-job_test.yaml.snap b/charts/flux2/tests/__snapshot__/pre-install-job_test.yaml.snap index 07aaf07..7064d29 100644 --- a/charts/flux2/tests/__snapshot__/pre-install-job_test.yaml.snap +++ b/charts/flux2/tests/__snapshot__/pre-install-job_test.yaml.snap @@ -12,7 +12,7 @@ should match snapshot of default values: app.kubernetes.io/managed-by: Helm app.kubernetes.io/part-of: flux app.kubernetes.io/version: 2.4.0 - helm.sh/chart: flux2-2.14.0 + helm.sh/chart: flux2-2.14.1 name: RELEASE-NAME-flux-check spec: backoffLimit: 1 @@ -23,7 +23,7 @@ should match snapshot of default values: app.kubernetes.io/managed-by: Helm app.kubernetes.io/part-of: flux app.kubernetes.io/version: 2.4.0 - helm.sh/chart: flux2-2.14.0 + helm.sh/chart: flux2-2.14.1 name: RELEASE-NAME spec: automountServiceAccountToken: true diff --git a/charts/flux2/tests/__snapshot__/source-controller_test.yaml.snap b/charts/flux2/tests/__snapshot__/source-controller_test.yaml.snap index abc1f28..9360163 100644 --- a/charts/flux2/tests/__snapshot__/source-controller_test.yaml.snap +++ b/charts/flux2/tests/__snapshot__/source-controller_test.yaml.snap @@ -10,7 +10,7 @@ should match snapshot of default values: app.kubernetes.io/part-of: flux app.kubernetes.io/version: 2.4.0 control-plane: controller - helm.sh/chart: flux2-2.14.0 + helm.sh/chart: flux2-2.14.1 name: source-controller spec: replicas: 1 diff --git a/hack/generate.sh b/hack/generate.sh index 1456b95..f34b48d 100755 --- a/hack/generate.sh +++ b/hack/generate.sh @@ -49,6 +49,7 @@ EOF attribute="$(get_controller_values_attribute ${FILE})" echo "{{- if and .Values.installCRDs .Values.${attribute}.create }}" > ./charts/flux2/templates/${FILE##*/} kubectl kustomize "${TEMPDIR}" >> ./charts/flux2/templates/${FILE##*/} +$SED -Ei '/^ annotations:/a\ \ \ \ {{- with .Values.crds.annotations }}\n\ \ \ \ {{- . | toYaml | nindent 4 }}\n\ \ \ \ {{- end }}' ./charts/flux2/templates/${FILE##*/} echo "{{- end }}">> ./charts/flux2/templates/${FILE##*/} # git diff --quiet will exit 1 when there are changes.