Skip to content

Conversation

@geokat
Copy link

@geokat geokat commented Jan 21, 2026

This PR also:

  • Adds it to the coderd_organization data source
  • Adds an option to the test harness to test against features gated by experiments (enabled via the CODER_EXPERIMENTS env var)
  • Upgrades the slog dependency (cdr.dev/slog -> cdr.dev/slog/v3)

NOTE: Draft PR: depends on unreleased Coder changes, so this uses a commit‑pinned github.com/coder/coder/v2 version until the next tag.

Related to: coder/internal#1245

- Also adds it to the coderd_organization data source
- Also adds an option to the test harness to test against features
  gated by experiments (enabled via the CODER_EXPERIMENTS env var)

Related to: coder/internal#1245
@geokat geokat linked an issue Jan 21, 2026 that may be closed by this pull request
@geokat geokat requested a review from aslilac January 21, 2026 20:58
Copy link
Member

@aslilac aslilac left a comment

Choose a reason for hiding this comment

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

one small thing but otherwise looks great!

MarkdownDescription: "Workspace sharing setting for the organization. " +
"Valid values are `everyone` and `none`.",
Optional: true,
Computed: true,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Computed: true,

I don't think this is computed on the resource. there's no code to read this value, just to update it.

Copy link
Author

Choose a reason for hiding this comment

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

We do read it back and set in state in Read/Create/Update. Since the backend always has a value (default
even if unset), we mark it as computed so state reflects the server state when users don’t configure it.
Is this the wrong approach?

Copy link
Member

@ethanndickson ethanndickson Jan 23, 2026

Choose a reason for hiding this comment

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

Since the backend always has a value (default even if unset), we mark it as computed so state reflects the server state when users don’t configure it.

Yep, this is correct. It's the same deal for a lot of the optional attributes in the template resource.
A good example ismax_port_share_level, another enum.

Comment on lines +448 to +452
workspaceSharingSettings, err := r.Client.WorkspaceSharingSettings(ctx, orgID.String())
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to get workspace sharing settings, got error: %s", err))
return
}
Copy link
Member

Choose a reason for hiding this comment

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

It looks like we're calling this new workspace sharing route unconditionally - won't this break the resource on Coder deployments that don't have the experiment enabled?

Even once workspace sharing is no longer an experiment, we still need to support Coder deployments running (I think up to 3?) older versions.

Copy link
Author

Choose a reason for hiding this comment

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

It looks like we're calling this new workspace sharing route unconditionally - won't this break the resource on Coder deployments that don't have the experiment enabled?

I wasn't sure how we handle situations like this, so I planned to only merge it once workspace sharing is no longer an experiment. Was this the wrong approach?

Even once workspace sharing is no longer an experiment, we still need to support Coder deployments running (I think up to 3?) older versions.

Great catch, I didn't know about this!

Copy link
Member

@ethanndickson ethanndickson Jan 23, 2026

Choose a reason for hiding this comment

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

I wasn't sure how we handle situations like this,

Yeah, unfortunately I don't think we have any existing code that's conditionally run depending on the Coder version, just some resources that we say in the docs aren't usable unless your Coder deployment is recent enough.

We do have entitlement checks for some resources though (TemplateResourceModel.CheckEntitlements()), so you might want to do something like that.

Off the top of my head I think we'd be fine to just always try and hit the route, not report an error if it's a 404, and set the attribute to a known null when that happens?

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.

Add coderd_organization.workspace_sharing attribute

3 participants