Skip to content

Commit 5140cc5

Browse files
committed
add makefile
1 parent 07bd226 commit 5140cc5

4 files changed

Lines changed: 161 additions & 28 deletions

File tree

GNUmakefile

Lines changed: 0 additions & 24 deletions
This file was deleted.

Makefile

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Makefile for terraform-provider-spiceai
2+
3+
BINARY_NAME=terraform-provider-spiceai
4+
VERSION?=dev
5+
GOOS?=$(shell go env GOOS)
6+
GOARCH?=$(shell go env GOARCH)
7+
8+
# Go build flags
9+
LDFLAGS=-ldflags "-X main.version=$(VERSION)"
10+
11+
# Directories
12+
PROJECT_DIR=$(shell pwd)
13+
TEST_DIR=$(PROJECT_DIR)/examples/test
14+
15+
.PHONY: all build clean test testacc fmt vet lint install setup plan apply destroy help
16+
17+
# Default target
18+
all: build
19+
20+
## Build targets
21+
22+
build:
23+
@echo "Building $(BINARY_NAME)..."
24+
go build $(LDFLAGS) -o $(BINARY_NAME) .
25+
@echo "Build complete: $(BINARY_NAME)"
26+
27+
build-all: build-linux build-darwin build-windows
28+
29+
build-linux:
30+
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(BINARY_NAME)_linux_amd64 .
31+
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $(BINARY_NAME)_linux_arm64 .
32+
33+
build-darwin:
34+
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(BINARY_NAME)_darwin_amd64 .
35+
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(BINARY_NAME)_darwin_arm64 .
36+
37+
build-windows:
38+
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o $(BINARY_NAME)_windows_amd64.exe .
39+
40+
install: build
41+
@echo "Installing provider to ~/.terraform.d/plugins..."
42+
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/spiceai/spiceai/$(VERSION)/$(GOOS)_$(GOARCH)
43+
cp $(BINARY_NAME) ~/.terraform.d/plugins/registry.terraform.io/spiceai/spiceai/$(VERSION)/$(GOOS)_$(GOARCH)/
44+
45+
## Test targets
46+
47+
test:
48+
@echo "Running unit tests..."
49+
go test ./... -v
50+
51+
testacc:
52+
@echo "Running acceptance tests..."
53+
TF_ACC=1 go test ./... -v -timeout 120m
54+
55+
## Code quality targets
56+
57+
fmt:
58+
@echo "Formatting code..."
59+
go fmt ./...
60+
61+
vet:
62+
@echo "Running go vet..."
63+
go vet ./...
64+
65+
lint:
66+
@echo "Running linter..."
67+
golangci-lint run ./...
68+
69+
## Development targets
70+
71+
setup:
72+
@echo "Setting up ~/.terraformrc with dev_overrides..."
73+
@printf 'provider_installation {\n dev_overrides {\n "spiceai/spiceai" = "%s"\n }\n direct {}\n}\n' "$(PROJECT_DIR)" > ~/.terraformrc
74+
@echo "Done. Provider path: $(PROJECT_DIR)"
75+
76+
plan: build
77+
@echo "Running terraform plan..."
78+
@test -n "$$SPICEAI_CLIENT_ID" || (echo "Error: SPICEAI_CLIENT_ID is not set"; exit 1)
79+
@test -n "$$SPICEAI_CLIENT_SECRET" || (echo "Error: SPICEAI_CLIENT_SECRET is not set"; exit 1)
80+
cd $(TEST_DIR) && terraform plan
81+
82+
apply: build
83+
@echo "Running terraform apply..."
84+
@test -n "$$SPICEAI_CLIENT_ID" || (echo "Error: SPICEAI_CLIENT_ID is not set"; exit 1)
85+
@test -n "$$SPICEAI_CLIENT_SECRET" || (echo "Error: SPICEAI_CLIENT_SECRET is not set"; exit 1)
86+
cd $(TEST_DIR) && terraform apply
87+
88+
destroy:
89+
@echo "Running terraform destroy..."
90+
@test -n "$$SPICEAI_CLIENT_ID" || (echo "Error: SPICEAI_CLIENT_ID is not set"; exit 1)
91+
@test -n "$$SPICEAI_CLIENT_SECRET" || (echo "Error: SPICEAI_CLIENT_SECRET is not set"; exit 1)
92+
cd $(TEST_DIR) && terraform destroy
93+
94+
## Cleanup targets
95+
96+
clean:
97+
@echo "Cleaning up..."
98+
rm -f $(BINARY_NAME)
99+
rm -f $(BINARY_NAME)_*
100+
rm -rf $(TEST_DIR)/.terraform
101+
rm -f $(TEST_DIR)/.terraform.lock.hcl
102+
rm -f $(TEST_DIR)/terraform.tfstate
103+
rm -f $(TEST_DIR)/terraform.tfstate.backup
104+
@echo "Clean complete"
105+
106+
## Documentation
107+
108+
docs:
109+
@echo "Generating documentation..."
110+
tfplugindocs generate --provider-name spiceai
111+
112+
## Dependency management
113+
114+
deps:
115+
@echo "Downloading dependencies..."
116+
go mod download
117+
118+
tidy:
119+
@echo "Tidying dependencies..."
120+
go mod tidy
121+
122+
## Help
123+
124+
help:
125+
@echo "Terraform Provider for Spice.ai - Makefile targets"
126+
@echo ""
127+
@echo "Build:"
128+
@echo " make build - Build the provider binary"
129+
@echo " make build-all - Build for all platforms"
130+
@echo " make install - Install provider to local plugins directory"
131+
@echo ""
132+
@echo "Test:"
133+
@echo " make test - Run unit tests"
134+
@echo " make testacc - Run acceptance tests"
135+
@echo ""
136+
@echo "Code Quality:"
137+
@echo " make fmt - Format Go code"
138+
@echo " make vet - Run go vet"
139+
@echo " make lint - Run linter"
140+
@echo ""
141+
@echo "Development:"
142+
@echo " make setup - Set up ~/.terraformrc with dev_overrides"
143+
@echo " make plan - Build and run terraform plan"
144+
@echo " make apply - Build and run terraform apply"
145+
@echo " make destroy - Run terraform destroy"
146+
@echo ""
147+
@echo "Cleanup:"
148+
@echo " make clean - Clean build artifacts and state files"
149+
@echo ""
150+
@echo "Other:"
151+
@echo " make docs - Generate provider documentation"
152+
@echo " make deps - Download dependencies"
153+
@echo " make tidy - Tidy dependencies"
154+
@echo ""
155+
@echo "Environment variables for plan/apply/destroy:"
156+
@echo " SPICEAI_CLIENT_ID - OAuth client ID"
157+
@echo " SPICEAI_CLIENT_SECRET - OAuth client secret"

terraform-provider-spiceai

-24.5 MB
Binary file not shown.

terraform-registry-manifest.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"version": 1,
3-
"metadata": {
4-
"protocol_versions": ["6.0"]
5-
}
2+
"version": 1,
3+
"metadata": {
4+
"protocol_versions": ["6.0"]
5+
}
66
}

0 commit comments

Comments
 (0)