-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
127 lines (118 loc) · 4.86 KB
/
Makefile
File metadata and controls
127 lines (118 loc) · 4.86 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
.PHONY: lint fix build docs docs-check onboard update
BINARY=equinix
GOLANGCI_LINT_VERSION=v2.3.0
GOLANGCI_LINT=go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
lint:
$(GOLANGCI_LINT) run -v
fix:
$(GOLANGCI_LINT) run -v --fix
build:
go build $(LDFLAGS) -o bin/$(BINARY) main.go
docs:
rm -rf docs/
mkdir -p docs
go run main.go docs ./docs
docs-check: docs
if git status --porcelain | grep docs; then \
echo "Uncommitted changes detected. Run 'make docs' and commit changes."; \
exit 1; \
fi
# update - Update an existing service integration by fetching latest SDK and regenerating descriptions
# Usage: make update SERVICE=fabricv4
# This will:
# 1. Update the SDK package to the latest version
# 2. Extract SDK descriptions and save to cmd/descriptions/<service>.json
update:
@if [ -z "$(SERVICE)" ]; then \
echo "Error: SERVICE parameter is required"; \
echo "Usage: make update SERVICE=fabricv4"; \
exit 1; \
fi
@echo "Updating service: $(SERVICE)"
@echo "Step 1: Fetching SDK package..."
@go get $$(go list -f '{{.Path}}@{{.Version}}' -m github.com/equinix/equinix-sdk-go)
@go mod tidy
@echo ""
@echo "Step 2: Extracting SDK descriptions..."
@mkdir -p cmd/descriptions
@SDK_PATH=$$(go list -f '{{.Dir}}' -m github.com/equinix/equinix-sdk-go)/services/$(SERVICE); \
if [ -z "$$SDK_PATH" ] || [ ! -d "$$SDK_PATH" ]; then \
echo "Error: Could not find SDK path for $(SERVICE)"; \
echo "Make sure github.com/equinix/equinix-sdk-go/services/$(SERVICE) is a valid module"; \
exit 1; \
fi; \
echo "Extracting descriptions from: $$SDK_PATH"; \
go run cmd/extract-descriptions/main.go --sdk-path "$$SDK_PATH" --output cmd/descriptions/$(SERVICE).json
@echo ""
@echo "Service $(SERVICE) updated successfully!"
@echo "Description file: cmd/descriptions/$(SERVICE).json"
@echo ""
@echo "Next steps:"
@echo "1. Review the updated SDK integration"
@echo "2. Run 'make build' to verify the changes"
@echo "3. Run 'make docs' to update documentation"
@echo "4. Commit the changes including go.mod, go.sum, and cmd/descriptions/$(SERVICE).json"
# onboard - Scaffold a new service integration
# Usage: make onboard SERVICE=fabricv5
# This will create cmd/<service>.go, internal/<service>/<service>.go, and extract SDK descriptions
onboard:
@if [ -z "$(SERVICE)" ]; then \
echo "Error: SERVICE parameter is required"; \
echo "Usage: make onboard SERVICE=fabricv5"; \
exit 1; \
fi
@echo "Onboarding new service: $(SERVICE)"
@echo ""
@echo "Step 1: Creating service scaffolding..."
@mkdir -p cmd
@sed -e 's/{{SERVICE}}/$(SERVICE)/g' \
-e 's/{{SERVICE_DISPLAY}}/$(shell echo $(SERVICE) | sed 's/\([a-z]\)\([A-Z]\)/\1 \2/g' | sed 's/v\([0-9]\)/v\1/g' | sed 's/\b\(.\)/\u\1/g')/g' \
-e 's/{{SERVICE_ALIAS}}/$(shell echo $(SERVICE) | sed 's/v[0-9]*$$//')/g' \
templates/cmd/service.go.tmpl > cmd/$(SERVICE).go
@echo " - Created cmd/$(SERVICE).go"
@mkdir -p internal/$(SERVICE)
@sed -e 's/{{SERVICE}}/$(SERVICE)/g' \
-e 's/{{SERVICE_DISPLAY}}/$(shell echo $(SERVICE) | sed 's/\([a-z]\)\([A-Z]\)/\1 \2/g' | sed 's/v\([0-9]\)/v\1/g' | sed 's/\b\(.\)/\u\1/g')/g' \
templates/internal/service.go.tmpl > internal/$(SERVICE)/$(SERVICE).go
@echo " - Created internal/$(SERVICE)/$(SERVICE).go"
@echo ""
@echo "Step 2: Fetching SDK and extracting descriptions..."
@$(MAKE) update SERVICE=$(SERVICE)
@echo ""
@echo "Service $(SERVICE) onboarded successfully!"
@echo ""
@echo "Files created:"
@echo " - cmd/$(SERVICE).go"
@echo " - internal/$(SERVICE)/$(SERVICE).go"
@echo " - cmd/descriptions/$(SERVICE).json"
@echo ""
@echo "Next steps:"
@echo "1. Review and adjust the generated files as needed"
@echo "2. Add service-specific aliases in cmd/$(SERVICE).go if desired"
@echo "3. Run 'make build' to verify the integration"
@echo "4. Run 'make docs' to generate documentation"
@echo "5. Update README.md with information about the new service"
# generate-all - Onboard/update all service integrations by fetching latest SDK
# and looping over all services that exist in the SDK
# Usage: make generate-all
# This will:
# 1. Update the SDK package to the latest version
# 2. Extract SDK descriptions and save to cmd/descriptions/<service>.json
generate-all:
@echo "Generating all services"
@echo "Step 1: Fetching SDK package..."
@go get $$(go list -f '{{.Path}}@{{.Version}}' -m github.com/equinix/equinix-sdk-go)
@go mod tidy
@echo ""
@echo "Step 2: Onboarding all service packages in the SDK..."
@mkdir -p cmd/descriptions
@SDK_PATH=$$(go list -f '{{.Dir}}' -m github.com/equinix/equinix-sdk-go)/services; \
if [ -z "$$SDK_PATH" ] || [ ! -d "$$SDK_PATH" ]; then \
echo "Error: Could not find SDK path for services"; \
echo "Make sure github.com/equinix/equinix-sdk-go/services is a valid module"; \
exit 1; \
fi; \
SERVICES=$$(ls -1 $$SDK_PATH); \
for SERVICE in $$SERVICES; do \
$(MAKE) onboard SERVICE=$$SERVICE; \
done;