11# Makefile for OADP CLI
22#
3- # This Makefile provides convenient targets for building, testing, and installing
4- # the OADP CLI as a kubectl plugin.
3+ # Simple Makefile for building, testing, and installing the OADP CLI
54
65# Variables
76BINARY_NAME = kubectl-oadp
8- LOCAL_BINARY = oadp
97INSTALL_PATH = /usr/local/bin
10- GO_FILES = $(shell find . -name '* .go' -not -path './vendor/* ')
118
129# Default target
1310.PHONY : help
@@ -19,133 +16,46 @@ help: ## Show this help message
1916
2017# Build targets
2118.PHONY : build
22- build : # # Build the CLI binary for local development
23- @echo " Building $( LOCAL_BINARY) for local development..."
24- go build -o $(LOCAL_BINARY ) .
25- @echo " ✅ Built $( LOCAL_BINARY) successfully!"
26-
27- .PHONY : build-plugin
28- build-plugin : # # Build the kubectl plugin binary
29- @echo " Building $( BINARY_NAME) kubectl plugin..."
19+ build : # # Build the kubectl plugin binary
20+ @echo " Building $( BINARY_NAME) ..."
3021 go build -o $(BINARY_NAME ) .
3122 @echo " ✅ Built $( BINARY_NAME) successfully!"
3223
3324# Installation targets
3425.PHONY : install
35- install : build-plugin # # Build and install the kubectl plugin (requires sudo)
26+ install : build # # Build and install the kubectl plugin
3627 @echo " Installing $( BINARY_NAME) to $( INSTALL_PATH) ..."
3728 sudo mv $(BINARY_NAME ) $(INSTALL_PATH ) /
38- @echo " ✅ $( BINARY_NAME) plugin installed successfully!"
39- @echo " You can now use: kubectl oadp --help"
40-
41- .PHONY : install-local
42- install-local : build-plugin # # Install the kubectl plugin to ~/bin (no sudo required)
43- @echo " Installing $( BINARY_NAME) to ~/bin..."
44- @mkdir -p ~ /bin
45- mv $(BINARY_NAME ) ~ /bin/
46- @echo " ✅ $( BINARY_NAME) plugin installed to ~/bin!"
47- @echo " Make sure ~/bin is in your PATH"
29+ @echo " ✅ $( BINARY_NAME) installed successfully!"
4830 @echo " You can now use: kubectl oadp --help"
4931
5032# Testing targets
5133.PHONY : test
5234test : # # Run all tests
5335 @echo " Running tests..."
5436 go test ./...
55- @echo " ✅ All tests passed!"
56-
57- .PHONY : test-verbose
58- test-verbose : # # Run tests with verbose output
59- @echo " Running tests with verbose output..."
60- go test -v ./...
61-
62- .PHONY : test-coverage
63- test-coverage : # # Run tests with coverage report
64- @echo " Running tests with coverage..."
65- go test -cover ./...
66-
67- # Development targets
68- .PHONY : fmt
69- fmt : # # Format Go code
70- @echo " Formatting Go code..."
71- go fmt ./...
72- @echo " ✅ Code formatted!"
73-
74- .PHONY : vet
75- vet : # # Run go vet
76- @echo " Running go vet..."
77- go vet ./...
78- @echo " ✅ Vet checks passed!"
79-
80- .PHONY : mod-tidy
81- mod-tidy : # # Tidy up go.mod
82- @echo " Tidying go.mod..."
83- go mod tidy
84- @echo " ✅ Dependencies tidied!"
85-
86- .PHONY : check
87- check : fmt vet test # # Run formatting, vetting, and tests
37+ @echo " ✅ Tests completed!"
8838
8939# Cleanup targets
9040.PHONY : clean
9141clean : # # Remove built binaries
92- @echo " Cleaning up built binaries ..."
93- @rm -f $(BINARY_NAME ) $( LOCAL_BINARY )
42+ @echo " Cleaning up..."
43+ @rm -f $(BINARY_NAME )
9444 @echo " ✅ Cleanup complete!"
9545
96- .PHONY : uninstall
97- uninstall : # # Remove the installed kubectl plugin
98- @echo " Removing $( BINARY_NAME) from $( INSTALL_PATH) ..."
99- @sudo rm -f $(INSTALL_PATH ) /$(BINARY_NAME )
100- @echo " ✅ $( BINARY_NAME) plugin uninstalled!"
101-
102- .PHONY : uninstall-local
103- uninstall-local : # # Remove the kubectl plugin from ~/bin
104- @echo " Removing $( BINARY_NAME) from ~/bin..."
105- @rm -f ~ /bin/$(BINARY_NAME )
106- @echo " ✅ $( BINARY_NAME) plugin uninstalled from ~/bin!"
107-
108- # Utility targets
109- .PHONY : verify-install
110- verify-install : # # Verify the kubectl plugin is installed and working
111- @echo " Verifying kubectl plugin installation..."
112- @if command -v kubectl oadp > /dev/null 2>&1 ; then \
113- echo " ✅ kubectl oadp plugin is installed and accessible!" ; \
114- kubectl oadp --help | head -5; \
115- else \
116- echo " ❌ kubectl oadp plugin not found in PATH" ; \
117- exit 1; \
118- fi
119-
120- .PHONY : dev-setup
121- dev-setup : mod-tidy fmt vet build # # Set up development environment
122- @echo " ✅ Development environment ready!"
123-
124- # File watching (requires 'entr' tool)
125- .PHONY : watch
126- watch : # # Watch for changes and rebuild (requires 'entr' tool)
127- @if command -v entr > /dev/null 2>&1 ; then \
128- echo " Watching for changes... (press Ctrl+C to stop)" ; \
129- find . -name ' *.go' | entr -r make build; \
130- else \
131- echo " ❌ 'entr' tool not found. Install with: brew install entr (macOS) or apt install entr (Ubuntu)" ; \
132- exit 1; \
133- fi
134-
135- # Show current status
46+ # Status and utility targets
13647.PHONY : status
137- status : # # Show build status and installed version
48+ status : # # Show build status and installation info
13849 @echo " === OADP CLI Status ==="
13950 @echo " "
14051 @echo " 📁 Repository:"
14152 @pwd
14253 @echo " "
143- @echo " 🔧 Local binaries :"
144- @ls -la $(LOCAL_BINARY ) $( BINARY_NAME ) 2> /dev/null || echo " No local binaries found"
54+ @echo " 🔧 Local binary :"
55+ @ls -la $(BINARY_NAME ) 2> /dev/null || echo " No local binary found"
14556 @echo " "
14657 @echo " 📦 Installed plugin:"
147- @ls -la $(INSTALL_PATH ) /$(BINARY_NAME ) 2> /dev/null || echo " Plugin not installed in $( INSTALL_PATH) "
148- @ls -la ~ /bin/$(BINARY_NAME ) 2> /dev/null || echo " Plugin not installed in ~/bin"
58+ @ls -la $(INSTALL_PATH ) /$(BINARY_NAME ) 2> /dev/null || echo " Plugin not installed"
14959 @echo " "
15060 @echo " ✅ Plugin accessibility:"
15161 @if command -v kubectl oadp > /dev/null 2>&1 ; then \
0 commit comments