Skip to content

Commit

Permalink
update makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
floreks committed Feb 28, 2025
1 parent c8dbff6 commit 86bfb8a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
9 changes: 6 additions & 3 deletions go/ai-proxy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ docker:
check: vet lint test ## run all code checks/tests

.PHONY: goimports
goimports: install-goimports ## format code imports
goimports: TOOL = goimports
goimports: --tool ## format code imports
@$(GOIMPORTS) -w ./

.PHONY: fmt
Expand All @@ -69,11 +70,13 @@ vet: ## run go vet
@go vet ./...

.PHONY: lint
lint: install-golangci-lint ## run linters
lint: TOOL = golangci-lint
lint: --tool ## run linters
@$(GOLANGCI_LINT) run ./...

.PHONY: fix
fix: install-golangci-lint fmt ## fix issues found by linters
fix: TOOL = golangci-lint
fix: --tool fmt ## fix issues found by linters
@$(GOLANGCI_LINT) run --fix ./...

.PHONY: test
Expand Down
4 changes: 3 additions & 1 deletion go/client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ include $(TOOLS_MAKEFILE)
help: ## show help
@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)

generate: install-gqlgenc ## generate Go client from GraphQL schema
.PHONY: generate:
generate: TOOL = gqlgenc
generate: --tool ## generate Go client from GraphQL schema
@$(GQLGENC)

release: ## create and push a tag with new client version
Expand Down
33 changes: 22 additions & 11 deletions go/controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,18 @@ vet: ## run go vet against code
@go vet ./...

.PHONY: lint
lint: install-golangci-lint ## run linters
lint: TOOL = golangci-lint
lint: --tool ## run linters
@$(GOLANGCI_LINT) run ./...

.PHONY: fix
fix: install-golangci-lint ## fix issues found by linters
fix: TOOL = golangci-lint
fix: --tool ## fix issues found by linters
@$(GOLANGCI_LINT) run --fix ./...

.PHONY: test
test: install-envtest manifests generate genmock fmt vet ## run tests
test: TOOL = envtest controller-gen mockery
test: --tool manifests generate genmock fmt vet ## run tests
@KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(BINARIES_DIR) -p path)" go test $$(go list ./... | grep -v /e2e) -v

.PHONY: e2e
Expand All @@ -83,20 +86,23 @@ e2e: ## run e2e tests
codegen: manifests generate genmock codegen-helm codegen-crd-docs ## runs all codegen-related targets

.PHONY: manifests
manifests: install-controller-gen ## generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects
manifests: ## generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook paths="./..." output:crd:artifacts:config=config/crd/bases
@$(MAKE) -s codegen-chart-crds

.PHONY: generate
generate: install-controller-gen ## generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations
generate: TOOL = controller-gen
generate: --tool ## generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations
$(CONTROLLER_GEN) object:headerFile=$(BOILERPLATE_FILE) paths="./..."

.PHONY: genmock
genmock: TOOL = mockery
genmock: ## generates mocks before running tests
$(MOCKERY)

.PHONY: codegen-helm
codegen-helm: install-kustomize install-helmify manifests ## generate controller helm chart with kustomize
codegen-helm: TOOL = kustomize helmify
codegen-helm: --tool manifests ## generate controller helm chart with kustomize
@rm -rf tmp/
@$(KUSTOMIZE) build config/default | $(HELMIFY) -generate-defaults -image-pull-secrets -crd-dir tmp/charts/controller
@find tmp/charts/controller -type f -exec sed -i 's/app.kubernetes.io\/managed-by: kustomize/app.kubernetes.io\/managed-by: helm/g' {} \;
Expand All @@ -107,29 +113,34 @@ codegen-chart-crds: ## copy CRDs to the controller helm chart
@cp -a $(CONTROLLER_CHART_DIR)/crds/. $(PLURAL_CONSOLE_CHART_DIR)/crds

.PHONY: codegen-crd-docs
codegen-crd-docs: install-crd-ref-docs ## generate docs from the CRDs
codegen-crd-docs: TOOL = crd-ref-docs
codegen-crd-docs: --tool ## generate docs from the CRDs
$(CRDDOCS) --source-path=./api --renderer=markdown --output-path=./docs/api.md --config=config.yaml

##@ Deployment

.PHONY: deploy-crds-kustomize
deploy-crds-kustomize: install-kustomize manifests ## deploy CRDs into the K8s cluster specified in ~/.kube/config.
deploy-crds-kustomize: TOOL = kustomize
deploy-crds-kustomize: --tool manifests ## deploy CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -

ifndef ignore-not-found
ignore-not-found = false
endif

.PHONY: undeploy-crds-kustomize
undeploy-crds-kustomize: install-kustomize manifests ## undeploy CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
undeploy-crds-kustomize: TOOL = kustomize
undeploy-crds-kustomize: --tool manifests ## undeploy CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: deploy-kustomize
deploy-kustomize: install-kustomize manifests deploy-crds-kustomize ## deploy controller to the K8s cluster specified in ~/.kube/config.
deploy-kustomize: TOOL = kustomize
deploy-kustomize: --tool manifests deploy-crds-kustomize ## deploy controller to the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | $(ENVSUBST) | $(KUBECTL) apply -f -

.PHONY: undeploy-kustomize
undeploy-kustomize: install-kustomize manifests ## undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
undeploy-kustomize: TOOL = kustomize
undeploy-kustomize: --tool manifests ## undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: deploy-helm
Expand Down
6 changes: 4 additions & 2 deletions go/oci-auth/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ release: lint test ## builds release version of the app, requires GoReleaser to
##@ Checks

.PHONY: lint
lint: install-golangci-lint ## run linters
lint: TOOL = golangci-lint
lint: --tool ## run linters
@$(GOLANGCI_LINT) run ./...

.PHONY: fix
fix: install-golangci-lint ## run linters and fix found issues
fix: TOOL = golangci-lint
fix: --tool ## run linters and fix found issues
@$(GOLANGCI_LINT) run --fix ./...

.PHONY: test
Expand Down
3 changes: 2 additions & 1 deletion go/tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ tools: --tool install-kubebuilder
dependency=$$(echo $${tool} | cut -d'@' -f1) ;\
version=$$(echo $$tool | cut -d'@' -f2) ;\
for path in $(GO_INSTALL_TOOLS); do \
if echo $${path} | grep -q "$(TOOL)"; then \
match=$$(echo "$(TOOL)" | tr ' ' '|') ;\
if echo $${path} | grep -qE "$${match}"; then \
if echo $${path} | grep -q $${dependency}; then \
echo Installing $${path}@$${version} ;\
GOBIN=$(BINARIES_DIR) go install $${path}@$${version} ;\
Expand Down

0 comments on commit 86bfb8a

Please sign in to comment.