Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (50 loc) · 1.78 KB
/
Copy pathMakefile
File metadata and controls
62 lines (50 loc) · 1.78 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
# IMPORTANT: ⚠️ Requires gmake >= 4.0 ⚠️
PKGNAME := onefuse
PLUGIN_EXECUTABLE := terraform-provider-$(PKGNAME)
VERSION := $(file < VERSION) # `file` may be a Make 4.3+ feature
ifeq ($(OS),Windows_NT)
PLUGIN_RELEASE_EXECUTABLE := $(strip $(PLUGIN_EXECUTABLE)_v$(VERSION)).exe
else
PLUGIN_RELEASE_EXECUTABLE := $(strip $(PLUGIN_EXECUTABLE)_v$(VERSION))
endif
VERSION_NUM := $(firstword $(subst -, ,$(VERSION)))
HOSTOS := $$(go env GOHOSTOS)
HOSTARCH := $$(go env GOHOSTARCH)
PLUGIN_RELEASE_EXECUTABLE := $(PLUGIN_EXECUTABLE)_v$(VERSION)
TF_PLUGINS_DIR_0.12 := $(HOME)/.terraform.d/plugins/$(HOSTOS)_$(HOSTARCH)# TODO: Drop support for TF 0.12
TF_PLUGINS_DIR := $(HOME)/.terraform.d/plugins/registry.terraform.io/CloudBoltSoftware/$(PKGNAME)/$(VERSION_NUM)/$(HOSTOS)_$(HOSTARCH)
GOFMT_FILES?=$$(find . -name '*.go' -not -path './vendor/*' -not -path './go/*')
default: build
# Build the plugin
build: fmtcheck
go install
go build -o $(PLUGIN_EXECUTABLE)
install: build
mkdir -p $(TF_PLUGINS_DIR)
cp -f $(PLUGIN_EXECUTABLE) $(TF_PLUGINS_DIR)
# Terraform 0.12 compatability
mkdir -p $(TF_PLUGINS_DIR_0.12) # TODO: Drop support for TF 0.12
cp -f $(PLUGIN_EXECUTABLE) $(TF_PLUGINS_DIR_0.12) # TODO: Drop support for TF 0.12
# Format code
fmt:
gofmt -w main.go
gofmt -w onefuse
# Verify code conforms to gofmt standards
fmtcheck:
@gofmt -l main.go
@gofmt -l onefuse
ifneq ($(strip $(gofmt -l main.go)),)
@exit 1
endif
ifneq ($(strip $(gofmt -l onefuse)),)
@exit 1
endif
release-%: fmtcheck
scripts/build.sh --$* --sha256sum --output $(PLUGIN_RELEASE_EXECUTABLE) --basedir release/terraform-provider-onefuse
release: release-darwin release-linux release-windows
clean:
@rm -rf release/*
# Live API tests
testacc:
cd onefuse ; source config.env ; go test
.PHONY : build clean install fmt fmtcheck