🐛 Patch generated yaml for restore CRD as a hacky workaround (#2814)

* 🐛 Patch generated yaml for restore CRD as a hacky workaround

Signed-off-by: Ashish Amarnath <ashisham@vmware.com>

* changelog

Signed-off-by: Ashish Amarnath <ashisham@vmware.com>
This commit is contained in:
Ashish Amarnath
2020-08-12 18:43:29 -04:00
committed by GitHub
parent 827d5d34f5
commit d4bbd7b817
6 changed files with 20 additions and 3 deletions
@@ -0,0 +1 @@
🐛 Manually patch the generated yaml for restore CRD as a hacky workaround
+1 -2
View File
@@ -1,5 +1,3 @@
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
@@ -857,6 +855,7 @@ spec:
type: string
required:
- containerPort
- protocol
type: object
type: array
x-kubernetes-list-map-keys:
File diff suppressed because one or more lines are too long
+5
View File
@@ -57,3 +57,8 @@ RUN wget --quiet https://github.com/goreleaser/goreleaser/releases/download/v0.1
# get golangci-lint
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0
# install kubectl
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin
+3
View File
@@ -0,0 +1,3 @@
[
{ "op": "replace", "path": "/spec/validation/openAPIV3Schema/properties/spec/properties/hooks/properties/resources/items/properties/postHooks/items/properties/init/properties/initContainers/items/properties/ports/items/required", "value": [ "containerPort", "protocol"] }
]
+9
View File
@@ -52,4 +52,13 @@ controller-gen \
paths=./pkg/controller/... \
output:crd:artifacts:config=config/crd/bases
# this is a super hacky workaround for https://github.com/kubernetes/kubernetes/issues/91395
# which a result of fixing the validation on CRD objects. The validation ensures the fields that are list map keys, are either marked
# as required or have default values to ensure merging of list map items work as expected.
# With "containerPort" and "protocol" being considered as x-kubernetes-list-map-keys in the container ports, and "protocol" was not
# a required field, the CRD would fail validation with errors similar to the one reported in https://github.com/kubernetes/kubernetes/issues/91395.
# once controller-gen (above) is able to generate CRDs with `protocol` as a required field, this hack can be removed.
kubectl patch -f config/crd/bases/velero.io_restores.yaml -p "$(cat hack/restore-crd-patch.json)" --type=json --local=true -o yaml > /tmp/velero.io_restores-yaml.patched
mv /tmp/velero.io_restores-yaml.patched config/crd/bases/velero.io_restores.yaml
go generate ./config/crd/crds