generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGNUmakefile
48 lines (42 loc) · 1.79 KB
/
GNUmakefile
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
CONTAINER_RUNTIME ?= $(shell command -v podman 2> /dev/null || echo docker)
DEVCONTAINER ?= $(shell if test -f /.dockerenv; then echo true; else echo false; fi)
# Attempts to find network of current container when DEVCONTAINER=true
CONTAINER_NETWORK ?= $(shell \
if ( "$(DEVCONTAINER)" -eq "true" ); then \
$(CONTAINER_RUNTIME) inspect $(shell cat /proc/self/cgroup | grep "::/docker/" | cut -d"/" -f3) | jq -r '.[0].NetworkSettings.Networks | keys | .[0]' \
; else \
echo remote \
; fi)
.PHONY: test
default: test
# Start host containers used for playground and testing
hosts: clean
$(CONTAINER_RUNTIME) network create $(CONTAINER_NETWORK) || true
$(CONTAINER_RUNTIME) build -t remotehost tests
$(CONTAINER_RUNTIME) run --rm -d --net $(CONTAINER_NETWORK) --name remotehost -p 8022:22 remotehost
$(CONTAINER_RUNTIME) run --rm -d --net $(CONTAINER_NETWORK) --name remotehost2 -p 8023:22 remotehost
# Stop containers
clean:
$(CONTAINER_RUNTIME) rm -f remotehost remotehost2 || true
ifeq ($(DEVCONTAINER),false)
$(CONTAINER_RUNTIME) network rm $(CONTAINER_NETWORK) || true
endif
# Run acceptance tests
test: hosts
ifeq ($(DEVCONTAINER),true)
./tests/test.sh
else
$(CONTAINER_RUNTIME) run --rm --net remote -v ~/go:/go:z -v $(PWD):/provider:z --workdir /provider \
-e "TF_LOG=INFO" -e "TF_ACC=1" -e "TF_ACC_TERRAFORM_VERSION=1.0.11" -e "TESTARGS=$(TESTARGS)" \
golang:1.22 bash tests/test.sh
endif
# Install provider in playground
INSTALL_DIR=playground
TARGET_ARCH=$(shell go env GOOS)_$(shell go env GOARCH)
PROVIDER_PATH=.terraform/providers/registry.terraform.io/tenstad/remote/99.0.0/$(TARGET_ARCH)
BIN_PATH=$(INSTALL_DIR)/$(PROVIDER_PATH)/terraform-provider-remote_v99.0.0
install:
mkdir -p $(INSTALL_DIR)/$(PROVIDER_PATH)
go build -ldflags="-s -w -X main.version=99.0.0" -o $(BIN_PATH)
doc:
go generate