Skip to content

Commit

Permalink
Update CRDs to v1 apiversion (#1424)
Browse files Browse the repository at this point in the history
* Use v1 of CRD API
  - Force preserveUnknownFields to false.
  • Loading branch information
matthchr authored May 10, 2021
1 parent 1c0969c commit a7ecb6b
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ else
GOBIN=$(shell go env GOBIN)
endif

# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:crdVersions=v1beta1"
CRD_OPTIONS ?= "crd:crdVersions=v1"

BUILD_ID ?= $(shell git rev-parse --short HEAD)
timestamp := $(shell /bin/date "+%Y%m%d-%H%M%S")
Expand Down Expand Up @@ -208,8 +207,13 @@ helm-chart-manifests: generate

# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests: controller-gen
manifests: install-dependencies
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
# update manifests to force preserveUnknownFields to false. We can't use controller-gen to set this to false because it has a bug...
# see: https://github.com/kubernetes-sigs/controller-tools/issues/476
# TODO: After this has been in the release for "a while" we can remove it since the default is also false and we just
# TODO: need it for the upgrade scenario between v1beta1 and v1 CRD types
ls config/crd/bases | xargs -I % yq eval -i ".spec.preserveUnknownFields = false" config/crd/bases/%

# Run go fmt against code
.PHONY: fmt
Expand All @@ -226,14 +230,6 @@ vet:
generate: manifests
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./api/...

# find or download controller-gen
# download controller-gen if necessary
.PHONY: controller-gen
controller-gen:
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.0
CONTROLLER_GEN=$(shell go env GOPATH)/bin/controller-gen


.PHONY: install-bindata
install-bindata:
go get -u github.com/jteeuwen/go-bindata/...
Expand Down Expand Up @@ -320,14 +316,20 @@ install-aad-pod-identity:
kubectl apply -f https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/deployment-rbac.yaml

.PHONY: install-test-dependencies
install-test-dependencies: controller-gen
install-test-dependencies: install-dependencies
go get github.com/jstemmer/go-junit-report \
&& go get github.com/axw/gocov/gocov \
&& go get github.com/AlekSi/gocov-xml \
&& go get github.com/wadey/gocovmerge \
&& go get k8s.io/code-generator/cmd/conversion-gen@v0.18.2 \
&& go get sigs.k8s.io/kind@v0.9.0 \
&& go get sigs.k8s.io/kustomize/kustomize/v3@v3.8.6

.PHONY: install-dependencies
install-dependencies:
go get github.com/mikefarah/yq/v4 \
&& go get k8s.io/code-generator/cmd/conversion-gen@v0.18.2 \
&& go get sigs.k8s.io/kustomize/kustomize/v3@v3.8.6 \
&& go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.0
CONTROLLER_GEN=$(shell go env GOPATH)/bin/controller-gen

# Operator-sdk release version
RELEASE_VERSION ?= v1.0.1
Expand Down

0 comments on commit a7ecb6b

Please sign in to comment.