Skip to content

Commit 2d5ea07

Browse files
committed
Cleaner Makefile
1 parent 24e730c commit 2d5ea07

File tree

3 files changed

+22
-133
lines changed

3 files changed

+22
-133
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
# Built binaries
99
kubectl-oadp
10-
oadp
1110

1211
# Test binary, built with `go test -c`
1312
*.test

Makefile

Lines changed: 13 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
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
76
BINARY_NAME = kubectl-oadp
8-
LOCAL_BINARY = oadp
97
INSTALL_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
5234
test: ## 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
9141
clean: ## 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 \

README.md

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,15 @@ oadp
3030
Use the Makefile for easy build and installation:
3131

3232
```sh
33-
# Quick install (equivalent to old quick-create.sh)
34-
make quick-install
35-
36-
# Or step by step:
37-
make build-plugin
38-
sudo make install
33+
# Build and install the kubectl plugin
34+
make install
3935
```
4036

41-
### Alternative Installation Methods
42-
43-
**Install to ~/bin (no sudo required):**
44-
```sh
45-
make install-local
46-
```
37+
### Manual Installation
4738

48-
**Manual Installation:**
4939
1. **Build the CLI:**
5040
```sh
51-
make build-plugin
52-
# or manually: go build -o kubectl-oadp .
41+
make build
5342
```
5443

5544
2. **Install as kubectl plugin:**
@@ -59,24 +48,21 @@ make install-local
5948

6049
3. **Verify installation:**
6150
```sh
62-
make verify-install
63-
# or manually: kubectl oadp --help
51+
kubectl oadp --help
6452
```
6553

6654
### Development Workflow
6755

6856
```sh
69-
# Set up development environment
70-
make dev-setup
71-
72-
# Build for local testing
57+
# Build and test locally
7358
make build
59+
./kubectl-oadp --help
7460

7561
# Run tests
7662
make test
7763

78-
# Format and check code
79-
make check
64+
# Check status
65+
make status
8066

8167
# View all available commands
8268
make help
@@ -133,12 +119,6 @@ This project includes comprehensive CLI integration tests organized by functiona
133119
# Run all tests
134120
make test
135121

136-
# Run tests with verbose output
137-
make test-verbose
138-
139-
# Run tests with coverage
140-
make test-coverage
141-
142122
# Standard Go pattern (also works)
143123
go test ./...
144124
```

0 commit comments

Comments
 (0)