Skip to content

feat: add default_org_member_roles to coderd_organization - #355

Merged
Emyrk merged 2 commits into
mainfrom
feat/org-default-member-roles
Sep 10, 2026
Merged

Emyrk merged 2 commits into
mainfrom
feat/org-default-member-roles

Conversation

@Emyrk

@Emyrk Emyrk commented Jun 5, 2026

Copy link
Copy Markdown
Member

Refs PLAT-217, depends on coder/coder#25994.

Adds a default_org_member_roles set attribute to coderd_organization so callers can override the deployment-wide default member roles per organization.

  • New attribute is Optional + Computed; omitting it leaves the deployment defaults in place.
  • Create flow follows the workspace_sharing precedent: post-create UpdateOrganization PATCH when the user provides a value, since CreateOrganization doesn't accept the field.
  • Update flow plumbs the value through the existing UpdateOrganization call as a *[]string so an unset attribute does not overwrite server state.
  • Bumps coder/coder to a SHA on the gateway-accounts stack and reacts to feat!: patchTemplateMeta to use optional fields coder#24984, which migrated UpdateTemplateMeta fields from values to optional pointers.
Agent context
  • internal/provider/organization_resource.go: new field on the resource model and schema, plus a defaultOrgMemberRolesValueFromAPI helper that maps a nil slice to an empty set so the attribute always has a known value.
  • internal/provider/organization_resource_test.go: new acceptance step under enableExperimentalSteps that sets the field to ["organization-member", "organization-template-admin"] and asserts state. The happy-path test now enables the minimum-implicit-member experiment alongside workspace-sharing since the server gates non-default values behind it.
  • internal/provider/template_resource.go and internal/provider/template_data_source_test.go: react to feat!: patchTemplateMeta to use optional fields coder#24984's pointer migration on UpdateTemplateMeta. Mechanical conversions: .ValueString() becomes .ValueStringPointer() etc., and bool literals get wrapped with ptr.Ref(...).
  • docs/resources/organization.md: regenerated via make gen.

Coder Agents on behalf of @Emyrk.

@linear-code

linear-code Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

PLAT-217

DOCS-464

@Emyrk
Emyrk force-pushed the feat/org-default-member-roles branch from 979b9c7 to 9a54ce7 Compare June 5, 2026 14:53
@Emyrk
Emyrk marked this pull request as ready for review July 22, 2026 19:21
Adds a new `default_org_member_roles` set attribute to the `coderd_organization`
resource so callers can override the deployment-wide default member roles per
organization. The attribute is set after `CreateOrganization` (the create
endpoint doesn't accept it) and through `UpdateOrganization` thereafter.

Also bumps coder/coder to a SHA that contains the gateway-accounts stack
(coder/coder#25994) and reacts to coder/coder#24984, which migrated
UpdateTemplateMeta fields from values to optional pointers.
@Emyrk
Emyrk force-pushed the feat/org-default-member-roles branch from 9a54ce7 to 614984d Compare July 22, 2026 19:27
…e split

"organization-member" is now the implicit floor role and no longer an
assignable built-in, and rbac.DefaultOrgMemberRoles() is
["organization-workspace-access"]. Use organization-template-admin +
organization-workspace-access as the non-default test value.
@Emyrk
Emyrk merged commit 87f6ed8 into main Sep 10, 2026
13 checks passed
@Emyrk
Emyrk deleted the feat/org-default-member-roles branch September 10, 2026 14:59
},
},

"default_org_member_roles": schema.ListAttribute{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a List and not a Set?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set makes sense 👍

Will fix

"requires the `minimum-implicit-member` experiment to be enabled on the Coder Deployment.",
Optional: true,
Computed: true,
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a validator

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethanndickson do you mean to validate the role names are valid?

At present we only support built in role names. So I can add this if you feel strongly.

If we add custom role support, then validating would be a lot more tricky.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't think the session token from the provider block is available to us in the validator, so custom role validation is maybe impossible

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will covo move to the other PR

ethanndickson added a commit that referenced this pull request Sep 14, 2026
…anization test (#435)

`main` has failed lint since #355 merged (`87f6ed8`):

```
internal/provider/organization_resource_test.go:169:35: undefined: ptr (typecheck)
```

#355 was last tested in July against a base where
`organization_resource_test.go` still imported `coderd/util/ptr` and
used `ptr.Ref(...)` throughout. In the meantime #422 replaced every
`ptr.Ref(...)` in that file with `new(...)` and dropped the import. The
squash-merge had no textual conflict, so it landed with one new
`ptr.Ref(...)` line and no `ptr` import. #434 then inherited the red
`main`.

This switches the one remaining `ptr.Ref([]string{...})` to
`new([]string{...})`, matching the rest of the file.

Also adds a `.github/CODEOWNERS` with `* @ethanndickson`.
ethanndickson added a commit that referenced this pull request Sep 15, 2026
<!-- Coder Agents on behalf of @Emyrk. -->

Followup to
#355 (comment).

Change `default_org_member_roles` on `coderd_organization` from a list
to a set.

- Duplicate role names have no meaning, and ordering does not matter.
- Replaces the `minimum-implicit-member` experiment note in the
attribute description with "Requires a Coder Deployment running v2.37.0
or later." The experiment was promoted to GA and removed in
coder/coder#27472, first shipped in v2.37.0.
- Drops `minimum-implicit-member` from the acceptance test's
`CoderExperiments(...)` list, since Coder v2.37.0+ no longer recognises
it.
- Existing state migrates in place; Terraform converts list-of-string to
set-of-string without a schema version bump.

---

<sub>Coder Agents on behalf of @Emyrk.</sub>

---------

Co-authored-by: Ethan Dickson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants