Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-759: Select the appropriate apiVersion #760

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions charts/moco/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Return the appropriate apiVersion for admissionregistration.
*/}}
{{- define "admissionregistration.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "admissionregistration.k8s.io/v1" -}}
admissionregistration.k8s.io/v1
{{- else -}}
admissionregistration.k8s.io/v1beta1
{{- end }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/moco/templates/generated/generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ spec:
app.kubernetes.io/component: moco-controller
app.kubernetes.io/name: '{{ include "moco.name" . }}'
---
apiVersion: admissionregistration.k8s.io/v1beta1
apiVersion: '{{ include "admissionregistration.apiVersion" . }}'
yamatcha marked this conversation as resolved.
Show resolved Hide resolved
kind: ValidatingAdmissionPolicy
metadata:
labels:
Expand Down Expand Up @@ -400,7 +400,7 @@ spec:
!(oldObject.metadata.annotations["moco.cybozu.com/prevent-delete"] == "true")
messageExpression: oldObject.metadata.name + ' is protected from deletion'
---
apiVersion: admissionregistration.k8s.io/v1beta1
apiVersion: '{{ include "admissionregistration.apiVersion" . }}'
yamatcha marked this conversation as resolved.
Show resolved Hide resolved
kind: ValidatingAdmissionPolicyBinding
metadata:
labels:
Expand Down
11 changes: 11 additions & 0 deletions config/kustomize-to-helm/overlays/templates/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ patchesStrategicMerge:

transformers:
- label-transformer.yaml

patches:
- target:
group: admissionregistration.k8s.io
version: v1beta1
kind: 'ValidatingAdmissionPolicy|ValidatingAdmissionPolicyBinding'
name: '.*'
patch: |-
- op: replace
path: "/apiVersion"
value: '{{ include "admissionregistration.apiVersion" . }}'