-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
118 lines (93 loc) · 4.04 KB
/
Makefile
File metadata and controls
118 lines (93 loc) · 4.04 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
# =============================================================================
# Configuration Variables
# =============================================================================
# Image configurations
IMG ?= ghcr.io/ullbergm/object-lease-controller:v1.0.0
PLUGIN_IMG ?= ghcr.io/ullbergm/object-lease-console-plugin:v1.0.0
# Build configurations
CONTAINER_TOOL ?= docker
PLATFORMS ?= linux/arm64,linux/amd64
# Application configurations
BINARY_NAME = lease-controller
BUILD_DIR = bin
# =============================================================================
# Development Targets
# =============================================================================
.PHONY: help
help: ## Display this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
.PHONY: tidy
tidy: ## Clean up Go modules
go mod tidy
.PHONY: fmt
fmt: ## Format Go code
go fmt ./...
.PHONY: vet
vet: ## Vet Go code
go vet ./...
.PHONY: lint
lint: ## Run golangci-lint (requires golangci-lint installed)
golangci-lint run
.PHONY: test
test: tidy fmt vet ## Run tests with coverage
go test ./... -race -coverprofile=coverage.out
go tool cover -html=coverage.out -o=coverage.html
.PHONY: build
build: tidy fmt vet test ## Build the binary
go build -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/main.go
.PHONY: run
run: build ## Run the application locally
./$(BUILD_DIR)/$(BINARY_NAME) \
-group startpunkt.ullberg.us \
-kind Application \
-version v1alpha4 \
-leader-elect \
-leader-elect-namespace default \
# -opt-in-label-key "object-lease-controller.ullberg.io/enabled" \
# -opt-in-label-value true \
-zap-log-level debug
# =============================================================================
# Docker Targets - Main Controller
# =============================================================================
.PHONY: docker-build
docker-build: build ## Build Docker image for main controller
$(CONTAINER_TOOL) build -t $(IMG) .
.PHONY: docker-push
docker-push: docker-build ## Build and push Docker image for main controller
$(CONTAINER_TOOL) push $(IMG)
.PHONY: docker-buildx
docker-buildx: ## Build and push multi-platform Docker image for main controller
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
$(CONTAINER_TOOL) buildx use project-v3-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag $(IMG) -f Dockerfile .
- $(CONTAINER_TOOL) buildx rm project-v3-builder
# =============================================================================
# Docker Targets - Console Plugin
# =============================================================================
.PHONY: plugin-build
plugin-build: ## Build Docker image for console plugin
$(CONTAINER_TOOL) build -t $(PLUGIN_IMG) object-lease-console-plugin
.PHONY: plugin-push
plugin-push: plugin-build ## Build and push Docker image for console plugin
$(CONTAINER_TOOL) push $(PLUGIN_IMG)
.PHONY: plugin-buildx
plugin-buildx: ## Build and push multi-platform Docker image for console plugin
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
$(CONTAINER_TOOL) buildx use project-v3-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag $(PLUGIN_IMG) object-lease-console-plugin
- $(CONTAINER_TOOL) buildx rm project-v3-builder
# =============================================================================
# Deployment Targets
# =============================================================================
.PHONY: deploy-operator-and-plugin
deploy-operator-and-plugin: ## Deploy operator and plugin to Kubernetes
kubectl apply -k object-lease-operator/config/default
# =============================================================================
# Convenience Targets
# =============================================================================
.PHONY: push-all
push-all: ## Push all images and operator bundles
$(MAKE) docker-push
$(MAKE) plugin-push
cd object-lease-operator && $(MAKE) docker-build docker-push bundle-push catalog-push && cd ..