-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
33 lines (28 loc) · 1.11 KB
/
Makefile
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
BINARY_NAME=terraform-provider-pfsense
VERSION=0.1.0
OS=$(shell uname | tr '[:upper:]' '[:lower:]')
ARCH=$(shell go env GOARCH)
PLUGIN_DIR=~/.terraform.d/plugins/terraform.local/local/pfsense
PF_PATH=terraform.local/local/pfsense
TF_PROVIDER_DIR=~/.terraform/providers/$(PF_PATH)
TF_PLUGIN_DIR=~/.terraform.d/plugins/$(PF_PATH)
TF_PLUGIN_BINARY_DIR=$(TF_PLUGIN_DIR)/$(VERSION)/$(OS)_$(ARCH)
TF_PROVIDER_BINARY_DIR=$(TF_PROVIDER_DIR)/$(VERSION)/$(OS)_$(ARCH)
# Build the custom Terraform provider
build:
@echo "Building the provider..."
go build -o $(BINARY_NAME)
test: build
@echo "Testing provider..."
go test -v ./...
# Install the custom provider to the local Terraform plugins directory
local-install: test
@echo "Installing the provider to local Terraform plugins directory..."
rm -rf $(TF_PROVIDER_DIR)
rm -rf $(TF_PLUGIN_DIR)
mkdir -p $(TF_PROVIDER_BINARY_DIR)
mkdir -p $(TF_PLUGIN_BINARY_DIR)
mv $(BINARY_NAME) $(TF_PLUGIN_BINARY_DIR)/$(BINARY_NAME)
chmod +x $(TF_PLUGIN_BINARY_DIR)/$(BINARY_NAME)
@echo "Provider installed at $(TF_PLUGIN_BINARY_DIR) and $(TF_PROVIDER_BINARY_DIR)!"
.PHONY: build local-install