@@ -13,62 +13,65 @@ all: build
13
13
# #@ General
14
14
15
15
.PHONY : help
16
- help : # # Display this help.
17
- @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s \033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
16
+ help : # # Display this help
17
+ @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s \033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
18
18
19
19
# #@ Development
20
20
21
21
.PHONY : manifests
22
- manifests : controller-gen # # Generate CustomResourceDefinition objects.
23
- $(CONTROLLER_GEN ) crd paths=" ./api/..." output:crd:artifacts:config=crds ; \
22
+ manifests : controller-gen # # Generate CustomResourceDefinition objects
23
+ $(LOCALBIN ) /controller-gen crd paths=" ./api/..." output:crd:artifacts:config=crds && \
24
24
test ! -d chart || test -e chart/crds || ln -s ../crds chart/crds
25
25
26
26
.PHONY : generate
27
- generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
28
- $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./api/..."
27
+ generate : generate-deepcopy # # Generate required code pieces
28
+
29
+ .PHONY : generate-deepcopy
30
+ generate-deepcopy : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations
31
+ $(LOCALBIN ) /controller-gen object:headerFile=" hack/boilerplate.go.txt" paths=" ./api/..."
29
32
30
33
.PHONY : generate-client
31
- generate-client : client-gen informer-gen lister-gen # # Generate typed client.
34
+ generate-client : # # Generate typed client
32
35
./hack/genclient.sh
33
36
34
37
.PHONY : fmt
35
- fmt : # # Run go fmt against code.
38
+ fmt : # # Run go fmt against code
36
39
go fmt ./...
37
40
38
41
.PHONY : vet
39
- vet : # # Run go vet against code.
42
+ vet : # # Run go vet against code
40
43
go vet ./...
41
44
42
45
# #@ Testing
43
46
44
47
.PHONY : test
45
- test : manifests generate fmt vet envtest # # Run tests.
48
+ test : manifests generate-deepcopy fmt vet envtest # # Run tests
46
49
KUBEBUILDER_ASSETS=" $( LOCALBIN) /k8s/current" go test ./... -coverprofile cover.out
47
50
48
51
# #@ Build
49
52
50
53
.PHONY : build
51
- build : generate fmt vet # # Build manager binary.
54
+ build : generate-deepcopy fmt vet # # Build manager binary
52
55
go build -o bin/manager main.go
53
56
54
57
.PHONY : run
55
- run : manifests generate fmt vet # # Run a controller from your host.
58
+ run : manifests generate-deepcopy fmt vet # # Run a controller from your host
56
59
go run ./main.go
57
60
58
- # Build docker image in current architecture and tag it as ${IMG}.
61
+ # Build docker image in current architecture and tag it as ${IMG}
59
62
.PHONY : docker-build
60
- docker-build : # # Build docker image with the manager.
63
+ docker-build : # # Build docker image with the manager
61
64
docker build -t ${IMG} .
62
65
63
- # Push docker image to the target specified in ${IMG}.
66
+ # Push docker image to the target specified in ${IMG}
64
67
.PHONY : docker-push
65
- docker-push : # # Push docker image with the manager.
68
+ docker-push : # # Push docker image with the manager
66
69
docker push ${IMG}
67
70
68
- # Build and push docker image for all given platforms.
71
+ # Build and push docker image for all given platforms
69
72
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
70
73
.PHONY : docker-buildx
71
- docker-buildx : # # Build and push docker image for the manager for cross-platform support.
74
+ docker-buildx : # # Build and push docker image for the manager for cross-platform support
72
75
- docker buildx create --name project-v3-builder
73
76
docker buildx use project-v3-builder
74
77
- docker buildx build --push --platform=$(PLATFORMS ) --tag ${IMG} .
@@ -79,53 +82,41 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
79
82
# # Location to install dependencies to
80
83
LOCALBIN ?= $(shell pwd) /bin
81
84
$(LOCALBIN ) :
82
- mkdir -p $(LOCALBIN )
83
-
84
- # # Tool Binaries
85
- CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
86
- CLIENT_GEN ?= $(LOCALBIN ) /client-gen
87
- INFORMER_GEN ?= $(LOCALBIN ) /informer-gen
88
- LISTER_GEN ?= $(LOCALBIN ) /lister-gen
89
- SETUP_ENVTEST ?= $(LOCALBIN ) /setup-envtest
90
-
91
- # # Tool Versions
92
- CONTROLLER_TOOLS_VERSION ?= v0.16.1
93
- CODE_GENERATOR_VERSION ?= v0.29.8
94
- SETUP_ENVTEST_VERSION ?= latest
85
+ @mkdir -p $(LOCALBIN )
95
86
96
87
.PHONY : controller-gen
97
- controller-gen : $(CONTROLLER_GEN ) # # Download controller-gen locally if necessary.
98
- $(CONTROLLER_GEN ) : $(LOCALBIN )
99
- test -s $(LOCALBIN ) /controller-gen || GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION )
100
-
101
- .PHONY : client-gen
102
- client-gen : $(CLIENT_GEN ) # # Download client-gen locally if necessary.
103
- $(CLIENT_GEN ) : $(LOCALBIN )
104
- test -s $(LOCALBIN ) /client-gen || GOBIN=$(LOCALBIN ) go install k8s.io/code-generator/cmd/client-gen@$(CODE_GENERATOR_VERSION )
105
-
106
- .PHONY : informer-gen
107
- informer-gen : $(INFORMER_GEN ) # # Download informer-gen locally if necessary.
108
- $(INFORMER_GEN ) : $(LOCALBIN )
109
- test -s $(LOCALBIN ) /informer-gen || GOBIN=$(LOCALBIN ) go install k8s.io/code-generator/cmd/informer-gen@$(CODE_GENERATOR_VERSION )
110
-
111
- .PHONY : lister-gen
112
- lister-gen : $(LISTER_GEN ) # # Download lister-gen locally if necessary.
113
- $(LISTER_GEN ) : $(LOCALBIN )
114
- test -s $(LOCALBIN ) /lister-gen || GOBIN=$(LOCALBIN ) go install k8s.io/code-generator/cmd/lister-gen@$(CODE_GENERATOR_VERSION )
88
+ controller-gen : $(LOCALBIN ) # # Install controller-gen
89
+ @go mod download sigs.k8s.io/controller-tools && \
90
+ VERSION=$$(go list -m -f '{{.Version}}' sigs.k8s.io/controller-tools ) && \
91
+ if [ ! -L $( LOCALBIN) /controller-gen ] || [ " $$ (readlink $( LOCALBIN) /controller-gen)" != " controller-gen-$$ VERSION" ]; then \
92
+ echo " Installing controller-gen $$ VERSION" && \
93
+ rm -f $(LOCALBIN ) /controller-gen && \
94
+ GOBIN=$(LOCALBIN ) go install $$(go list -m -f '{{.Dir}}' sigs.k8s.io/controller-tools ) /cmd/controller-gen && \
95
+ mv $(LOCALBIN ) /controller-gen $(LOCALBIN ) /controller-gen-$$ VERSION && \
96
+ ln -s controller-gen-$$ VERSION $(LOCALBIN ) /controller-gen; \
97
+ fi
115
98
116
99
.PHONY : setup-envtest
117
- setup-envtest : $(SETUP_ENVTEST ) # # Download setup-envtest locally if necessary.
118
- $(SETUP_ENVTEST ) : $(LOCALBIN )
119
- test -s $(LOCALBIN ) /setup-envtest || GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$(SETUP_ENVTEST_VERSION )
100
+ setup-envtest : $(LOCALBIN ) # # Install setup-envtest
101
+ @go mod download sigs.k8s.io/controller-runtime/tools/setup-envtest && \
102
+ VERSION=$$(go list -m -f '{{.Version}}' sigs.k8s.io/controller-runtime/tools/setup-envtest ) && \
103
+ if [ ! -L $( LOCALBIN) /setup-envtest ] || [ " $$ (readlink $( LOCALBIN) /setup-envtest)" != " setup-envtest-$$ VERSION" ]; then \
104
+ echo " Installing setup-envtest $$ VERSION" && \
105
+ rm -f $(LOCALBIN ) /setup-envtest && \
106
+ GOBIN=$(LOCALBIN ) go install $$(go list -m -f '{{.Dir}}' sigs.k8s.io/controller-runtime/tools/setup-envtest ) && \
107
+ mv $(LOCALBIN ) /setup-envtest $(LOCALBIN ) /setup-envtest-$$ VERSION && \
108
+ ln -s setup-envtest-$$ VERSION $(LOCALBIN ) /setup-envtest; \
109
+ fi
120
110
121
111
.PHONY : envtest
122
- envtest : setup-envtest
123
- ENVTESTDIR=$$($(SETUP_ENVTEST ) use $(ENVTEST_K8S_VERSION ) --bin-dir $(LOCALBIN ) -p path) ; \
124
- chmod -R u+w $$ ENVTESTDIR ; \
125
- rm -f $(LOCALBIN ) /k8s/current ; \
112
+ envtest : setup-envtest # # Install envtest binaries
113
+ @ ENVTESTDIR=$$($(LOCALBIN ) /setup-envtest use $(ENVTEST_K8S_VERSION ) --bin-dir $(LOCALBIN ) -p path) && \
114
+ chmod -R u+w $$ ENVTESTDIR && \
115
+ rm -f $(LOCALBIN ) /k8s/current && \
126
116
ln -s $$ ENVTESTDIR $(LOCALBIN ) /k8s/current
127
117
128
118
# #@ Manage Content
119
+
129
120
.PHONY : update-content
130
121
update-content : # # Update external resources used by this repository.
131
122
rm -rf pkg/operator/data/charts
0 commit comments