Skip to content

Commit b0e9236

Browse files
feat: Environments
1 parent f30e16e commit b0e9236

19 files changed

+1396
-686
lines changed

.env.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Required environment variables for running acceptance tests
2+
CTRLPLANE_PROVIDER_TESTING_API_KEY=your_api_key_here
3+
CTRLPLANE_PROVIDER_TESTING_WORKSPACE=your_workspace_here
4+
CTRLPLANE_PROVIDER_TESTING_BASE_URL=https://app.ctrlplane.com
5+
6+
# Test configuration
7+
TF_ACC=1 # Required for running acceptance tests
8+
TF_LOG=DEBUG # Optional: Set to DEBUG for verbose logging during tests
9+
TF_LOG_PATH=./terraform.log # Optional: Log file path for test output
10+
11+
# Go test configuration
12+
GO_TEST_TIMEOUT=120m # Test timeout duration
13+
GO_TEST_PARALLEL=4 # Number of parallel tests to run
14+
15+
# Optional test configuration
16+
TF_ACC=1 # Set to 1 to run acceptance tests
17+
TF_LOG=INFO # Set to DEBUG for verbose logging during tests

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ website/vendor
3333

3434
# Keep windows files with windows line endings
3535
*.winfile eol=crlf
36+
37+
.env

GNUmakefile

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,37 @@ lint:
1212
generate:
1313
cd tools; go generate ./...
1414

15+
generate-client:
16+
cd client; go generate ./...
17+
1518
fmt:
1619
gofmt -s -w -e .
1720

1821
test:
1922
go test -v -cover -timeout=120s -parallel=10 ./...
2023

2124
testacc:
22-
TF_ACC=1 go test -v -cover -timeout 120m ./...
23-
24-
test-acceptance:
25+
@if [ ! -f .env ]; then \
26+
echo "Error: .env file not found. Copy .env.example to .env and configure it."; \
27+
exit 1; \
28+
fi
29+
@echo "Running acceptance tests..."
30+
source .env && \
2531
TF_ACC=1 \
26-
CTRLPLANE_TOKEN=$(CTRLPLANE_PROVIDER_TESTING_API_KEY) \
27-
CTRLPLANE_WORKSPACE=$(CTRLPLANE_PROVIDER_TESTING_WORKSPACE) \
28-
go test -v -cover -timeout 120m ./...
29-
30-
.PHONY: fmt lint test testacc build install generate
32+
CTRLPLANE_TOKEN="$${CTRLPLANE_PROVIDER_TESTING_API_KEY}" \
33+
CTRLPLANE_WORKSPACE="$${CTRLPLANE_PROVIDER_TESTING_WORKSPACE}" \
34+
CTRLPLANE_BASE_URL="$${CTRLPLANE_PROVIDER_TESTING_BASE_URL}" \
35+
go test -v \
36+
-timeout=$${GO_TEST_TIMEOUT:-120m} \
37+
-parallel=$${GO_TEST_PARALLEL:-4} \
38+
-cover \
39+
./internal/provider/...
40+
41+
# Clean test artifacts
42+
clean:
43+
rm -f terraform.log
44+
rm -rf .terraform
45+
rm -f .terraform.lock.hcl
46+
rm -f terraform.tfstate*
47+
48+
.PHONY: fmt lint test testacc build install generate clean install-local

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
_This template repository is built on the [Terraform Plugin Framework](https://github.com/hashicorp/terraform-plugin-framework). The template repository built on the [Terraform Plugin SDK](https://github.com/hashicorp/terraform-plugin-sdk) can be found at [terraform-provider-scaffolding](https://github.com/hashicorp/terraform-provider-scaffolding). See [Which SDK Should I Use?](https://developer.hashicorp.com/terraform/plugin/framework-benefits) in the Terraform documentation for additional information._
44

5-
This repository is a *template* for a [Terraform](https://www.terraform.io) provider. It is intended as a starting point for creating Terraform providers, containing:
5+
This repository is a _template_ for a [Terraform](https://www.terraform.io) provider. It is intended as a starting point for creating Terraform providers, containing:
66

77
- A resource and a data source (`internal/provider/`),
88
- Examples (`examples/`) and generated documentation (`docs/`),
@@ -57,7 +57,15 @@ To generate or update documentation, run `make generate`.
5757

5858
In order to run the full suite of Acceptance tests, run `make testacc`.
5959

60-
*Note:* Acceptance tests create real resources, and often cost money to run.
60+
_Note:_ Acceptance tests create real resources, and often cost money to run.
61+
62+
Create a `.env` file with the following environment variables:
63+
64+
```shell
65+
CTRLPLANE
66+
CTRLPLANE_PROVIDER_TESTING_API_KEY=your_token_here
67+
CTRLPLANE_PROVIDER_TESTING_WORKSPACE=your_workspace_here
68+
```
6169

6270
```shell
6371
make testacc

0 commit comments

Comments
 (0)