Skip to content

Commit 5dbb021

Browse files
committed
Merge branch 'main' into 224-version-comp
2 parents f8178da + 62fa89d commit 5dbb021

File tree

21 files changed

+873
-59
lines changed

21 files changed

+873
-59
lines changed

.devcontainer/devcontainer.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "terraform-provider-coder",
3+
"image": "mcr.microsoft.com/devcontainers/go:1.22",
4+
"features": {
5+
"ghcr.io/devcontainers/features/terraform:1": {
6+
"installTerraformDocs": true
7+
}
8+
}
9+
}

.github/workflows/cla.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
steps:
1212
- name: "CLA Assistant"
1313
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
14-
uses: contributor-assistant/github-action@v2.3.2
14+
uses: contributor-assistant/github-action@v2.4.0
1515
env:
1616
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1717
# the below token should have repo scope and must be manually added by you in the repository's secret

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Set up Go
2828
uses: actions/setup-go@v5
2929
with:
30-
go-version: 1.20.6
30+
go-version: 1.22.3
3131

3232
- name: Import GPG key
3333
id: import_gpg
@@ -38,7 +38,7 @@ jobs:
3838
passphrase: ${{ secrets.PASSPHRASE }}
3939

4040
- name: Run GoReleaser
41-
uses: goreleaser/goreleaser-action@v5.0.0
41+
uses: goreleaser/goreleaser-action@v5.1.0
4242
with:
4343
version: latest
4444
args: release --rm-dist

.github/workflows/test.yml

+14-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Go
2323
uses: actions/setup-go@v5
2424
with:
25-
go-version: "1.20"
25+
go-version: "1.22"
2626
id: go
2727

2828
- name: Check out code into the Go module directory
@@ -33,9 +33,19 @@ jobs:
3333
go mod download
3434
3535
- name: Build
36+
env:
37+
CGO_ENABLED: "0"
3638
run: |
3739
go build -v .
3840
41+
- name: Run integration test
42+
timeout-minutes: 10
43+
env:
44+
CODER_IMAGE: "ghcr.io/coder/coder"
45+
CODER_VERSION: "latest"
46+
run: |
47+
go test -v ./integration
48+
3949
# run acceptance tests in a matrix with Terraform core versions
4050
test:
4151
name: Matrix Test
@@ -54,11 +64,12 @@ jobs:
5464
- "1.5.*"
5565
- "1.6.*"
5666
- "1.7.*"
67+
- "1.8.*"
5768
steps:
5869
- name: Set up Go
5970
uses: actions/setup-go@v5
6071
with:
61-
go-version: "1.20"
72+
go-version: "1.22"
6273
id: go
6374

6475
- uses: hashicorp/setup-terraform@v3
@@ -88,7 +99,7 @@ jobs:
8899
- name: Set up Go
89100
uses: actions/setup-go@v5
90101
with:
91-
go-version: "1.20"
102+
go-version: "1.22"
92103
id: go
93104

94105
- uses: hashicorp/setup-terraform@v3

Makefile

+13-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@ fmt:
66
gen:
77
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest
88

9+
build: terraform-provider-coder
10+
11+
# Builds the provider. Note that as coder/coder is based on
12+
# alpine, we need to disable cgo.
13+
terraform-provider-coder: provider/*.go main.go
14+
CGO_ENABLED=0 go build .
15+
16+
# Run integration tests
17+
.PHONY: test-integration
18+
test-integration: terraform-provider-coder
19+
go test -v ./integration
20+
921
# Run acceptance tests
1022
.PHONY: testacc
1123
testacc:
12-
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m
24+
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m

README.md

+40-11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ to setup your local Terraform to use your local version rather than the registry
2020

2121
1. Create a file named `.terraformrc` in your `$HOME` directory
2222
2. Add the following content:
23+
2324
```hcl
2425
provider_installation {
2526
# Override the coder/coder provider to use your local version
@@ -33,18 +34,46 @@ to setup your local Terraform to use your local version rather than the registry
3334
direct {}
3435
}
3536
```
37+
3638
3. (optional, but recommended) Validate your configuration:
37-
1. Create a new `main.tf` file and include:
38-
```hcl
39-
terraform {
40-
required_providers {
41-
coder = {
42-
source = "coder/coder"
43-
}
44-
}
45-
}
46-
```
39+
1. Create a new `main.tf` file and include:
40+
```hcl
41+
terraform {
42+
required_providers {
43+
coder = {
44+
source = "coder/coder"
45+
}
46+
}
47+
}
48+
```
4749
2. Run `terraform init` and observe a warning like `Warning: Provider development overrides are in effect`
4850
4. Run `go build -o terraform-provider-coder` to build the provider binary, which Terraform will try locate and execute
4951
5. All local Terraform runs will now use your local provider!
50-
6. _**NOTE**: we vendor in this provider into `github.com/coder/coder`, so if you're testing with a local clone then you should also run `go mod edit -replace github.com/coder/terraform-provider-coder=/path/to/terraform-provider-coder` in your clone._
52+
6. _**NOTE**: we vendor in this provider into `github.com/coder/coder`, so if you're testing with a local clone then you should also run `go mod edit -replace github.com/coder/terraform-provider-coder=/path/to/terraform-provider-coder` in your clone._
53+
54+
#### Terraform Acceptance Tests
55+
56+
To run Terraform acceptance tests, run `make testacc`. This will test the provider against the locally installed version of Terraform.
57+
58+
> **Note:** our [CI workflow](./github/workflows/test.yml) runs a test matrix against multiple Terraform versions.
59+
60+
#### Integration Tests
61+
62+
The tests under the `./integration` directory perform the following steps:
63+
64+
- Build the local version of the provider,
65+
- Run an in-memory Coder instance with a specified version,
66+
- Validate the behaviour of the local provider against that specific version of Coder.
67+
68+
To run these integration tests locally:
69+
70+
1. Pull the version of the Coder image you wish to test:
71+
72+
```console
73+
docker pull ghcr.io/coder/coder:main-x.y.z-devel-abcd1234
74+
```
75+
76+
1. Run `CODER_VERSION=main-x.y.z-devel-abcd1234 make test-integration`.
77+
78+
> **Note:** you can specify `CODER_IMAGE` if the Coder image you wish to test is hosted somewhere other than `ghcr.io/coder/coder`.
79+
> For example, `CODER_IMAGE=example.com/repo/coder CODER_VERSION=foobar make test-integration`.

docs/data-sources/workspace.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ resource "kubernetes_pod" "dev" {
3030
- `access_url` (String) The access URL of the Coder deployment provisioning this workspace.
3131
- `id` (String) UUID of the workspace.
3232
- `name` (String) Name of the workspace.
33-
- `owner` (String) Username of the workspace owner.
34-
- `owner_email` (String) Email address of the workspace owner.
35-
- `owner_groups` (List of String) List of groups the workspace owner belongs to.
36-
- `owner_id` (String) UUID of the workspace owner.
37-
- `owner_name` (String) Name of the workspace owner.
38-
- `owner_oidc_access_token` (String) A valid OpenID Connect access token of the workspace owner. This is only available if the workspace owner authenticated with OpenID Connect. If a valid token cannot be obtained, this value will be an empty string.
39-
- `owner_session_token` (String) Session token for authenticating with a Coder deployment. It is regenerated everytime a workspace is started.
33+
- `owner` (String, Deprecated) Username of the workspace owner.
34+
- `owner_email` (String, Deprecated) Email address of the workspace owner.
35+
- `owner_groups` (List of String, Deprecated) List of groups the workspace owner belongs to.
36+
- `owner_id` (String, Deprecated) UUID of the workspace owner.
37+
- `owner_name` (String, Deprecated) Name of the workspace owner.
38+
- `owner_oidc_access_token` (String, Deprecated) A valid OpenID Connect access token of the workspace owner. This is only available if the workspace owner authenticated with OpenID Connect. If a valid token cannot be obtained, this value will be an empty string.
39+
- `owner_session_token` (String, Deprecated) Session token for authenticating with a Coder deployment. It is regenerated everytime a workspace is started.
4040
- `start_count` (Number) A computed count based on "transition" state. If "start", count will equal 1.
4141
- `template_id` (String) ID of the workspace's template.
4242
- `template_name` (String) Name of the workspace's template.

docs/data-sources/workspace_owner.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "coder_workspace_owner Data Source - terraform-provider-coder"
4+
subcategory: ""
5+
description: |-
6+
Use this data source to fetch information about the workspace owner.
7+
---
8+
9+
# coder_workspace_owner (Data Source)
10+
11+
Use this data source to fetch information about the workspace owner.
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Read-Only
19+
20+
- `email` (String) The email address of the user.
21+
- `full_name` (String) The full name of the user.
22+
- `groups` (List of String) The groups of which the user is a member.
23+
- `id` (String) The UUID of the workspace owner.
24+
- `name` (String) The username of the user.
25+
- `oidc_access_token` (String) A valid OpenID Connect access token of the workspace owner. This is only available if the workspace owner authenticated with OpenID Connect. If a valid token cannot be obtained, this value will be an empty string.
26+
- `session_token` (String) Session token for authenticating with a Coder deployment. It is regenerated every time a workspace is started.
27+
- `ssh_private_key` (String, Sensitive) The user's generated SSH private key.
28+
- `ssh_public_key` (String) The user's generated SSH public key.

docs/data-sources/workspace_tags.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "coder_workspace_tags Data Source - terraform-provider-coder"
4+
subcategory: ""
5+
description: |-
6+
Use this data source to configure workspace tags to select provisioners.
7+
---
8+
9+
# coder_workspace_tags (Data Source)
10+
11+
Use this data source to configure workspace tags to select provisioners.
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Optional
19+
20+
- `tags` (Map of String) Key-value map with workspace tags
21+
22+
### Read-Only
23+
24+
- `id` (String) The ID of this resource.

docs/resources/metadata.md

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ data "coder_workspace" "me" {
1818
1919
resource "kubernetes_pod" "dev" {
2020
count = data.coder_workspace.me.start_count
21+
metadata {
22+
name = "k8s_example"
23+
namespace = "example"
24+
}
25+
spec {
26+
# Draw the rest of the pod!
27+
}
2128
}
2229
2330
resource "tls_private_key" "example_key_pair" {

examples/resources/coder_metadata/resource.tf

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ data "coder_workspace" "me" {
33

44
resource "kubernetes_pod" "dev" {
55
count = data.coder_workspace.me.start_count
6+
metadata {
7+
name = "k8s_example"
8+
namespace = "example"
9+
}
10+
spec {
11+
# Draw the rest of the pod!
12+
}
613
}
714

815
resource "tls_private_key" "example_key_pair" {

go.mod

+35-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
module github.com/coder/terraform-provider-coder
22

3-
go 1.20
3+
go 1.22
4+
5+
toolchain go1.22.3
46

57
require (
8+
github.com/docker/docker v26.1.4+incompatible
69
github.com/google/uuid v1.6.0
710
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
811
github.com/hashicorp/terraform-plugin-sdk/v2 v2.20.0
@@ -16,10 +19,18 @@ require (
1619
github.com/Microsoft/go-winio v0.5.2 // indirect
1720
github.com/agext/levenshtein v1.2.3 // indirect
1821
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
22+
github.com/containerd/log v0.1.0 // indirect
1923
github.com/davecgh/go-spew v1.1.1 // indirect
24+
github.com/distribution/reference v0.6.0 // indirect
25+
github.com/docker/go-connections v0.5.0 // indirect
26+
github.com/docker/go-units v0.5.0 // indirect
2027
github.com/fatih/color v1.13.0 // indirect
21-
github.com/golang/protobuf v1.5.3 // indirect
22-
github.com/google/go-cmp v0.5.9 // indirect
28+
github.com/felixge/httpsnoop v1.0.4 // indirect
29+
github.com/go-logr/logr v1.4.1 // indirect
30+
github.com/go-logr/stdr v1.2.2 // indirect
31+
github.com/gogo/protobuf v1.3.2 // indirect
32+
github.com/golang/protobuf v1.5.4 // indirect
33+
github.com/google/go-cmp v0.6.0 // indirect
2334
github.com/hashicorp/errwrap v1.1.0 // indirect
2435
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
2536
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
@@ -45,20 +56,34 @@ require (
4556
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
4657
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
4758
github.com/mitchellh/reflectwalk v1.0.2 // indirect
59+
github.com/moby/docker-image-spec v1.3.1 // indirect
60+
github.com/moby/term v0.5.0 // indirect
61+
github.com/morikuni/aec v1.0.0 // indirect
4862
github.com/oklog/run v1.0.0 // indirect
63+
github.com/opencontainers/go-digest v1.0.0 // indirect
64+
github.com/opencontainers/image-spec v1.1.0 // indirect
65+
github.com/pkg/errors v0.9.1 // indirect
4966
github.com/pmezard/go-difflib v1.0.0 // indirect
5067
github.com/rogpeppe/go-internal v1.8.0 // indirect
5168
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
5269
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
5370
github.com/vmihailenco/tagparser v0.1.1 // indirect
5471
github.com/zclconf/go-cty v1.10.0 // indirect
55-
golang.org/x/crypto v0.21.0 // indirect
56-
golang.org/x/net v0.23.0 // indirect
57-
golang.org/x/sys v0.18.0 // indirect
58-
golang.org/x/text v0.14.0 // indirect
59-
google.golang.org/appengine v1.6.7 // indirect
72+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0 // indirect
73+
go.opentelemetry.io/otel v1.27.0 // indirect
74+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 // indirect
75+
go.opentelemetry.io/otel/metric v1.27.0 // indirect
76+
go.opentelemetry.io/otel/sdk v1.27.0 // indirect
77+
go.opentelemetry.io/otel/trace v1.27.0 // indirect
78+
golang.org/x/crypto v0.23.0 // indirect
79+
golang.org/x/net v0.25.0 // indirect
80+
golang.org/x/sys v0.20.0 // indirect
81+
golang.org/x/text v0.15.0 // indirect
82+
golang.org/x/time v0.5.0 // indirect
83+
google.golang.org/appengine v1.6.8 // indirect
6084
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
61-
google.golang.org/grpc v1.56.3 // indirect
62-
google.golang.org/protobuf v1.33.0 // indirect
85+
google.golang.org/grpc v1.64.0 // indirect
86+
google.golang.org/protobuf v1.34.1 // indirect
6387
gopkg.in/yaml.v3 v3.0.1 // indirect
88+
gotest.tools/v3 v3.5.1 // indirect
6489
)

0 commit comments

Comments
 (0)