forked from migtools/oadp-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (80 loc) · 2.83 KB
/
Makefile
File metadata and controls
88 lines (80 loc) · 2.83 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
# Makefile for OADP CLI
#
# Simple Makefile for building, testing, and installing the OADP CLI
# Variables
BINARY_NAME = kubectl-oadp
INSTALL_PATH ?= /usr/local/bin
# Platform variables for multi-arch builds
# Usage: make build PLATFORM=linux/amd64
PLATFORM ?=
GOOS = $(word 1,$(subst /, ,$(PLATFORM)))
GOARCH = $(word 2,$(subst /, ,$(PLATFORM)))
# Default target
.PHONY: help
help: ## Show this help message
@echo "OADP CLI Makefile"
@echo ""
@echo "Available targets:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "Build with different platforms:"
@echo " make build PLATFORM=linux/amd64"
@echo " make build PLATFORM=linux/arm64"
@echo " make build PLATFORM=darwin/amd64"
@echo " make build PLATFORM=darwin/arm64"
@echo " make build PLATFORM=windows/amd64"
# Build targets
.PHONY: build
build: ## Build the kubectl plugin binary (use PLATFORM=os/arch for cross-compilation)
@if [ -n "$(PLATFORM)" ]; then \
echo "Building $(BINARY_NAME) for $(PLATFORM)..."; \
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(BINARY_NAME)-$(GOOS)-$(GOARCH) .; \
echo "✅ Built $(BINARY_NAME)-$(GOOS)-$(GOARCH) successfully!"; \
else \
echo "Building $(BINARY_NAME) for current platform ($$(go env GOOS)/$$(go env GOARCH))..."; \
go build -o $(BINARY_NAME) .; \
echo "✅ Built $(BINARY_NAME) successfully!"; \
fi
# Installation targets
.PHONY: install
install: build ## Build and install the kubectl plugin
@echo "Installing $(BINARY_NAME) to $(INSTALL_PATH)..."
mv $(BINARY_NAME) $(INSTALL_PATH)/
@echo "✅ $(BINARY_NAME) installed successfully!"
@echo "You can now use: kubectl oadp --help"
# Testing targets
.PHONY: test
test: ## Run all tests
@echo "Running tests..."
go test ./...
@echo "✅ Tests completed!"
# Cleanup targets
.PHONY: clean
clean: ## Remove built binaries
@echo "Cleaning up..."
@rm -f $(BINARY_NAME) $(BINARY_NAME)-*
@echo "✅ Cleanup complete!"
# Status and utility targets
.PHONY: status
status: ## Show build status and installation info
@echo "=== OADP CLI Status ==="
@echo ""
@echo "📁 Repository:"
@pwd
@echo ""
@echo "🔧 Local binary:"
@ls -la $(BINARY_NAME) 2>/dev/null || echo " No local binary found"
@echo ""
@echo "📦 Installed plugin:"
@ls -la $(INSTALL_PATH)/$(BINARY_NAME) 2>/dev/null || echo " Plugin not installed"
@echo ""
@echo "✅ Plugin accessibility:"
@if kubectl plugin list 2>/dev/null | grep -q "kubectl-oadp"; then \
echo " ✅ kubectl-oadp plugin is installed and accessible"; \
echo " Version check:"; \
kubectl oadp version 2>/dev/null || echo " (version command not available)"; \
else \
echo " ❌ kubectl-oadp plugin is NOT accessible"; \
echo " Available plugins:"; \
kubectl plugin list 2>/dev/null | head -5 || echo " (no plugins found or kubectl not available)"; \
fi