Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit 372c535

Browse files
committed
🏃 Align Makefile with other CAP* repos
Signed-off-by: Vince Prignano <[email protected]>
1 parent 7b907ab commit 372c535

File tree

4 files changed

+109
-42
lines changed

4 files changed

+109
-42
lines changed

Makefile

Lines changed: 52 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -64,34 +64,33 @@ all: manager
6464
help: ## Display this help
6565
@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)
6666

67+
## --------------------------------------
68+
## Testing
69+
## --------------------------------------
70+
6771
.PHONY: test
6872
test: generate fmt vet lint ## Run tests
6973
go test ./... -coverprofile cover.out
7074

75+
## --------------------------------------
76+
## Binaries
77+
## --------------------------------------
78+
7179
.PHONY: manager
7280
manager: generate fmt vet ## Build manager binary
7381
go build -o bin/manager main.go
7482

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
8786

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
9190

92-
.PHONY: vet
93-
vet: ## Run go vet against code
94-
go vet ./...
91+
## --------------------------------------
92+
## Linting
93+
## --------------------------------------
9594

9695
.PHONY: lint
9796
lint: $(GOLANGCI_LINT) ## Lint quickly using `golangci-lint --fast=true`
@@ -101,6 +100,10 @@ lint: $(GOLANGCI_LINT) ## Lint quickly using `golangci-lint --fast=true`
101100
lint-full: $(GOLANGCI_LINT) ## Lint thoroughly using `golangci-lint --fase=false`
102101
$(GOLANGCI_LINT) run -v --fast=false
103102

103+
## --------------------------------------
104+
## Generate / Manifests
105+
## --------------------------------------
106+
104107
.PHONY: generate
105108
generate: $(CONTROLLER_GEN) ## Generate code
106109
$(MAKE) generate-manifests
@@ -114,13 +117,10 @@ generate-deepcopy: $(CONTROLLER_GEN) ## Generate deepcopy files
114117
generate-manifests: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc
115118
$(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)
116119

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
124124

125125
## --------------------------------------
126126
## Docker
@@ -192,17 +192,39 @@ release-manifests: $(RELEASE_DIR) ## Builds the manifests to publish with a rele
192192

193193
.PHONY: release-staging
194194
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
196196

197+
RELEASE_ALIAS_TAG=$(shell if [ "$(PULL_BASE_REF)" = "master" ]; then echo "latest"; else echo "$(PULL_BASE_REF)"; fi)
197198

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)
202202

203203
## --------------------------------------
204204
## Cleanup / Verification
205205
## --------------------------------------
206+
207+
.PHONY: clean
208+
clean: ## Remove all generated files
209+
$(MAKE) clean-release
210+
206211
.PHONY: clean-release
207212
clean-release: ## Remove the release folder
208213
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 -

cloudbuild.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ steps:
88
env:
99
- DOCKER_CLI_EXPERIMENTAL=enabled
1010
- TAG=$_GIT_TAG
11-
- ADDITIONAL_TAG=$_PULL_BASE_REF
11+
- PULL_BASE_REF=$_PULL_BASE_REF
1212
args:
1313
- release-staging
1414
substitutions:

go.mod

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ go 1.12
44

55
require (
66
github.com/go-logr/logr v0.1.0
7+
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
78
github.com/google/gofuzz v1.0.0 // indirect
8-
github.com/onsi/ginkgo v1.8.0
9-
github.com/onsi/gomega v1.5.0
9+
github.com/onsi/ginkgo v1.10.1
10+
github.com/onsi/gomega v1.7.0
1011
github.com/pkg/errors v0.8.1
11-
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 // indirect
12-
golang.org/x/net v0.0.0-20190620200207-3b0461eec859
13-
golang.org/x/sys v0.0.0-20190621203818-d432491b9138 // indirect
12+
github.com/prometheus/client_golang v0.9.3 // indirect
13+
github.com/spf13/pflag v1.0.5 // indirect
14+
github.com/stretchr/testify v1.4.0 // indirect
15+
go.uber.org/atomic v1.4.0 // indirect
16+
go.uber.org/zap v1.10.0 // indirect
17+
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 // indirect
18+
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b
19+
golang.org/x/sys v0.0.0-20190911201528-7ad0cfa0b7b5 // indirect
20+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
1421
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b
1522
k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d
1623
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible

0 commit comments

Comments
 (0)