Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (83 loc) · 3.88 KB
/
Copy pathMakefile
File metadata and controls
109 lines (83 loc) · 3.88 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Include ODC common make targets
DEV_KIT_VERSION := v1.0.15
-include common.mk
common.mk:
curl --fail -sSL https://raw.githubusercontent.com/opendefensecloud/dev-kit/$(DEV_KIT_VERSION)/common.mk -o common.mk.download && \
mv common.mk.download $@
APIGEN ?= $(LOCALGOBIN)/apigen
KCP ?= $(LOCALBIN)/kcp
# Envtest kcp binary version. Pinned to what multicluster-provider v0.8.0's
# envtest was built/tested against (its Makefile + access-operator both use
# 0.30.0). This is the test-harness binary, distinct from the production kcp
# version (idea.md spikes targeted v0.32.3).
KCP_VERSION ?= 0.30.0
DOCKER ?= docker
IMG_REGISTRY ?= ghcr.io/opendefense
IMG_TAG ?= latest
CONTROLLER_IMG ?= $(IMG_REGISTRY)/krop-controller:$(IMG_TAG)
# Build version injected into the binary via -ldflags -X main.version.
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
TIMESTAMP := $(shell date '+%Y%m%d%H%M%S')
DEV_TAG ?= dev.$(TIMESTAMP)
export DEV_TAG
LICENSE := apache
LICENSE_COMMENT := opendefense contributors
##@ Development
.PHONY: generate
generate: $(CONTROLLER_GEN) ## Generate deepcopy methods.
$(CONTROLLER_GEN) object paths="./api/..."
.PHONY: manifests
manifests: $(CONTROLLER_GEN) $(APIGEN) ## Generate the engine CRD and convert to kcp APIResourceSchemas + APIExport.
$(CONTROLLER_GEN) crd paths="./api/..." output:crd:dir=config/crds
$(APIGEN) --input-dir=config/crds --output-dir=config/kcp
.PHONY: fmt
fmt: $(ADDLICENSE) $(GOLANGCI_LINT) ## Add license headers and format code.
$(MAKE) addlicense license=$(LICENSE) comment='$(LICENSE_COMMENT)' pattern='*\.go'
$(GO) fmt ./...
$(GOLANGCI_LINT) run --fix
.PHONY: lint
lint: lint-no-golangci golangci-lint ## Run all linters.
.PHONY: lint-no-golangci
lint-no-golangci: ## Run linters except golangci-lint (license headers + shellcheck).
$(MAKE) addlicense-check license=$(LICENSE) comment='$(LICENSE_COMMENT)' pattern='*\.go'
.PHONY: vet
vet: ## Run go vet.
$(GO) vet ./...
##@ Build
.PHONY: build
build: generate ## Build the controller binary.
$(GO) build -ldflags "-X main.version=$(VERSION)" -o $(LOCALBIN)/krop-controller ./cmd/controller/
.PHONY: run
run-controller: generate ## Run the controller from source.
$(GO) run ./cmd/controller/
.PHONY: docker-build
docker-build: ## Build the Docker image (native single-arch; multi-arch is the CI pipeline's job).
$(DOCKER) build --build-arg VERSION=$(VERSION) -t $(CONTROLLER_IMG) .
.PHONY: docker-push
docker-push: ## Push the Docker image.
$(DOCKER) push $(CONTROLLER_IMG)
.PHONY: helm-package
helm-package: manifests ## Package Helm chart.
helm package charts/krop-controller
.PHONY: deploy-standalone
deploy-standalone: ## Apply the fog/edge standalone deployment (plain cluster, non-kcp).
kubectl apply -k config/standalone
##@ Testing
.PHONY: test
test: $(GINKGO) $(KCP) generate ## Run all tests (excludes e2e).
TEST_KCP_ASSETS=$(LOCALBIN) $(GINKGO) -r -cover --fail-fast --require-suite -covermode count --output-dir=$(BUILD_PATH) -coverprofile=coverprofile --skip-package=test/e2e $(testargs)
.PHONY: test-e2e
test-e2e: $(GINKGO) ## Run the full-stack e2e (kind + kcp-operator + helm; deployed pod). Set E2E_SKIP_CLEANUP=1 to keep the cluster.
$(GINKGO) -r --fail-fast -v --timeout 30m ./test/e2e/ $(testargs)
.PHONY: clean-e2e
clean-e2e: ## Remove the kind cluster created by the e2e tests.
-$(KIND) delete cluster --name krop-e2e 2>/dev/null
##@ Tool Dependencies
.PHONY: $(KCP)
$(KCP): $(LOCALBIN) ## Download kcp binary locally if necessary.
@test -s $(LOCALBIN)/kcp && $(LOCALBIN)/kcp --version 2>&1 | grep -q "$(KCP_VERSION)" || (\
echo "Downloading kcp v$(KCP_VERSION) for $(OS)/$(ARCH)..."; \
curl -fsSL -o $(LOCALBIN)/kcp.tar.gz "https://github.com/kcp-dev/kcp/releases/download/v$(KCP_VERSION)/kcp_$(KCP_VERSION)_$(OS)_$(ARCH).tar.gz"; \
tar -xzf $(LOCALBIN)/kcp.tar.gz -C $(LOCALBIN) --strip-components=1 bin/; \
rm -f $(LOCALBIN)/kcp.tar.gz; \
chmod +x $(LOCALBIN)/kcp)