Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: coder/terraform-provider-coderd
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.1
Choose a base ref
...
head repository: coder/terraform-provider-coderd
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
Showing with 5,078 additions and 1,017 deletions.
  1. +0 −27 .github/workflows/cla.yaml
  2. +29 −30 .github/workflows/release.yml
  3. +31 −18 .github/workflows/test.yml
  4. +7 −0 .gitignore
  5. +12 −6 .golangci.yml
  6. +8 −1 Makefile
  7. +1 −1 README.md
  8. +34 −4 docs/data-sources/group.md
  9. +24 −1 docs/data-sources/organization.md
  10. +66 −0 docs/data-sources/template.md
  11. +25 −4 docs/data-sources/user.md
  12. +69 −4 docs/index.md
  13. +24 −3 docs/resources/group.md
  14. +41 −0 docs/resources/license.md
  15. +103 −0 docs/resources/organization.md
  16. +47 −0 docs/resources/organization_sync_settings.md
  17. +29 −0 docs/resources/provisioner_key.md
  18. +45 −12 docs/resources/template.md
  19. +22 −3 docs/resources/user.md
  20. +33 −2 docs/resources/workspace_proxy.md
  21. +28 −0 examples/data-sources/coderd_group/data-source.tf
  22. +20 −0 examples/data-sources/coderd_organization/data-source.tf
  23. +21 −0 examples/data-sources/coderd_template/data-source.tf
  24. +19 −0 examples/data-sources/coderd_user/data-source.tf
  25. +59 −0 examples/provider/provider.tf
  26. +11 −0 examples/resources/coderd_group/import.sh
  27. +7 −0 examples/resources/coderd_license/resource.tf
  28. +11 −0 examples/resources/coderd_organization/import.sh
  29. +25 −0 examples/resources/coderd_organization/resource.tf
  30. +11 −0 examples/resources/coderd_organization_sync_settings/resource.tf
  31. +15 −0 examples/resources/coderd_template/import.sh
  32. +11 −4 examples/resources/coderd_template/resource.tf
  33. +11 −0 examples/resources/coderd_user/import.sh
  34. +1 −0 examples/resources/coderd_user/resource.tf
  35. +28 −0 examples/resources/coderd_workspace_proxy/resource.tf
  36. +148 −98 go.mod
  37. +436 −304 go.sum
  38. +5 −5 integration/integration.go
  39. +7 −4 integration/integration_test.go
  40. +10 −0 internal/codersdkvalidator/display_name.go
  41. +10 −0 internal/codersdkvalidator/group_name.go
  42. +10 −0 internal/codersdkvalidator/name.go
  43. +16 −0 internal/codersdkvalidator/regex.go
  44. +10 −0 internal/codersdkvalidator/template_version_name.go
  45. +10 −0 internal/codersdkvalidator/user_real_name.go
  46. +51 −0 internal/codersdkvalidator/validator_from_func.go
  47. +27 −22 internal/provider/group_data_source.go
  48. +8 −7 internal/provider/group_data_source_test.go
  49. +46 −16 internal/provider/group_resource.go
  50. +27 −18 internal/provider/group_resource_test.go
  51. +198 −0 internal/provider/license_resource.go
  52. +74 −0 internal/provider/license_resource_test.go
  53. +15 −0 internal/provider/organization_data_source.go
  54. +9 −8 internal/provider/organization_data_source_test.go
  55. +652 −0 internal/provider/organization_resource.go
  56. +219 −0 internal/provider/organization_resource_test.go
  57. +258 −0 internal/provider/organization_sync_settings_resource.go
  58. +125 −0 internal/provider/organization_sync_settings_resource_test.go
  59. +20 −5 internal/provider/provider.go
  60. +1 −0 internal/provider/provider_test.go
  61. +154 −0 internal/provider/provisioner_key_resource.go
  62. +114 −0 internal/provider/provisioner_key_resource_test.go
  63. +89 −7 internal/provider/template_data_source.go
  64. +43 −17 internal/provider/template_data_source_test.go
  65. +365 −100 internal/provider/template_resource.go
  66. +789 −202 internal/provider/template_resource_test.go
  67. +7 −8 internal/provider/user_data_source.go
  68. +26 −4 internal/provider/user_data_source_test.go
  69. +69 −19 internal/provider/user_resource.go
  70. +36 −12 internal/provider/user_resource_test.go
  71. +27 −10 internal/provider/util.go
  72. +10 −10 internal/provider/uuid.go
  73. +9 −8 internal/provider/uuid_internal_test.go
  74. +6 −1 internal/provider/workspace_proxy_resource.go
  75. +14 −12 internal/provider/workspace_proxy_resource_test.go
27 changes: 0 additions & 27 deletions .github/workflows/cla.yaml

This file was deleted.

59 changes: 29 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
name: release

on:
push:
tags:
- 'v*'
push:
tags:
- "v*"

permissions:
contents: write
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Unshallow
run: git fetch --prune --unshallow
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22.4
- name: Import GPG Key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6.1.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6.0.0
with:
version: latest
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Unshallow
run: git fetch --prune --unshallow
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version: "1.22"
- name: Import GPG Key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
with:
version: latest
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 changes: 31 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -24,31 +24,42 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: "go.mod"
cache: true

- run: go mod download

- run: go build -v .

- name: Run linters
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@2226d7cb06a077cd73e56eedd38eecad18e5d837 # v6.5.0
with:
version: latest

generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: "go.mod"
cache: true

- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2

- run: go generate ./...

- name: git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
if [[ -n $(git ls-files --other --modified --exclude-standard) ]]; then
echo "Unexpected difference in directories after code generation. Run 'make gen' and include the output in the commit."
exit 1
fi
# Run acceptance tests in a matrix with Terraform CLI versions
test:
@@ -72,41 +83,43 @@ jobs:
- "1.8.*"
- "1.9.*"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: "go.mod"
cache: true
- uses: hashicorp/setup-terraform@v3

- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false

- run: go mod download
- env:

- run: go test -v -cover ./internal/provider/
env:
TF_ACC: "1"
CODER_ENTERPRISE_LICENSE: ${{ secrets.CODER_ENTERPRISE_LICENSE }}
run: go test -v -cover ./internal/provider/
timeout-minutes: 10

lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Set up Go
uses: actions/setup-go@v5
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version: "1.22"
id: go

- uses: hashicorp/setup-terraform@v3
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: "1.9.*"
terraform_wrapper: false

- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Get dependencies
run: |
go mod download
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -39,3 +39,10 @@ terraform-provider-coderd
integration/integration.tfrc

*.tfstate

# Local .terraform directories
**/.terraform/*


# Ignore transient lock info files created by terraform apply
.terraform.tfstate.lock.info
18 changes: 12 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
# Visit https://golangci-lint.run/ for usage documentation
# and information on other useful linters
# Visit https://golangci-lint.run/ for usage documentation and information on
# other useful linters
issues:
max-per-linter: 0
max-issues-per-linter: 0
max-same-issues: 0

linters:
disable-all: true
enable:
- durationcheck
- errcheck
- exportloopref
- forcetypeassert
- godot
- gofmt
- gosimple
- govet
- ineffassign
- makezero
- misspell
- nilerr
- paralleltest
- predeclared
- staticcheck
- tenv
- unconvert
- unparam
- unused
- vet
- usetesting

linters-settings:
paralleltest:
# Terraform acceptance subtests all share a Coder instance, and cannot run
# in parallel.
ignore-missing-subtests: true
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
default: testacc

fmt:
go fmt ./...
terraform fmt -recursive

lint:
golangci-lint run ./...

gen:
go generate ./...

@@ -11,7 +15,10 @@ build: terraform-provider-coderd
terraform-provider-coderd: internal/provider/*.go main.go
CGO_ENABLED=0 go build .

test: testacc
.PHONY: test

# Run acceptance tests
.PHONY: testacc
testacc:
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m
.PHONY: testacc
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ The provider currently supports resources and data sources for:
- Templates + Template Versions
- Groups
- Workspace Proxies
- Organizations (Data Source only)
- Organizations

## Requirements

38 changes: 34 additions & 4 deletions docs/data-sources/group.md
Original file line number Diff line number Diff line change
@@ -10,7 +10,38 @@ description: |-

An existing group on the Coder deployment.

## Example Usage

```terraform
// Get a group on the provider default organization by `id`
data "coderd_group" "employees" {
id = "abcd-efg-hijk"
}
// Get a group on the provider default organization by `name` + `organization_id`
data "coderd_group" "bosses" {
name = "bosses"
}
// Use them to apply ACL to a template
resource "coderd_template" "example" {
name = "example-template"
versions = [/* ... */]
acl = {
groups = [
{
id = data.coderd_group.employees.id
role = "use"
},
{
id = data.coderd_group.bosses.id
role = "admin"
}
]
users = []
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema
@@ -27,7 +58,7 @@ An existing group on the Coder deployment.
- `display_name` (String)
- `members` (Attributes Set) Members of the group. (see [below for nested schema](#nestedatt--members))
- `quota_allowance` (Number) The number of quota credits to allocate to each user in the group.
- `source` (String) The source of the group. Either 'oidc' or 'user'.
- `source` (String) The source of the group. Either `oidc` or `user`.

<a id="nestedatt--members"></a>
### Nested Schema for `members`
@@ -38,7 +69,6 @@ Read-Only:
- `email` (String)
- `id` (String)
- `last_seen_at` (Number) Unix timestamp of when the member was last seen.
- `login_type` (String) The login type of the member. Can be 'oidc', 'token', 'password', 'github' or 'none'.
- `status` (String) The status of the member. Can be 'active', 'dormant' or 'suspended'.
- `theme_preference` (String)
- `login_type` (String) The login type of the member. Can be `oidc`, `token`, `password`, `github` or `none`.
- `status` (String) The status of the member. Can be `active`, `dormant` or `suspended`.
- `username` (String)
25 changes: 24 additions & 1 deletion docs/data-sources/organization.md
Original file line number Diff line number Diff line change
@@ -15,7 +15,30 @@ An existing organization on the Coder deployment.
~> **Warning**
This data source is only compatible with Coder version [2.13.0](https://github.com/coder/coder/releases/tag/v2.13.0) and later.


## Example Usage

```terraform
// Get the default (first) organization for the coder deployment
data "coderd_organization" "default" {
is_default = true
}
// Get another organization by `id`
data "coderd_organization" "example" {
id = "abcd-efg-hijk"
}
// Or get by name
data "coderd_organization" "example2" {
name = "example-organization-2"
}
// Create a group on a specific organization
resource "coderd_group" "example" {
name = "example-group"
organization_id = data.coderd_organization.example.id
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Loading