Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <[email protected]>
  • Loading branch information
fjogeleit committed Dec 8, 2023
1 parent 5c21783 commit 3e1390b
Show file tree
Hide file tree
Showing 7 changed files with 685 additions and 25 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/release-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
linting: off
charts_dir: charts
app_version: ${{ env.APP_VERSION }}
chart_version: ${{ env.CHART_VERSION }}
116 changes: 102 additions & 14 deletions Makefile
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

Expand Down Expand Up @@ -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 .
4 changes: 2 additions & 2 deletions charts/policy-reporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ description: |
It creates Prometheus Metrics and can send rule validation events to different targets like Loki, Elasticsearch, Slack or Discord
type: application
version: 2.21.2
appVersion: 2.17.2
version: 3.0.0-alpha
appVersion: 3.0.0-alpha

icon: https://github.com/kyverno/kyverno/raw/main/img/logo.png
home: https://kyverno.github.io/policy-reporter
Expand Down
Loading

0 comments on commit 3e1390b

Please sign in to comment.