Skip to content

Commit ca63b7c

Browse files
committed
org_sync_idp_groups
1 parent 8733bb5 commit ca63b7c

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

docs/resources/organization.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ description: |-
1212

1313
An organization on the Coder deployment.
1414

15-
~> **Warning**
16-
This resource is only compatible with Coder version [2.16.0](https://github.com/coder/coder/releases/tag/v2.16.0) and later.
15+
~> **Warning** This resource is only compatible with Coder version [2.16.0](https://github.com/coder/coder/releases/tag/v2.16.0) and later.
1716

1817
## Example Usage
1918

@@ -24,7 +23,7 @@ resource "coderd_organization" "blueberry" {
2423
description = "The organization for blueberries"
2524
icon = "/emojis/1fad0.png"
2625
27-
sync_mapping = [
26+
org_sync_idp_groups = [
2827
"wibble",
2928
"wobble",
3029
]
@@ -46,6 +45,7 @@ resource "coderd_organization" "blueberry" {
4645
```
4746

4847
<!-- schema generated by tfplugindocs -->
48+
4949
## Schema
5050

5151
### Required
@@ -59,13 +59,14 @@ resource "coderd_organization" "blueberry" {
5959
- `group_sync` (Block, Optional) Group sync settings to sync groups from an IdP. (see [below for nested schema](#nestedblock--group_sync))
6060
- `icon` (String)
6161
- `role_sync` (Block, Optional) Role sync settings to sync organization roles from an IdP. (see [below for nested schema](#nestedblock--role_sync))
62-
- `sync_mapping` (Set of String) Claims from the IdP provider that will give users access to this organization.
62+
- `org_sync_idp_groups` (Set of String) Claims from the IdP provider that will give users access to this organization.
6363

6464
### Read-Only
6565

6666
- `id` (String) Organization ID
6767

6868
<a id="nestedblock--group_sync"></a>
69+
6970
### Nested Schema for `group_sync`
7071

7172
Optional:
@@ -75,8 +76,8 @@ Optional:
7576
- `mapping` (Map of List of String) A map from OIDC group name to Coder group ID.
7677
- `regex_filter` (String) A regular expression that will be used to filter the groups returned by the OIDC provider. Any group not matched will be ignored.
7778

78-
7979
<a id="nestedblock--role_sync"></a>
80+
8081
### Nested Schema for `role_sync`
8182

8283
Optional:
@@ -93,6 +94,7 @@ Import is supported using the following syntax:
9394
# or the name of the organization.
9495
$ terraform import coderd_organization.our_org our-org
9596
```
97+
9698
Alternatively, in Terraform v1.5.0 and later, an [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used:
9799

98100
```terraform

examples/resources/coderd_organization/resource.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ resource "coderd_organization" "blueberry" {
44
description = "The organization for blueberries"
55
icon = "/emojis/1fad0.png"
66

7-
sync_mapping = [
7+
org_sync_idp_groups = [
88
"wibble",
99
"wobble",
1010
]

internal/provider/organization_resource.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type OrganizationResourceModel struct {
4141
Description types.String `tfsdk:"description"`
4242
Icon types.String `tfsdk:"icon"`
4343

44-
SyncMapping types.Set `tfsdk:"sync_mapping"`
44+
SyncMapping types.Set `tfsdk:"org_sync_idp_groups"`
4545
GroupSync types.Object `tfsdk:"group_sync"`
4646
RoleSync types.Object `tfsdk:"role_sync"`
4747
}
@@ -137,7 +137,7 @@ This resource is only compatible with Coder version [2.16.0](https://github.com/
137137
Default: stringdefault.StaticString(""),
138138
},
139139

140-
"sync_mapping": schema.SetAttribute{
140+
"org_sync_idp_groups": schema.SetAttribute{
141141
ElementType: types.StringType,
142142
Optional: true,
143143
MarkdownDescription: "Claims from the IdP provider that will give users access to this organization.",

internal/provider/organization_resource_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ func TestAccOrganizationResource(t *testing.T) {
9696
{
9797
Config: cfg3.String(t),
9898
ConfigStateChecks: []statecheck.StateCheck{
99-
statecheck.ExpectKnownValue("coderd_organization.test", tfjsonpath.New("sync_mapping").AtSliceIndex(0), knownvalue.StringExact("wibble")),
100-
statecheck.ExpectKnownValue("coderd_organization.test", tfjsonpath.New("sync_mapping").AtSliceIndex(1), knownvalue.StringExact("wobble")),
99+
statecheck.ExpectKnownValue("coderd_organization.test", tfjsonpath.New("org_sync_idp_groups").AtSliceIndex(0), knownvalue.StringExact("wibble")),
100+
statecheck.ExpectKnownValue("coderd_organization.test", tfjsonpath.New("org_sync_idp_groups").AtSliceIndex(1), knownvalue.StringExact("wobble")),
101101
},
102102
},
103103
// Patch org sync
104104
{
105105
Config: cfg4.String(t),
106106
ConfigStateChecks: []statecheck.StateCheck{
107-
statecheck.ExpectKnownValue("coderd_organization.test", tfjsonpath.New("sync_mapping").AtSliceIndex(0), knownvalue.StringExact("wibbley")),
108-
statecheck.ExpectKnownValue("coderd_organization.test", tfjsonpath.New("sync_mapping").AtSliceIndex(1), knownvalue.StringExact("wobbley")),
107+
statecheck.ExpectKnownValue("coderd_organization.test", tfjsonpath.New("org_sync_idp_groups").AtSliceIndex(0), knownvalue.StringExact("wibbley")),
108+
statecheck.ExpectKnownValue("coderd_organization.test", tfjsonpath.New("org_sync_idp_groups").AtSliceIndex(1), knownvalue.StringExact("wobbley")),
109109
},
110110
},
111111
// Add group and role sync
@@ -152,7 +152,7 @@ resource "coderd_organization" "test" {
152152
icon = {{orNull .Icon}}
153153
154154
{{- if .SyncMapping}}
155-
sync_mapping = [
155+
org_sync_idp_groups = [
156156
{{- range $name := .SyncMapping }}
157157
"{{$name}}",
158158
{{- end}}

internal/provider/organization_sync_settings_resource.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func (r *OrganizationSyncSettingsResource) Delete(ctx context.Context, req resou
244244
tflog.Trace(ctx, "deleting organization sync", map[string]any{})
245245
_, err := r.Client.PatchOrganizationIDPSyncConfig(ctx, codersdk.PatchOrganizationIDPSyncConfigRequest{
246246
// This disables organization sync without causing state conflicts for
247-
// organization resources that might still specify `sync_mapping`.
247+
// organization resources that might still specify `org_sync_idp_groups`.
248248
Field: "",
249249
})
250250
if err != nil {

0 commit comments

Comments
 (0)