-
Notifications
You must be signed in to change notification settings - Fork 89
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: Frank Jogeleit <[email protected]>
- Loading branch information
Showing
7 changed files
with
685 additions
and
25 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
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 |
---|---|---|
@@ -1,9 +1,105 @@ | ||
GO ?= go | ||
BUILD ?= build | ||
REPO ?= ghcr.io/kyverno/policy-reporter | ||
IMAGE_TAG ?= 2.17.2 | ||
LD_FLAGS=-s -w -linkmode external -extldflags "-static" | ||
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x | ||
############ | ||
# DEFAULTS # | ||
############ | ||
|
||
USE_CONFIG ?= standard,no-ingress,in-cluster,all-read-rbac | ||
KUBECONFIG ?= "" | ||
PIP ?= "pip3" | ||
GO ?= go | ||
BUILD ?= build | ||
IMAGE_TAG ?= 3.0.0 | ||
|
||
############# | ||
# VARIABLES # | ||
############# | ||
|
||
GIT_SHA := $(shell git rev-parse HEAD) | ||
TIMESTAMP := $(shell date '+%Y-%m-%d_%I:%M:%S%p') | ||
GOOS ?= $(shell go env GOOS) | ||
GOARCH ?= $(shell go env GOARCH) | ||
REGISTRY ?= ghcr.io | ||
REPO ?= kyverno | ||
IMAGE ?= policy-reporter | ||
LD_FLAGS := -s -w -linkmode external -extldflags "-static" | ||
LOCAL_PLATFORM := linux/$(GOARCH) | ||
PLATFORMS := linux/arm64,linux/amd64,linux/s390x | ||
REPO := $(REGISTRY)/$(REPO)/$(IMAGE) | ||
COMMA := , | ||
|
||
ifndef VERSION | ||
APP_VERSION := $(GIT_SHA) | ||
else | ||
APP_VERSION := $(VERSION) | ||
endif | ||
|
||
######### | ||
# TOOLS # | ||
######### | ||
|
||
TOOLS_DIR := $(PWD)/.tools | ||
HELM := $(TOOLS_DIR)/helm | ||
HELM_VERSION := v3.10.1 | ||
HELM_DOCS := $(TOOLS_DIR)/helm-docs | ||
HELM_DOCS_VERSION := v1.11.0 | ||
GCI := $(TOOLS_DIR)/gci | ||
GCI_VERSION := v0.9.1 | ||
GOFUMPT := $(TOOLS_DIR)/gofumpt | ||
GOFUMPT_VERSION := v0.4.0 | ||
TOOLS := $(HELM) $(HELM_DOCS) $(GCI) $(GOFUMPT) | ||
|
||
$(HELM): | ||
@echo Install helm... >&2 | ||
@GOBIN=$(TOOLS_DIR) go install helm.sh/helm/v3/cmd/helm@$(HELM_VERSION) | ||
|
||
$(HELM_DOCS): | ||
@echo Install helm-docs... >&2 | ||
@GOBIN=$(TOOLS_DIR) go install github.com/norwoodj/helm-docs/cmd/helm-docs@$(HELM_DOCS_VERSION) | ||
|
||
$(GCI): | ||
@echo Install gci... >&2 | ||
@GOBIN=$(TOOLS_DIR) go install github.com/daixiang0/gci@$(GCI_VERSION) | ||
|
||
$(GOFUMPT): | ||
@echo Install gofumpt... >&2 | ||
@GOBIN=$(TOOLS_DIR) go install mvdan.cc/gofumpt@$(GOFUMPT_VERSION) | ||
|
||
.PHONY: gci | ||
gci: $(GCI) | ||
@echo "Running gci" | ||
@$(GCI) write -s standard -s default -s "prefix(github.com/kyverno/policy-reporter)" . | ||
|
||
.PHONY: gofumpt | ||
gofumpt: $(GOFUMPT) | ||
@echo "Running gofumpt" | ||
@$(GOFUMPT) -w . | ||
|
||
.PHONY: fmt | ||
fmt: gci gofumpt | ||
|
||
.PHONY: install-tools | ||
install-tools: $(TOOLS) ## Install tools | ||
|
||
.PHONY: clean-tools | ||
clean-tools: ## Remove installed tools | ||
@echo Clean tools... >&2 | ||
@rm -rf $(TOOLS_DIR) | ||
|
||
########### | ||
# CODEGEN # | ||
########### | ||
|
||
.PHONY: codegen-helm-docs | ||
codegen-helm-docs: ## Generate helm docs | ||
@echo Generate helm docs... >&2 | ||
@docker run -v ${PWD}/charts:/work -w /work jnorwood/helm-docs:v1.11.0 -s file | ||
|
||
.PHONY: verify-helm-docs | ||
verify-helm-docs: codegen-helm-docs ## Check Helm charts are up to date | ||
@echo Checking helm charts are up to date... >&2 | ||
@git --no-pager diff -- charts | ||
@echo 'If this test fails, it is because the git diff is non-empty after running "make codegen-helm-docs".' >&2 | ||
@echo 'To correct this, locally run "make codegen-helm-docs", commit the changes, and re-run tests.' >&2 | ||
@git diff --quiet --exit-code -- charts | ||
|
||
all: build | ||
|
||
|
@@ -39,11 +135,3 @@ docker-push: | |
.PHONY: docker-push-dev | ||
docker-push-dev: | ||
@docker buildx build --progress plane --platform $(PLATFORMS) --tag $(REPO):dev . --build-arg LD_FLAGS='$(LD_FLAGS) -X main.Version=$(IMAGE_TAG)-dev' --push | ||
|
||
.PHONY: fmt | ||
fmt: | ||
$(call print-target) | ||
@echo "Running gci" | ||
@go run github.com/daixiang0/[email protected] write -s standard -s default -s "prefix(github.com/kyverno/policy-reporter)" . | ||
@echo "Running gofumpt" | ||
@go run mvdan.cc/[email protected] -w . |
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
Oops, something went wrong.