Skip to content

Commit

Permalink
fix(charts/flux2,crds): crds.annotations got respected now
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
roth-wine committed Oct 18, 2024
1 parent 08dcb08 commit fc77eb3
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 11 deletions.
2 changes: 1 addition & 1 deletion charts/flux2/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ name: flux2
sources:
- https://github.com/fluxcd-community/helm-charts
type: application
version: 2.14.0
version: 2.14.1
2 changes: 1 addition & 1 deletion charts/flux2/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions charts/flux2/templates/helm-controller.crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions charts/flux2/templates/image-automation-controller.crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions charts/flux2/templates/image-reflector-controller.crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions charts/flux2/templates/kustomize-controller.crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions charts/flux2/templates/notification-controller.crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions charts/flux2/templates/source-controller.crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions hack/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit fc77eb3

Please sign in to comment.