diff --git a/docs/resources/organization.md b/docs/resources/organization.md index 67fe4e9..c4e97ec 100644 --- a/docs/resources/organization.md +++ b/docs/resources/organization.md @@ -54,7 +54,7 @@ resource "coderd_organization" "blueberry" { ### Optional -- `default_org_member_roles` (List of String) Built-in organization role names that are unioned into every member's effective roles. Changes propagate to members on their next request. Setting any value other than the deployment defaults requires the `minimum-implicit-member` experiment to be enabled on the Coder Deployment. +- `default_org_member_roles` (Set of String) Built-in organization role names that are unioned into every member's effective roles. Changes propagate to members on their next request. Requires a Coder Deployment running v2.37.0 or later. - `description` (String) - `display_name` (String) Display name of the organization. Defaults to name. - `group_sync` (Block, Optional, Deprecated) Group sync settings to sync groups from an IdP. diff --git a/internal/provider/organization_resource.go b/internal/provider/organization_resource.go index 57371ca..4e244f4 100644 --- a/internal/provider/organization_resource.go +++ b/internal/provider/organization_resource.go @@ -8,9 +8,6 @@ import ( "regexp" "strings" - "github.com/coder/coder/v2/coderd/util/slice" - "github.com/coder/coder/v2/codersdk" - "github.com/coder/terraform-provider-coderd/internal/codersdkvalidator" "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" @@ -25,6 +22,10 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-log/tflog" + + "github.com/coder/coder/v2/coderd/util/slice" + "github.com/coder/coder/v2/codersdk" + "github.com/coder/terraform-provider-coderd/internal/codersdkvalidator" ) // Ensure provider defined types fully satisfy framework interfaces. @@ -45,7 +46,7 @@ type OrganizationResourceModel struct { Icon types.String `tfsdk:"icon"` WorkspaceSharing types.String `tfsdk:"workspace_sharing"` - DefaultOrgMemberRoles types.List `tfsdk:"default_org_member_roles"` + DefaultOrgMemberRoles types.Set `tfsdk:"default_org_member_roles"` OrgSyncIdpGroups types.Set `tfsdk:"org_sync_idp_groups"` GroupSync types.Object `tfsdk:"group_sync"` @@ -151,11 +152,10 @@ This resource is only compatible with Coder version [2.16.0](https://github.com/ }, }, - "default_org_member_roles": schema.ListAttribute{ + "default_org_member_roles": schema.SetAttribute{ ElementType: types.StringType, MarkdownDescription: "Built-in organization role names that are unioned into every member's effective roles. " + - "Changes propagate to members on their next request. Setting any value other than the deployment defaults " + - "requires the `minimum-implicit-member` experiment to be enabled on the Coder Deployment.", + "Changes propagate to members on their next request. Requires a Coder Deployment running v2.37.0 or later.", Optional: true, Computed: true, }, @@ -856,11 +856,11 @@ func isWorkspaceSharingExperimentOff(err error) bool { } // defaultOrgMemberRolesValueFromAPI converts the API's []string into a -// types.List[string]. A nil slice from an older server is treated as an -// empty list so the attribute always has a known value. -func defaultOrgMemberRolesValueFromAPI(ctx context.Context, roles []string) (types.List, diag.Diagnostics) { +// types.Set[string]. A nil slice from an older server is treated as an +// empty set so the attribute always has a known value. +func defaultOrgMemberRolesValueFromAPI(ctx context.Context, roles []string) (types.Set, diag.Diagnostics) { if roles == nil { roles = []string{} } - return types.ListValueFrom(ctx, types.StringType, roles) + return types.SetValueFrom(ctx, types.StringType, roles) } diff --git a/internal/provider/organization_resource_test.go b/internal/provider/organization_resource_test.go index 98ac968..28a1258 100644 --- a/internal/provider/organization_resource_test.go +++ b/internal/provider/organization_resource_test.go @@ -25,7 +25,7 @@ func TestAccOrganizationResource(t *testing.T) { } ctx := t.Context() - client := integration.StartCoder(ctx, t, "organization_acc", integration.UseLicense, integration.CoderExperiments("workspace-sharing,minimum-implicit-member")) + client := integration.StartCoder(ctx, t, "organization_acc", integration.UseLicense, integration.CoderExperiments("workspace-sharing")) _, err := client.User(ctx, codersdk.Me) require.NoError(t, err) runOrganizationResourceTest(t, client, true) @@ -187,7 +187,7 @@ func runOrganizationResourceTest(t *testing.T, client *codersdk.Client, enableEx resource.TestStep{ Config: cfg8.String(t), ConfigStateChecks: []statecheck.StateCheck{ - statecheck.ExpectKnownValue("coderd_organization.test", tfjsonpath.New("default_org_member_roles"), knownvalue.ListExact([]knownvalue.Check{ + statecheck.ExpectKnownValue("coderd_organization.test", tfjsonpath.New("default_org_member_roles"), knownvalue.SetExact([]knownvalue.Check{ knownvalue.StringExact("organization-template-admin"), knownvalue.StringExact("organization-workspace-access"), })),