@@ -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.
22
+ manifests : controller-gen # # Generate CustomResourceDefinition objects
23
23
$(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.
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
28
31
$(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} .
@@ -83,49 +86,29 @@ $(LOCALBIN):
83
86
84
87
# # Tool Binaries
85
88
CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
86
- CLIENT_GEN ?= $(LOCALBIN ) /client-gen
87
- INFORMER_GEN ?= $(LOCALBIN ) /informer-gen
88
- LISTER_GEN ?= $(LOCALBIN ) /lister-gen
89
89
SETUP_ENVTEST ?= $(LOCALBIN ) /setup-envtest
90
90
91
- # # Tool Versions
92
- CONTROLLER_TOOLS_VERSION ?= v0.16.1
93
- CODE_GENERATOR_VERSION ?= v0.29.8
94
- SETUP_ENVTEST_VERSION ?= latest
95
-
96
91
.PHONY : controller-gen
97
- controller-gen : $(CONTROLLER_GEN ) # # Download controller-gen locally if necessary.
92
+ controller-gen : $(CONTROLLER_GEN ) # # Install controller-gen
98
93
$(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 )
94
+ go mod download sigs.k8s.io/controller-tools
95
+ GOBIN=$(LOCALBIN ) go install $$(go list -m -f '{{.Dir}}' sigs.k8s.io/controller-tools ) /cmd/controller-gen
115
96
116
97
.PHONY : setup-envtest
117
- setup-envtest : $(SETUP_ENVTEST ) # # Download setup-envtest locally if necessary.
98
+ setup-envtest : $(SETUP_ENVTEST ) # # Install setup-envtest
118
99
$(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
+ go mod download sigs.k8s.io/controller-runtime
101
+ GOBIN=$(LOCALBIN ) go install $$(go list -m -f '{{.Dir}}' sigs.k8s.io/controller-runtime/tools/setup-envtest )
120
102
121
103
.PHONY : envtest
122
- envtest : setup-envtest
104
+ envtest : setup-envtest # # Install envtest binaries
123
105
ENVTESTDIR=$$($(SETUP_ENVTEST ) use $(ENVTEST_K8S_VERSION ) --bin-dir $(LOCALBIN ) -p path) ; \
124
106
chmod -R u+w $$ ENVTESTDIR ; \
125
107
rm -f $(LOCALBIN ) /k8s/current ; \
126
108
ln -s $$ ENVTESTDIR $(LOCALBIN ) /k8s/current
127
109
128
110
# #@ Manage Content
111
+
129
112
.PHONY : update-content
130
113
update-content : # # Update external resources used by this repository.
131
114
rm -rf pkg/operator/data/charts
0 commit comments