generated from vshn/go-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (63 loc) · 2.39 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Set Shell to bash, otherwise some targets fail with dash/zsh etc.
SHELL := /bin/bash
# Disable built-in rules
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables
.SUFFIXES:
.SECONDARY:
.DEFAULT_GOAL := help
# General variables
include Makefile.vars.mk
# Optional kind module
-include kind/kind.mk
.PHONY: help
help: ## Show this help
@grep -E -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.PHONY: build
build: build-bin build-docker ## All-in-one build
.PHONY: build-bin
build-bin: export CGO_ENABLED = 0
build-bin: fmt vet ## Build binary
@go build -o $(BIN_FILENAME)
.PHONY: build-docker
build-docker: build-bin ## Build docker image
$(DOCKER_CMD) build -t $(CONTAINER_IMG) .
.PHONY: run
run:
go run . -webhook-cert-dir webhook-certs -zap-devel -zap-log-level debug
.PHONY: test
test: test-go ## All-in-one test
.PHONY: fuzz
fuzz:
go test ./ratio -fuzztime 1m -fuzz .
.PHONY: test-go
test-go: envtest ## Run unit tests against code
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -race -coverprofile cover.out -covermode atomic ./...
.PHONY: fmt
fmt: ## Run 'go fmt' against code
go fmt ./...
.PHONY: vet
vet: ## Run 'go vet' against code
go vet ./...
.PHONY: lint
lint: fmt vet generate manifests ## All-in-one linting
@echo 'Check for uncommitted changes ...'
git diff --exit-code
.PHONY: generate
generate: ## Generate additional code and artifacts
@go generate ./...
.PHONY: manifests
manifests: ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
go run sigs.k8s.io/controller-tools/cmd/controller-gen rbac:roleName=appuio-cloud-agent crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
@# Kubebuilder misses the scope field for the webhook generator
@yq eval -i '.webhooks[] |= with(select(.name == "validate-request-ratio.appuio.io"); .rules[] |= .scope = "Namespaced")' config/webhook/manifests.yaml
.PHONY: clean
clean: ## Cleans local build artifacts
rm -rf docs/node_modules $(docs_out_dir) dist .cache
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest