Skip to content

Commit 7275d5a

Browse files
authored
Merge pull request #1172 from timofurrer/local-build
Add convenience cmd to build and install bin locally
2 parents ac46389 + 33a747a commit 7275d5a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

CONTRIBUTING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,35 @@ You'll first need [Go](http://www.golang.org) installed on your machine (version
7878
```
7979

8080

81+
You can also install the provider locally so that you can use it with Terraform experimentally.
82+
Run one of the following `make` commands depending on what is correct for your platform:
83+
84+
```sh
85+
# Default: suitable for macOS
86+
make local
87+
88+
# Set the terraform platform directory
89+
# e.g. for linux amd64:
90+
make local TERRAFORM_PLATFORM_DIR=linux_amd64
91+
92+
# Set the terraform plugin dir, see https://www.terraform.io/cli/config/config-file#implied-local-mirror-directories
93+
# e.g. for Windows
94+
make local TERRAFORM_PLUGIN_DIR=%APPDATA%/terraform.d/plugins
95+
```
96+
97+
The you can use it in your provider config like this:
98+
99+
```hcl
100+
terraform {
101+
required_providers {
102+
gitlab = {
103+
version = "99.99.99"
104+
source = "gitlab.local/x/gitlab"
105+
}
106+
}
107+
}
108+
```
109+
81110
### Use a Remote Environment via GitPod
82111

83112
You can choose to use your own development environment if desired, however a `.gitpod.yml` file is included within the repository to allow the use of [GitPod](https://gitpod.io/) easily.

GNUmakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ reviewable: build fmt generate test ## Run before committing.
44

55
GOBIN = $(shell pwd)/bin
66
PROVIDER_SRC_DIR := ./internal/provider
7+
TERRAFORM_PLUGIN_DIR ?= ~/.terraform.d/plugins/gitlab.local/x/gitlab/99.99.99
8+
TERRAFORM_PLATFORM_DIR ?= darwin_amd64
79

810
build: ## Build the provider binary.
911
go mod tidy
1012
GOBIN=$(GOBIN) go install
1113

14+
local: build ## Build and Install the provider locally
15+
mkdir -p $(TERRAFORM_PLUGIN_DIR)/$(TERRAFORM_PLATFORM_DIR)
16+
cp -f $(GOBIN)/terraform-provider-gitlab $(TERRAFORM_PLUGIN_DIR)/$(TERRAFORM_PLATFORM_DIR)/terraform-provider-gitlab
17+
1218
generate: tool-tfplugindocs ## Generate files to be checked in.
1319
@# Setting empty environment variables to work around issue: https://github.com/hashicorp/terraform-plugin-docs/issues/12
1420
@# Setting the PATH so that tfplugindocs uses the same terraform binary as other targets here, and to resolve a "Error: Incompatible provider version" error on M1 macs.

0 commit comments

Comments
 (0)