Skip to content

Commit

Permalink
Merge pull request open-policy-agent#111 from julianKatz/upgrade-cont…
Browse files Browse the repository at this point in the history
…roller-gen

Upgrade: controller-gen v0.5.0, conversion-gen v0.20.2
  • Loading branch information
julianKatz authored May 3, 2021
2 parents 804ff2e + 0e7217e commit 3f51770
Show file tree
Hide file tree
Showing 1,592 changed files with 198,197 additions and 80,377 deletions.
46 changes: 29 additions & 17 deletions constraint/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 local 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/..."
# 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
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 3f51770

Please sign in to comment.