@@ -64,34 +64,33 @@ all: manager
64
64
help : # # Display this help
65
65
@awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-22s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
66
66
67
+ # # --------------------------------------
68
+ # # Testing
69
+ # # --------------------------------------
70
+
67
71
.PHONY : test
68
72
test : generate fmt vet lint # # Run tests
69
73
go test ./... -coverprofile cover.out
70
74
75
+ # # --------------------------------------
76
+ # # Binaries
77
+ # # --------------------------------------
78
+
71
79
.PHONY : manager
72
80
manager : generate fmt vet # # Build manager binary
73
81
go build -o bin/manager main.go
74
82
75
- .PHONY : run
76
- run : generate fmt vet # # Run against the configured Kubernetes cluster in ~/.kube/config
77
- go run ./main.go
78
-
79
- .PHONY : install
80
- install : generate # # Install CRDs into a cluster
81
- kubectl apply -f config/crd/bases
82
-
83
- .PHONY : deploy
84
- deploy : generate # # Deploy controller in the configured Kubernetes cluster in ~/.kube/config
85
- kubectl apply -f config/crd/bases
86
- kubectl kustomize config/default | kubectl apply -f -
83
+ # Build controller-gen
84
+ $(CONTROLLER_GEN ) : $(TOOLS_DIR ) /go.mod
85
+ cd $(TOOLS_DIR ) && go build -o $(CONTROLLER_GEN_BIN ) sigs.k8s.io/controller-tools/cmd/controller-gen
87
86
88
- .PHONY : fmt
89
- fmt : # # Run go fmt against code
90
- go fmt ./...
87
+ # Build golangci-lint
88
+ $( GOLANGCI_LINT ) : $( TOOLS_DIR ) /go.mod
89
+ cd $( TOOLS_DIR ) && go build -o $( GOLANGCI_LINT_BIN ) github.com/golangci/golangci-lint/cmd/golangci-lint
91
90
92
- .PHONY : vet
93
- vet : # # Run go vet against code
94
- go vet ./...
91
+ # # --------------------------------------
92
+ # # Linting
93
+ # # --------------------------------------
95
94
96
95
.PHONY : lint
97
96
lint : $(GOLANGCI_LINT ) # # Lint quickly using `golangci-lint --fast=true`
@@ -101,6 +100,10 @@ lint: $(GOLANGCI_LINT) ## Lint quickly using `golangci-lint --fast=true`
101
100
lint-full : $(GOLANGCI_LINT ) # # Lint thoroughly using `golangci-lint --fase=false`
102
101
$(GOLANGCI_LINT ) run -v --fast=false
103
102
103
+ # # --------------------------------------
104
+ # # Generate / Manifests
105
+ # # --------------------------------------
106
+
104
107
.PHONY : generate
105
108
generate : $(CONTROLLER_GEN ) # # Generate code
106
109
$(MAKE ) generate-manifests
@@ -114,13 +117,10 @@ generate-deepcopy: $(CONTROLLER_GEN) ## Generate deepcopy files
114
117
generate-manifests : $(CONTROLLER_GEN ) # # Generate manifests e.g. CRD, RBAC etc
115
118
$(CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=manager-role webhook paths=" ./..." output:crd:dir=$(CRD_ROOT ) output:webhook:dir=$(WEBHOOK_ROOT ) output:rbac:dir=$(RBAC_ROOT )
116
119
117
- # Build controller-gen
118
- $(CONTROLLER_GEN ) : $(TOOLS_DIR ) /go.mod
119
- cd $(TOOLS_DIR ) && go build -o $(CONTROLLER_GEN_BIN ) sigs.k8s.io/controller-tools/cmd/controller-gen
120
-
121
- # Build golangci-lint
122
- $(GOLANGCI_LINT ) : $(TOOLS_DIR ) /go.mod
123
- cd $(TOOLS_DIR ) && go build -o $(GOLANGCI_LINT_BIN ) github.com/golangci/golangci-lint/cmd/golangci-lint
120
+ .PHONY : modules
121
+ modules : # # Runs go mod to ensure modules are up to date.
122
+ go mod tidy
123
+ cd $(TOOLS_DIR ) ; go mod tidy
124
124
125
125
# # --------------------------------------
126
126
# # Docker
@@ -192,17 +192,39 @@ release-manifests: $(RELEASE_DIR) ## Builds the manifests to publish with a rele
192
192
193
193
.PHONY : release-staging
194
194
release-staging : # # Builds and push container images to the staging bucket.
195
- REGISTRY=$(STAGING_REGISTRY ) $(MAKE ) docker-build-all docker-push-all release-tag-latest
195
+ REGISTRY=$(STAGING_REGISTRY ) $(MAKE ) docker-build-all docker-push-all release-alias-tag
196
196
197
+ RELEASE_ALIAS_TAG =$(shell if [ "$(PULL_BASE_REF ) " = "master" ]; then echo "latest"; else echo "$(PULL_BASE_REF ) "; fi)
197
198
198
- .PHONY : release-tag-latest
199
- release-tag-latest : # # Adds the latest tag to the last build tag.
200
- # # TODO(vincepri): Only do this when we're on master.
201
- gcloud container images add-tag $(CONTROLLER_IMG ) :$(TAG ) $(CONTROLLER_IMG ) :latest
199
+ .PHONY : release-alias-tag
200
+ release-alias-tag : # Adds the tag to the last build tag.
201
+ gcloud container images add-tag $(CONTROLLER_IMG ) :$(TAG ) $(CONTROLLER_IMG ) :$(RELEASE_ALIAS_TAG )
202
202
203
203
# # --------------------------------------
204
204
# # Cleanup / Verification
205
205
# # --------------------------------------
206
+
207
+ .PHONY : clean
208
+ clean : # # Remove all generated files
209
+ $(MAKE ) clean-release
210
+
206
211
.PHONY : clean-release
207
212
clean-release : # # Remove the release folder
208
213
rm -rf $(RELEASE_DIR )
214
+
215
+ # # --------------------------------------
216
+ # # Others / Utilities
217
+ # # --------------------------------------
218
+
219
+ .PHONY : run
220
+ run : generate fmt vet # # Run against the configured Kubernetes cluster in ~/.kube/config
221
+ go run ./main.go
222
+
223
+ .PHONY : install
224
+ install : generate # # Install CRDs into a cluster
225
+ kubectl apply -f config/crd/bases
226
+
227
+ .PHONY : deploy
228
+ deploy : generate # # Deploy controller in the configured Kubernetes cluster in ~/.kube/config
229
+ kubectl apply -f config/crd/bases
230
+ kubectl kustomize config/default | kubectl apply -f -
0 commit comments