Skip to content

Commit

Permalink
Improve generate-* targets in Makefile
Browse files Browse the repository at this point in the history
Signed-off-by: Vince Prignano <[email protected]>
  • Loading branch information
vincepri committed Jun 24, 2019
1 parent 554edc4 commit c6254c8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
43 changes: 22 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ dep-ensure: ## Runs dep-ensure and rebuilds Bazel gazelle files.
$(MAKE) gazelle

.PHONY: test
test: gazelle verify generate fmt vet manifests ## Run tests
test: generate lint ## Run tests
$(MAKE) test-go

.PHONY: test
test-go: ## Run tests
go test -v -tags=integration ./pkg/... ./cmd/...

.PHONY: manager
Expand All @@ -62,27 +66,13 @@ clusterctl: generate fmt vet ## Build clusterctl binary
go build -o bin/clusterctl sigs.k8s.io/cluster-api/cmd/clusterctl

.PHONY: run
run: generate fmt vet ## Run against the configured Kubernetes cluster in ~/.kube/config
run: generate lint ## Run against the configured Kubernetes cluster in ~/.kube/config
go run ./cmd/manager/main.go

.PHONY: deploy
deploy: manifests ## Deploy controller in the configured Kubernetes cluster in ~/.kube/config
kustomize build config/default | kubectl apply -f -

.PHONY: manifests
manifests: ## Generate manifests e.g. CRD, RBAC etc.
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all
cp -f ./config/rbac/manager*.yaml ./config/ci/rbac/
cp -f ./config/manager/manager*.yaml ./config/ci/manager/

.PHONY: fmt
fmt: ## Run go fmt against code
go fmt ./pkg/... ./cmd/...

.PHONY: vet
vet: ## Run go vet against code
go vet ./pkg/... ./cmd/...

.PHONY: lint
lint: dep-ensure ## Lint codebase
bazel run //:lint $(BAZEL_ARGS)
Expand All @@ -91,12 +81,18 @@ lint-full: dep-ensure ## Run slower linters to detect possible issues
bazel run //:lint-full $(BAZEL_ARGS)

.PHONY: generate
generate: clientset dep-ensure ## Generate code
go generate ./pkg/... ./cmd/...
generate: dep-ensure ## Generate code
$(MAKE) generate-clientset
$(MAKE) generate-manifests
$(MAKE) generate-go
$(MAKE) gazelle

.PHONY: clientset
clientset: ## Generate a typed clientset
.PHONY: generate-go
generate-go: ## Runs go generate
go generate ./pkg/... ./cmd/...

.PHONY: generate-clientset
generate-clientset: ## Generate a typed clientset
rm -rf pkg/client
cd ./vendor/k8s.io/code-generator/cmd && go install ./client-gen ./lister-gen ./informer-gen
$$GOPATH/bin/client-gen --clientset-name clientset --input-base sigs.k8s.io/cluster-api/pkg/apis \
Expand All @@ -110,7 +106,12 @@ clientset: ## Generate a typed clientset
--listers-package sigs.k8s.io/cluster-api/pkg/client/listers_generated \
--output-package sigs.k8s.io/cluster-api/pkg/client/informers_generated \
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt
$(MAKE) gazelle

.PHONY: generate-manifests
generate-manifests: ## Generate manifests e.g. CRD, RBAC etc.
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go all
cp -f ./config/rbac/manager*.yaml ./config/ci/rbac/
cp -f ./config/manager/manager*.yaml ./config/ci/manager/

.PHONY: clean
clean: ## Remove all generated files
Expand Down
2 changes: 1 addition & 1 deletion hack/verify_clientset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cleanup
mkdir -p "${TMP_DIFFROOT}"
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"

make clientset
make generate

echo "diffing ${DIFFROOT} against freshly generated codegen"
ret=0
Expand Down

0 comments on commit c6254c8

Please sign in to comment.