-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade: controller-gen v0.5.0, conversion-gen v0.21.0
frameworks/constraint had previously been reliant on an outdated version of the controller-gen library for generating CRDs with embedded JSONSchemas. The older version of the library wasn't built to detect a nested JSONSchema, and thus would not refuse it. With the requirement of v1 CRDs around the corner in k8s 1.22, framework/constraint requires the newer controller-gen v0.5.0. This library version can output v1 CRD. The conversion logic was also in need of a library upgrade, with conversion-gen v0.21.0 now generating the necessary files. This PR _does not_ output a v1 CRD for Constraint Template. That will be left for a future PR. This PR brings the two binaries up-to-date. Note: I attempted to dockerize these two binaries. Controller-gen worked fine, but for some reason conversion-gen couldn't write to the filesystem. The output looked fine, but no dice. Rather than figure out why, I decided to punt on the dockeriziation effort. Signed-off-by: juliankatz <[email protected]>
- Loading branch information
1 parent
804ff2e
commit a4911cf
Showing
1,592 changed files
with
198,193 additions
and
80,377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,8 @@ endif | |
all: lint test | ||
|
||
# Run tests | ||
native-test: generate manifests | ||
# TODO: Once https://github.com/kubernetes/kubernetes/issues/101567 is fixed, add `generate` back as a dependency target | ||
native-test: gen-dependencies manifests | ||
go test ./pkg/... -coverprofile cover.out | ||
|
||
# Docker internal test | ||
|
@@ -21,31 +22,42 @@ docker-internal-test: | |
# ./tests/test_remote_driver.sh | ||
|
||
# Hook to run docker tests | ||
test: generate | ||
test: | ||
docker build . -t constraint-test && docker run -t constraint-test | ||
|
||
# Install CRDs into a cluster | ||
install: manifests | ||
kubectl apply -f config/crds | ||
|
||
# Install the generation dependencies on the location machine | ||
gen-dependencies: | ||
GO111MODULE=on go get sigs.k8s.io/controller-tools/cmd/[email protected] | ||
GO111MODULE=on go get k8s.io/code-generator/cmd/[email protected] | ||
|
||
# Generate manifests e.g. CRD, RBAC etc. | ||
manifests: buildutils | ||
controller-gen all | ||
kustomize build config -o deploy/crds.yaml | ||
manifests: | ||
controller-gen \ | ||
crd:crdVersions="v1beta1",allowDangerousTypes="true" \ | ||
paths="./pkg/..." \ | ||
output:crd:artifacts:config=config/crds | ||
cp config/crds/* deploy/crds.yaml | ||
|
||
lint: | ||
golangci-lint -v run ./... --timeout 5m | ||
|
||
# Generate code | ||
generate: buildutils | ||
ifndef GOPATH | ||
$(error GOPATH not defined, please define GOPATH. Run "go help gopath" to learn more about GOPATH) | ||
endif | ||
export GOROOT=$(go env root) | ||
GO111MODULE=off go generate ./pkg/... | ||
|
||
# find or download controller-gen | ||
# download controller-gen if necessary | ||
.PHONY: buildutils | ||
buildutils: | ||
cd buildutils && ./buildutils.sh | ||
# Not working? Try running `make gen-dependencies` | ||
generate: | ||
controller-gen \ | ||
object:headerFile=./hack/boilerplate.go.txt \ | ||
paths="./pkg/..." | ||
# This conversion-gen code is broken. For some reason, it does not include functions | ||
# for converting from v1beta JSONSchemaProps to apiextensions JSONSchemaProps, even though | ||
# those functions exist and can be added manually to the conversion file. | ||
# TODO: Once https://github.com/kubernetes/kubernetes/issues/101567 is fixed, update | ||
# conversion-gen and get us back to running `make generate` in our CI pipeline | ||
conversion-gen \ | ||
--input-dirs "./pkg/apis/templates/..." \ | ||
--go-header-file=./hack/boilerplate.go.txt \ | ||
--output-file-base=zz_generated.conversion \ | ||
--extra-dirs=k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.