Add dummy openAPIV3Schema to initContainer and log patch

pull/1278/head
Arvind Iyengar 2021-06-16 18:04:16 -07:00
parent d9130be8f0
commit 3202417f2d
No known key found for this signature in database
GPG Key ID: A8DD9BFD6C811498
3 changed files with 8 additions and 6 deletions

View File

@ -30,10 +30,11 @@ spec:
{{- range $path, $_ := (.Files.Glob "crd-manifest/**.yaml") }} {{- range $path, $_ := (.Files.Glob "crd-manifest/**.yaml") }}
{{- $crd := get (get ($.Files.Get $path | fromYaml) "metadata") "name" }} {{- $crd := get (get ($.Files.Get $path | fromYaml) "metadata") "name" }}
if [[ -n "$(kubectl get crd {{ $crd }} -o jsonpath='{.spec.preserveUnknownFields}')" ]]; then if [[ -n "$(kubectl get crd {{ $crd }} -o jsonpath='{.spec.preserveUnknownFields}')" ]]; then
patch="{\"spec\": {\"preserveUnknownFields\": false}}"; patch='{"spec": {"preserveUnknownFields": false}}';
if [[ -z "$(kubectl get crd {{ $crd }} -o jsonpath='{.spec.versions[0].schema}' 2>&1)" ]]; then if [[ -z "$(kubectl get crd {{ $crd }} -o jsonpath='{.spec.versions[0].schema}')" ]]; then
patch="{\"spec\": {\"preserveUnknownFields\": false, \"versions\": [{\"name\": \"v1\", \"served\": false, \"storage\": true}]}}"; patch='{"spec": {"preserveUnknownFields": false, "versions": [{"name": "v1", "served": false, "storage": true, "schema": {"openAPIV3Schema": {"description": "placeholder", "type": "object"}}}]}}';
fi fi
echo "Applying patch to {{ $crd }}: ${patch}"
if kubectl patch crd {{ $crd }} -p "${patch}" --type="merge"; then if kubectl patch crd {{ $crd }} -p "${patch}" --type="merge"; then
{{- include "crd.established" $crd | nindent 18 }} {{- include "crd.established" $crd | nindent 18 }}
fi; fi;

View File

@ -30,10 +30,11 @@ spec:
{{- range $path, $_ := (.Files.Glob "crd-manifest/**.yaml") }} {{- range $path, $_ := (.Files.Glob "crd-manifest/**.yaml") }}
{{- $crd := get (get ($.Files.Get $path | fromYaml) "metadata") "name" }} {{- $crd := get (get ($.Files.Get $path | fromYaml) "metadata") "name" }}
if [[ -n "$(kubectl get crd {{ $crd }} -o jsonpath='{.spec.preserveUnknownFields}')" ]]; then if [[ -n "$(kubectl get crd {{ $crd }} -o jsonpath='{.spec.preserveUnknownFields}')" ]]; then
patch="{\"spec\": {\"preserveUnknownFields\": false}}"; patch='{"spec": {"preserveUnknownFields": false}}';
if [[ -z "$(kubectl get crd {{ $crd }} -o jsonpath='{.spec.versions[0].schema}' 2>&1)" ]]; then if [[ -z "$(kubectl get crd {{ $crd }} -o jsonpath='{.spec.versions[0].schema}')" ]]; then
patch="{\"spec\": {\"preserveUnknownFields\": false, \"versions\": [{\"name\": \"v1\", \"served\": false, \"storage\": true}]}}"; patch='{"spec": {"preserveUnknownFields": false, "versions": [{"name": "v1", "served": false, "storage": true, "schema": {"openAPIV3Schema": {"description": "placeholder", "type": "object"}}}]}}';
fi fi
echo "Applying patch to {{ $crd }}: ${patch}"
if kubectl patch crd {{ $crd }} -p "${patch}" --type="merge"; then if kubectl patch crd {{ $crd }} -p "${patch}" --type="merge"; then
{{- include "crd.established" $crd | nindent 18 }} {{- include "crd.established" $crd | nindent 18 }}
fi; fi;