2021-02-19 23:58:01 +00:00
|
|
|
GO ?= go
|
|
|
|
BUILD ?= build
|
2021-10-18 13:31:55 +00:00
|
|
|
REPO ?= ghcr.io/kyverno/policy-reporter
|
2022-08-25 11:23:03 +00:00
|
|
|
IMAGE_TAG ?= 2.8.1
|
2021-12-13 15:02:40 +00:00
|
|
|
LD_FLAGS='-s -w -linkmode external -extldflags "-static"'
|
2022-03-16 22:06:39 +00:00
|
|
|
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x
|
2021-02-19 23:58:01 +00:00
|
|
|
|
|
|
|
all: build
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm -rf $(BUILD)
|
|
|
|
|
|
|
|
.PHONY: prepare
|
|
|
|
prepare:
|
|
|
|
mkdir -p $(BUILD)
|
|
|
|
|
2021-02-24 00:06:58 +00:00
|
|
|
.PHONY: test
|
|
|
|
test:
|
2021-12-13 15:02:40 +00:00
|
|
|
go test -v ./... -timeout=10s
|
2021-02-24 00:06:58 +00:00
|
|
|
|
|
|
|
.PHONY: coverage
|
|
|
|
coverage:
|
2021-12-13 15:02:40 +00:00
|
|
|
go test -v ./... -covermode=count -coverprofile=coverage.out -timeout=30s
|
2021-02-24 00:06:58 +00:00
|
|
|
|
2021-02-19 23:58:01 +00:00
|
|
|
.PHONY: build
|
|
|
|
build: prepare
|
2021-12-13 15:02:40 +00:00
|
|
|
CGO_ENABLED=1 $(GO) build -v -ldflags="-s -w" $(GOFLAGS) -o $(BUILD)/policyreporter .
|
2021-06-27 10:11:39 +00:00
|
|
|
|
|
|
|
.PHONY: docker-build
|
|
|
|
docker-build:
|
2022-03-16 22:06:39 +00:00
|
|
|
@docker buildx build --progress plane --platform $(PLATFORMS) --tag $(REPO):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS)
|
2021-06-27 10:11:39 +00:00
|
|
|
|
|
|
|
.PHONY: docker-push
|
|
|
|
docker-push:
|
2022-03-16 22:06:39 +00:00
|
|
|
@docker buildx build --progress plane --platform $(PLATFORMS) --tag $(REPO):$(IMAGE_TAG) . --build-arg LD_FLAGS=$(LD_FLAGS) --push
|
|
|
|
@docker buildx build --progress plane --platform $(PLATFORMS) --tag $(REPO):latest . --build-arg LD_FLAGS=$(LD_FLAGS) --push
|
2021-06-27 13:10:29 +00:00
|
|
|
|
|
|
|
.PHONY: docker-push-dev
|
|
|
|
docker-push-dev:
|
2022-03-16 22:06:39 +00:00
|
|
|
@docker buildx build --progress plane --platform $(PLATFORMS) --tag $(REPO):dev . --build-arg LD_FLAGS=$(LD_FLAGS) --push
|
2023-02-08 14:53:59 +00:00
|
|
|
|
|
|
|
.PHONY: fmt
|
|
|
|
fmt:
|
|
|
|
$(call print-target)
|
|
|
|
@echo "Running gci"
|
|
|
|
@go run github.com/daixiang0/gci@v0.9.1 write -s standard -s default -s "prefix(github.com/kyverno/policy-reporter)" .
|
|
|
|
@echo "Running gofumpt"
|
|
|
|
@go run mvdan.cc/gofumpt@v0.4.0 -w .
|