Browse Source

Update makefile

Ileriayo Adebiyi 4 years ago
parent
commit
1c9e2ba949
1 changed files with 17 additions and 25 deletions
  1. 17 25
      Makefile

+ 17 - 25
Makefile

@@ -65,12 +65,10 @@ FAIL	= (echo ${TIME} ${RED}[FAIL]${CNone} && false)
 # ====================================================================================
 # ====================================================================================
 # Conformance
 # Conformance
 
 
-# Ensure a PR is ready for review.
-reviewable: generate helm.generate lint
+reviewable: generate helm.generate lint ## Ensure a PR is ready for review.
 	@go mod tidy
 	@go mod tidy
 
 
-# Ensure branch is clean.
-check-diff: reviewable
+check-diff: reviewable ## Ensure branch is clean.
 	@$(INFO) checking that branch is clean
 	@$(INFO) checking that branch is clean
 	@test -z "$$(git status --porcelain)" || (echo "$$(git status --porcelain)" && $(FAIL))
 	@test -z "$$(git status --porcelain)" || (echo "$$(git status --porcelain)" && $(FAIL))
 	@$(OK) branch is clean
 	@$(OK) branch is clean
@@ -91,7 +89,7 @@ test.e2e: generate ## Run e2e tests
 	@$(OK) go test unit-tests
 	@$(OK) go test unit-tests
 
 
 .PHONY: build
 .PHONY: build
-build: $(addprefix build-,$(ARCH))
+build: $(addprefix build-,$(ARCH)) ## Build binary 
 
 
 .PHONY: build-%
 .PHONY: build-%
 build-%: generate ## Build binary for the specified arch
 build-%: generate ## Build binary for the specified arch
@@ -100,28 +98,26 @@ build-%: generate ## Build binary for the specified arch
 		go build -o '$(OUTPUT_DIR)/external-secrets-linux-$*' main.go
 		go build -o '$(OUTPUT_DIR)/external-secrets-linux-$*' main.go
 	@$(OK) go build $*
 	@$(OK) go build $*
 
 
-# Check install of golanci-lint
-lint.check:
+lint.check: ## Check install of golanci-lint
 	@if ! golangci-lint --version > /dev/null 2>&1; then \
 	@if ! golangci-lint --version > /dev/null 2>&1; then \
 		echo -e "\033[0;33mgolangci-lint is not installed: run \`\033[0;32mmake lint.install\033[0m\033[0;33m\` or install it from https://golangci-lint.run\033[0m"; \
 		echo -e "\033[0;33mgolangci-lint is not installed: run \`\033[0;32mmake lint.install\033[0m\033[0;33m\` or install it from https://golangci-lint.run\033[0m"; \
 		exit 1; \
 		exit 1; \
 	fi
 	fi
 
 
-# installs golangci-lint to the go bin dir
-lint.install:
+lint.install: ## Install golangci-lint to the go bin dir
 	@if ! golangci-lint --version > /dev/null 2>&1; then \
 	@if ! golangci-lint --version > /dev/null 2>&1; then \
 		echo "Installing golangci-lint"; \
 		echo "Installing golangci-lint"; \
 		curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOBIN) v1.33.0; \
 		curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOBIN) v1.33.0; \
 	fi
 	fi
 
 
-lint: lint.check ## run golangci-lint
+lint: lint.check ## Run golangci-lint
 	@if ! golangci-lint run; then \
 	@if ! golangci-lint run; then \
 		echo -e "\033[0;33mgolangci-lint failed: some checks can be fixed with \`\033[0;32mmake fmt\033[0m\033[0;33m\`\033[0m"; \
 		echo -e "\033[0;33mgolangci-lint failed: some checks can be fixed with \`\033[0;32mmake fmt\033[0m\033[0;33m\`\033[0m"; \
 		exit 1; \
 		exit 1; \
 	fi
 	fi
 	@$(OK) Finished linting
 	@$(OK) Finished linting
 
 
-fmt: lint.check ## ensure consistent code style
+fmt: lint.check ## Ensure consistent code style
 	@go mod tidy
 	@go mod tidy
 	@go fmt ./...
 	@go fmt ./...
 	@golangci-lint run --fix > /dev/null 2>&1 || true
 	@golangci-lint run --fix > /dev/null 2>&1 || true
@@ -143,20 +139,17 @@ generate: ## Generate code and crds
 
 
 # This is for running out-of-cluster locally, and is for convenience.
 # This is for running out-of-cluster locally, and is for convenience.
 # For more control, try running the binary directly with different arguments.
 # For more control, try running the binary directly with different arguments.
-run: generate
+run: generate ## Run app locally (without a k8s cluster)
 	go run ./main.go
 	go run ./main.go
 
 
-# Generate manifests from helm chart
-manifests: helm.generate
+manifests: helm.generate ## Generate manifests from helm chart
 	mkdir -p $(OUTPUT_DIR)/deploy/manifests
 	mkdir -p $(OUTPUT_DIR)/deploy/manifests
 	helm template external-secrets $(HELM_DIR) -f deploy/manifests/helm-values.yaml > $(OUTPUT_DIR)/deploy/manifests/external-secrets.yaml
 	helm template external-secrets $(HELM_DIR) -f deploy/manifests/helm-values.yaml > $(OUTPUT_DIR)/deploy/manifests/external-secrets.yaml
 
 
-# Install CRDs into a cluster. This is for convenience.
-crds.install: generate
+crds.install: generate ## Install CRDs into a cluster. This is for convenience
 	kubectl apply -f $(CRD_DIR)
 	kubectl apply -f $(CRD_DIR)
 
 
-# Uninstall CRDs from a cluster. This is for convenience.
-crds.uninstall:
+crds.uninstall: ## Uninstall CRDs from a cluster. This is for convenience
 	kubectl delete -f $(CRD_DIR)
 	kubectl delete -f $(CRD_DIR)
 
 
 # ====================================================================================
 # ====================================================================================
@@ -174,8 +167,7 @@ helm.build: helm.generate ## Build helm chart
 	@mv $(OUTPUT_DIR)/chart/external-secrets-$(HELM_VERSION).tgz $(OUTPUT_DIR)/chart/external-secrets.tgz
 	@mv $(OUTPUT_DIR)/chart/external-secrets-$(HELM_VERSION).tgz $(OUTPUT_DIR)/chart/external-secrets.tgz
 	@$(OK) helm package
 	@$(OK) helm package
 
 
-# Copy crds to helm chart directory
-helm.generate: helm.docs
+helm.generate: helm.docs ## Copy crds to helm chart directory
 	@cp $(CRD_DIR)/*.yaml $(HELM_DIR)/templates/crds/
 	@cp $(CRD_DIR)/*.yaml $(HELM_DIR)/templates/crds/
 # Add helm if statement for controlling the install of CRDs
 # Add helm if statement for controlling the install of CRDs
 	@for i in $(HELM_DIR)/templates/crds/*.yaml; do \
 	@for i in $(HELM_DIR)/templates/crds/*.yaml; do \
@@ -190,11 +182,11 @@ helm.generate: helm.docs
 # ====================================================================================
 # ====================================================================================
 # Documentation
 # Documentation
 .PHONY: docs
 .PHONY: docs
-docs: generate
+docs: generate ## Generate docs
 	$(MAKE) -C ./hack/api-docs build
 	$(MAKE) -C ./hack/api-docs build
 
 
 .PHONY: serve-docs
 .PHONY: serve-docs
-serve-docs:
+serve-docs: ## Serve docs
 	$(MAKE) -C ./hack/api-docs serve
 	$(MAKE) -C ./hack/api-docs serve
 
 
 # ====================================================================================
 # ====================================================================================
@@ -207,7 +199,7 @@ docker.build: $(addprefix build-,$(ARCH)) ## Build the docker image
 	@docker build . $(BUILD_ARGS) -t $(IMAGE_REGISTRY):$(VERSION)
 	@docker build . $(BUILD_ARGS) -t $(IMAGE_REGISTRY):$(VERSION)
 	@$(OK) docker build
 	@$(OK) docker build
 
 
-docker.push:
+docker.push: ## Push the docker image to the registry
 	@$(INFO) docker push
 	@$(INFO) docker push
 	@docker push $(IMAGE_REGISTRY):$(VERSION)
 	@docker push $(IMAGE_REGISTRY):$(VERSION)
 	@$(OK) docker push
 	@$(OK) docker push
@@ -217,7 +209,7 @@ docker.push:
 RELEASE_TAG ?= main
 RELEASE_TAG ?= main
 SOURCE_TAG ?= $(VERSION)
 SOURCE_TAG ?= $(VERSION)
 
 
-docker.promote:
+docker.promote: ## Promote the docker image to the registry
 	@$(INFO) promoting $(SOURCE_TAG) to $(RELEASE_TAG)
 	@$(INFO) promoting $(SOURCE_TAG) to $(RELEASE_TAG)
 	docker manifest inspect $(IMAGE_REGISTRY):$(SOURCE_TAG) > .tagmanifest
 	docker manifest inspect $(IMAGE_REGISTRY):$(SOURCE_TAG) > .tagmanifest
 	for digest in $$(jq -r '.manifests[].digest' < .tagmanifest); do \
 	for digest in $$(jq -r '.manifests[].digest' < .tagmanifest); do \
@@ -232,5 +224,5 @@ docker.promote:
 # Help
 # Help
 
 
 # only comments after make target name are shown as help text
 # only comments after make target name are shown as help text
-help: ## displays this help message
+help: ## Displays this help message
 	@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s : | sort)"
 	@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s : | sort)"