-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (98 loc) · 3.45 KB
/
Makefile
File metadata and controls
129 lines (98 loc) · 3.45 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# onax Makefile
# Image URL
IMG ?= ghcr.io/varaxlabs/onax:latest
# Version injection
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
DATE ?= $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
LDFLAGS := -s -w \
-X github.com/varaxlabs/onax/internal/version.Version=$(VERSION) \
-X github.com/varaxlabs/onax/internal/version.Commit=$(COMMIT) \
-X github.com/varaxlabs/onax/internal/version.Date=$(DATE)
# Get the currently used golang install path
GOPATH ?= $(shell go env GOPATH)
GOBIN ?= $(GOPATH)/bin
# setup-envtest binary
SETUP_ENVTEST ?= $(GOBIN)/setup-envtest
ENVTEST_K8S_VERSION ?= 1.30.0
.PHONY: all
all: build
##@ General
.PHONY: help
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Development
.PHONY: fmt
fmt: ## Run go fmt
go fmt ./...
.PHONY: vet
vet: ## Run go vet
go vet ./...
.PHONY: lint
lint: ## Run golangci-lint
golangci-lint run
.PHONY: test
test: fmt vet envtest ## Run tests
KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(shell pwd)/testbin -p path)" \
go test ./... -coverprofile cover.out -race
@echo "Coverage:"
@go tool cover -func cover.out | tail -1
.PHONY: test-coverage
test-coverage: test ## Run tests with coverage report
go tool cover -html=cover.out -o coverage.html
@echo "Coverage report: coverage.html"
.PHONY: test-integration
test-integration: fmt vet envtest ## Run integration tests only
KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(shell pwd)/testbin -p path)" \
go test ./pkg/controller/... -coverprofile cover.out -race -v
##@ Build
.PHONY: build
build: fmt vet ## Build binary
go build -ldflags '$(LDFLAGS)' -o bin/onax ./cmd/operator
.PHONY: run
run: fmt vet ## Run operator locally
go run cmd/operator/main.go
.PHONY: docker-build
docker-build: ## Build docker image
docker build \
--build-arg VERSION=$(VERSION) \
--build-arg COMMIT=$(COMMIT) \
--build-arg DATE=$(DATE) \
-t ${IMG} .
.PHONY: docker-push
docker-push: ## Push docker image
docker push ${IMG}
.PHONY: release-snapshot
release-snapshot: ## Run GoReleaser in snapshot mode (local dry run)
goreleaser release --snapshot --clean
##@ Tool Dependencies
.PHONY: envtest
envtest: $(SETUP_ENVTEST) ## Download setup-envtest if necessary
$(SETUP_ENVTEST):
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
##@ Deployment
.PHONY: deploy
deploy: ## Deploy to cluster using Helm
helm upgrade --install onax ./deploy/helm/onax \
--namespace monitoring \
--create-namespace
.PHONY: undeploy
undeploy: ## Remove from cluster
helm uninstall onax --namespace monitoring
.PHONY: manifests
manifests: ## Generate raw YAML manifests from Helm
helm template onax ./deploy/helm/onax \
--namespace monitoring > deploy/manifests/operator.yaml
##@ Local Testing
.PHONY: kind-create
kind-create: ## Create kind cluster with monitoring stack
./hack/test-setup.sh create
.PHONY: kind-delete
kind-delete: ## Delete kind cluster
kind delete cluster --name cronjob-monitor-test
.PHONY: import-dashboards
import-dashboards: ## Import Grafana dashboards
./hack/import-dashboards.sh
.PHONY: test-cronjobs
test-cronjobs: ## Deploy test CronJobs
kubectl apply -f examples/