Skip to content

Commit

Permalink
Upgrade: controller-gen v0.5.0, conversion-gen v0.21.0
Browse files Browse the repository at this point in the history
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 <juliankatz@google.com>
  • Loading branch information
julianKatz committed Apr 28, 2021
1 parent 804ff2e commit eedf931
Show file tree
Hide file tree
Showing 1,407 changed files with 153,818 additions and 43,568 deletions.
35 changes: 20 additions & 15 deletions constraint/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,29 @@ test: generate
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/controller-gen@v0.5.0
GO111MODULE=on go get k8s.io/code-generator/cmd/conversion-gen@v0.20.2

# 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/..."
conversion-gen \
--input-dirs "./pkg/apis/templates/..." \
--go-header-file=./hack/boilerplate.go.txt \
--output-file-base=zz_generated.conversion
5 changes: 0 additions & 5 deletions constraint/buildutils/README.md

This file was deleted.

15 changes: 0 additions & 15 deletions constraint/buildutils/buildutils.sh

This file was deleted.

48 changes: 0 additions & 48 deletions constraint/buildutils/go.mod

This file was deleted.

Loading

0 comments on commit eedf931

Please sign in to comment.