Skip to content

Commit

Permalink
feat: Add a target to install/uninstall the provider locally (#191)
Browse files Browse the repository at this point in the history
* feat: Add a target to install/uninstall the provider locally
Co-authored-by: Francesco Racciatti <97034431+francesco-racciatti@users.noreply.github.com>
  • Loading branch information
marojor committed Aug 25, 2022
1 parent 6a288e6 commit 7e739b0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
16 changes: 16 additions & 0 deletions GNUmakefile
Expand Up @@ -5,11 +5,27 @@ WEBSITE_REPO=github.com/hashicorp/terraform-website
VERSION=$(shell [ ! -z `git tag -l --contains HEAD` ] && git tag -l --contains HEAD || git rev-parse --short HEAD)
GOPATH=$(shell go env GOPATH)

TERRAFORM_PLUGIN_ROOT_DIR=$(HOME)/.terraform.d/plugins
TERRAFORM_PROVIDER_REFERENCE_NAME=local
TERRAFORM_PROVIDER_NAME=sysdiglabs/$(PKG_NAME)
TERRAFORM_PROVIDER_DEV_VERSION=1.0.0
TERRAFORM_PLATFORM=$(shell terraform version -json | jq -r .platform)
TERRAFORM_SYSDIG_PLUGIN_DIR=$(TERRAFORM_PLUGIN_ROOT_DIR)/$(TERRAFORM_PROVIDER_REFERENCE_NAME)/$(TERRAFORM_PROVIDER_NAME)/$(TERRAFORM_PROVIDER_DEV_VERSION)/$(TERRAFORM_PLATFORM)

default: build

build: fmtcheck
go install

install: fmtcheck
go build -o terraform-provider-sysdig
mkdir -p $(TERRAFORM_SYSDIG_PLUGIN_DIR)
cp terraform-provider-sysdig $(TERRAFORM_SYSDIG_PLUGIN_DIR)/terraform-provider-sysdig

uninstall:
rm -rf $(TERRAFORM_SYSDIG_PLUGIN_DIR)


sweep:
@echo "WARNING: This will destroy infrastructure. Use only in development accounts."
go test $(TEST) -v -sweep=$(SWEEP) $(SWEEPARGS)
Expand Down
31 changes: 31 additions & 0 deletions README.md
Expand Up @@ -55,10 +55,41 @@ $ make test
```

If you want to execute the acceptance tests, you can run `make testacc`.

```sh
$ make testacc
```

To use the local provider you just built, get it installed in your machine with:

```sh
$ make install
```

That will add the provider to the terraform plugins dir. Then just set `source` and `version` values appropiately:

```
provider "aws" {
region = my_region
}
terraform {
required_providers {
sysdig = {
source = "local/sysdiglabs/sysdig"
version = "~> 1.0.0"
}
}
}
```

To uninstall the plugin:

```
$ make uninstall
```


<br/>:warning:Please note that you need a token for Monitor and Secure, and since the **acceptance tests create real infrastructure**
you should execute them in an environment where you can remove the resorces easily.

Expand Down

0 comments on commit 7e739b0

Please sign in to comment.