Skip to content

Commit

Permalink
🏃 bumped up CR to 0.3.0 and CT to 0.2.2 version
Browse files Browse the repository at this point in the history
This PR also changes the way controller-gen is installed using Makefile.

KBProject uses controller-runtime@v0.3.0 that uses k8s 1.15 packages.
When you run 'make all' to build the project and if you don't have
controller-gen installed on your system, Makefile's controller-gen
target will install controller-gen@v0.2.2 using 'go get'. 'go get'
will update the Go.mod file to use k8s 1.16 ApiMachinery pkg
because controller-tool's v0.2.2 is using k8s 1.16 pkgs.

There are two ways to fix this problem:
 1. Ship controller-gen binaries for each OS and Makefile target
    should use the appropriate binary.
 2. Run 'go get' in a temporary directory so that it doesn't KB Project's Go.mod

This PR implements the second approach.

Error Reported:
pkg/mod/sigs.k8s.io/controller-runtime@v0.3.0/pkg/client/apiutil/apimachinery.go:77:30: undefined: serializer.DirectCodecFactory
  • Loading branch information
droot committed Oct 24, 2019
1 parent c9f4434 commit da02981
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 88 deletions.
2 changes: 1 addition & 1 deletion docs/book/install-and-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ chmod +x /tmp/mdbook
echo "grabbing the latest released controller-gen"
# TODO(directxman12): remove the @v0.2.0-beta.4 once get v0.2.0 released,
# so that we actually get the latest version
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.0-beta.5
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.2

# make sure we add the go bin directory to our path
gobin=$(go env GOBIN)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 6 additions & 15 deletions docs/book/src/cronjob-tutorial/testdata/project/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,10 @@ go 1.12

require (
github.com/go-logr/logr v0.1.0
github.com/gogo/protobuf v1.2.1 // indirect
github.com/json-iterator/go v1.1.6 // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/onsi/ginkgo v1.8.0 // indirect
github.com/onsi/gomega v1.5.0 // indirect
github.com/robfig/cron v1.1.0
github.com/spf13/pflag v1.0.3 // indirect
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09 // indirect
golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872 // indirect
golang.org/x/text v0.3.2 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b
k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
sigs.k8s.io/controller-runtime v0.2.0-rc.0
github.com/robfig/cron v1.2.0
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect
k8s.io/api v0.0.0-20190918195907-bd6ac527cfd2
k8s.io/apimachinery v0.0.0-20190817020851-f2f3a405f61d
k8s.io/client-go v0.0.0-20190918200256-06eb1244587a
sigs.k8s.io/controller-runtime v0.3.0
)
262 changes: 202 additions & 60 deletions docs/book/src/cronjob-tutorial/testdata/project/go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/scaffold/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ import (

const (
// controller runtime version to be used in the project
controllerRuntimeVersion = "v0.2.2"
controllerRuntimeVersion = "v0.3.0"
// ControllerTools version to be used in the project
controllerToolsVersion = "v0.2.1"
controllerToolsVersion = "v0.2.2"
)

type ProjectScaffolder interface {
Expand Down
9 changes: 8 additions & 1 deletion pkg/scaffold/v2/makefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,14 @@ docker-push:
# download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
go get sigs.k8s.io/controller-tools/cmd/controller-gen@{{.ControllerToolsVersion}}
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@{{.ControllerToolsVersion}} ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
Expand Down
9 changes: 8 additions & 1 deletion testdata/project-v2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ docker-push:
# download controller-gen if necessary
controller-gen:
ifeq (, $(shell which controller-gen))
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.1
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.2 ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
Expand Down
6 changes: 3 additions & 3 deletions testdata/project-v2/api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions testdata/project-v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ require (
github.com/go-logr/logr v0.1.0
github.com/onsi/ginkgo v1.6.0
github.com/onsi/gomega v1.4.2
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b
k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
sigs.k8s.io/controller-runtime v0.2.2
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect
k8s.io/api v0.0.0-20190918195907-bd6ac527cfd2
k8s.io/apimachinery v0.0.0-20190817020851-f2f3a405f61d
k8s.io/client-go v0.0.0-20190918200256-06eb1244587a
sigs.k8s.io/controller-runtime v0.3.0
)

0 comments on commit da02981

Please sign in to comment.