Skip to content

Commit 7e739b0

Browse files
feat: Add a target to install/uninstall the provider locally (#191)
* feat: Add a target to install/uninstall the provider locally Co-authored-by: Francesco Racciatti <[email protected]>
1 parent 6a288e6 commit 7e739b0

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

GNUmakefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,27 @@ WEBSITE_REPO=github.com/hashicorp/terraform-website
55
VERSION=$(shell [ ! -z `git tag -l --contains HEAD` ] && git tag -l --contains HEAD || git rev-parse --short HEAD)
66
GOPATH=$(shell go env GOPATH)
77

8+
TERRAFORM_PLUGIN_ROOT_DIR=$(HOME)/.terraform.d/plugins
9+
TERRAFORM_PROVIDER_REFERENCE_NAME=local
10+
TERRAFORM_PROVIDER_NAME=sysdiglabs/$(PKG_NAME)
11+
TERRAFORM_PROVIDER_DEV_VERSION=1.0.0
12+
TERRAFORM_PLATFORM=$(shell terraform version -json | jq -r .platform)
13+
TERRAFORM_SYSDIG_PLUGIN_DIR=$(TERRAFORM_PLUGIN_ROOT_DIR)/$(TERRAFORM_PROVIDER_REFERENCE_NAME)/$(TERRAFORM_PROVIDER_NAME)/$(TERRAFORM_PROVIDER_DEV_VERSION)/$(TERRAFORM_PLATFORM)
14+
815
default: build
916

1017
build: fmtcheck
1118
go install
1219

20+
install: fmtcheck
21+
go build -o terraform-provider-sysdig
22+
mkdir -p $(TERRAFORM_SYSDIG_PLUGIN_DIR)
23+
cp terraform-provider-sysdig $(TERRAFORM_SYSDIG_PLUGIN_DIR)/terraform-provider-sysdig
24+
25+
uninstall:
26+
rm -rf $(TERRAFORM_SYSDIG_PLUGIN_DIR)
27+
28+
1329
sweep:
1430
@echo "WARNING: This will destroy infrastructure. Use only in development accounts."
1531
go test $(TEST) -v -sweep=$(SWEEP) $(SWEEPARGS)

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,41 @@ $ make test
5555
```
5656

5757
If you want to execute the acceptance tests, you can run `make testacc`.
58+
5859
```sh
5960
$ make testacc
6061
```
6162

63+
To use the local provider you just built, get it installed in your machine with:
64+
65+
```sh
66+
$ make install
67+
```
68+
69+
That will add the provider to the terraform plugins dir. Then just set `source` and `version` values appropiately:
70+
71+
```
72+
provider "aws" {
73+
region = my_region
74+
}
75+
76+
terraform {
77+
required_providers {
78+
sysdig = {
79+
source = "local/sysdiglabs/sysdig"
80+
version = "~> 1.0.0"
81+
}
82+
}
83+
}
84+
```
85+
86+
To uninstall the plugin:
87+
88+
```
89+
$ make uninstall
90+
```
91+
92+
6293
<br/>:warning:Please note that you need a token for Monitor and Secure, and since the **acceptance tests create real infrastructure**
6394
you should execute them in an environment where you can remove the resorces easily.
6495

0 commit comments

Comments
 (0)