-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yi Chen <[email protected]>
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,17 @@ endif | |
SHELL = /usr/bin/env bash -o pipefail | ||
.SHELLFLAGS = -ec | ||
|
||
## Location to install binaries | ||
LOCALBIN ?= $(shell pwd)/bin | ||
|
||
## Versions | ||
HELM_VERSION ?= v3.15.3 | ||
HELM_DOCS_VERSION ?= v1.14.2 | ||
|
||
## Binaries | ||
HELM ?= $(LOCALBIN)/helm-$(HELM_VERSION) | ||
HELM_DOCS ?= $(LOCALBIN)/helm-docs-$(HELM_DOCS_VERSION) | ||
|
||
all: build | ||
|
||
##@ General | ||
|
@@ -99,6 +110,12 @@ docker-build: test ## Build docker image with the manager. | |
docker-push: ## Push docker image with the manager. | ||
docker push ${IMG} | ||
|
||
##@ Helm | ||
|
||
.PHONY: helm-docs | ||
helm-docs: helm-docs-plugin ## Generates markdown documentation for helm charts from requirements and values files. | ||
$(HELM_DOCS) --sort-values-order=file | ||
|
||
##@ Deployment | ||
|
||
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config. | ||
|
@@ -114,12 +131,41 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in | |
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. | ||
$(KUSTOMIZE) build manifests/overlays/standalone | kubectl delete -f - | ||
|
||
##@ Dependencies | ||
|
||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
$(LOCALBIN): | ||
mkdir -p $(LOCALBIN) | ||
|
||
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen | ||
controller-gen: ## Download controller-gen locally if necessary. | ||
GOBIN=$(PROJECT_DIR)/bin go install sigs.k8s.io/controller-tools/cmd/[email protected] | ||
|
||
KUSTOMIZE = $(shell pwd)/bin/kustomize | ||
kustomize: ## Download kustomize locally if necessary. | ||
GOBIN=$(PROJECT_DIR)/bin go install sigs.k8s.io/kustomize/kustomize/[email protected] | ||
|
||
.PHONY: helm | ||
helm: $(HELM) ## Download helm locally if necessary. | ||
$(HELM): $(LOCALBIN) | ||
$(call go-install-tool,$(HELM),helm.sh/helm/v3/cmd/helm,$(HELM_VERSION)) | ||
|
||
.PHONY: helm-docs-plugin | ||
helm-docs-plugin: $(HELM_DOCS) ## Download helm-docs plugin locally if necessary. | ||
$(HELM_DOCS): $(LOCALBIN) | ||
$(call go-install-tool,$(HELM_DOCS),github.com/norwoodj/helm-docs/cmd/helm-docs,$(HELM_DOCS_VERSION)) | ||
|
||
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist | ||
# $1 - target path with name of binary (ideally with version) | ||
# $2 - package url which can be installed | ||
# $3 - specific version of package | ||
define go-install-tool | ||
@[ -f $(1) ] || { \ | ||
set -e; \ | ||
package=$(2)@$(3) ;\ | ||
echo "Downloading $${package}" ;\ | ||
GOBIN=$(LOCALBIN) go install $${package} ;\ | ||
mv "$$(echo "$(1)" | sed "s/-$(3)$$//")" $(1) ;\ | ||
} | ||
endef |