Skip to content

Commit 8b11975

Browse files
committed
Enhance Makefile for building and managing Terraform provider
- Update provider version to 0.2.1 - Automatically determine OS and architecture using `go env GOOS` and `go env GOARCH` - Define variables for plugin directory and output path - Add commands for building, testing, formatting, linting, and cleaning the project - Include command to install dependencies using `go mod tidy` - Add help command to display usage information This update improves the Makefile by making it more flexible and adding useful development commands.
1 parent ddb08ad commit 8b11975

File tree

1 file changed

+65
-8
lines changed

1 file changed

+65
-8
lines changed

Diff for: Makefile

+65-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,69 @@
1-
version := 0.2.0
2-
#path := $$HOME/.terraform.d/plugins/github.com/murtll/regru/${version}/linux_amd64
3-
#path := $$HOME/.terraform.d/plugins/github.com/murtll/regru/${version}/darwin_arm64
4-
path := $$HOME/.terraform.d/plugins/registry.terraform.io/murtll/regru/${version}/darwin_arm64
5-
#path := $$HOME/.terraform.d/plugins/darwin_arm64
1+
# Версия провайдера
2+
VERSION := 0.2.1
63

4+
# Определение пути для установки плагина
5+
OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH)
6+
PLUGIN_DIR := $(HOME)/.terraform.d/plugins/registry.terraform.io/letenkov/regru/$(VERSION)/$(OS_ARCH)
7+
PLUGIN_NAME := terraform-provider-regru_v$(VERSION)
8+
BUILD_OUTPUT := $(PLUGIN_DIR)/$(PLUGIN_NAME)
9+
10+
# Компиляция и установка провайдера
11+
.PHONY: build
712
build:
8-
mkdir -p ${path}
9-
go build -o ${path}/terraform-provider-regru_${version}
13+
@echo "Building Terraform provider..."
14+
mkdir -p $(PLUGIN_DIR)
15+
go build -o $(BUILD_OUTPUT)
16+
@echo "Build completed and installed at $(BUILD_OUTPUT)"
1017

11-
get-go-version:
18+
# Получение версии Go из go.mod
19+
.PHONY: go-version
20+
go-version:
1221
@grep ^go go.mod | awk '{ print $$2 }'
22+
23+
# Запуск тестов
24+
.PHONY: test
25+
test:
26+
@echo "Running tests..."
27+
go test ./... -v
28+
@echo "Tests completed"
29+
30+
# Форматирование кода
31+
.PHONY: fmt
32+
fmt:
33+
@echo "Formatting code..."
34+
go fmt ./...
35+
@echo "Code formatted"
36+
37+
# Линтинг кода
38+
.PHONY: lint
39+
lint:
40+
@echo "Linting code..."
41+
go vet ./...
42+
@echo "Linting completed"
43+
44+
# Очистка сборочных артефактов
45+
.PHONY: clean
46+
clean:
47+
@echo "Cleaning up..."
48+
rm -f $(BUILD_OUTPUT)
49+
@echo "Cleanup completed"
50+
51+
# Установка всех зависимостей
52+
.PHONY: install-deps
53+
install-deps:
54+
@echo "Installing dependencies..."
55+
go mod tidy
56+
@echo "Dependencies installed"
57+
58+
# Помощь
59+
.PHONY: help
60+
help:
61+
@echo "Usage:"
62+
@echo " make build Build and install the Terraform provider"
63+
@echo " make go-version Get the Go version from go.mod"
64+
@echo " make test Run tests"
65+
@echo " make fmt Format the code"
66+
@echo " make lint Lint the code"
67+
@echo " make clean Clean up build artifacts"
68+
@echo " make install-deps Install all dependencies"
69+
@echo " make help Display this help message"

0 commit comments

Comments
 (0)