Skip to content

Conversation

brettkolodny
Copy link
Contributor

@brettkolodny brettkolodny commented Aug 27, 2025

Adds a sharing add command for sharing Workspaces with other users and groups.

The command allows sharing with multiple users, and groups within one command as well as specifying the role (use, or admin) defaulting to use if none is specified.

In the current implementation when the command completes we show the user the current state of the workspace ACL.

$ coder sharing add apricot-catfish-86 --user=member:admin --group=contractors:use
USER    GROUP        ROLE
member  -            admin
member  contractors  use

If a user is a part of multiple groups, or the workspace has been individually shared with them they will show up multiple times. Although this is a bit confusing at first glance it's important to be able to tell what the maximum role a user may have, and via what ACL they have it.


One piece of UX to consider is that in order to be able to share a Workspace with a user they must have a role that can read that user. In the tests we give the user the ScopedRoleOrgAuditor role.

Closes coder/internal#859

@brettkolodny brettkolodny marked this pull request as ready for review August 27, 2025 21:01
@brettkolodny brettkolodny force-pushed the brett/coder-sharing-share-command-859 branch from 3ff3630 to a88364c Compare August 28, 2025 13:15
@stirby
Copy link
Collaborator

stirby commented Aug 28, 2025

Let's add sharing add as an alias to sharing share. I think it's a little more intuitive and looks better.

@matifali matifali changed the title feat: add sharing share command to the CLI feat: add sharing add command to the CLI Aug 28, 2025
Copy link
Contributor

@rafrdz rafrdz left a comment

Choose a reason for hiding this comment

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

Overall looks good! Just some small requests for some validation of user input.

}

for _, user := range users {
userAndRole := nameRoleRegex.FindStringSubmatch(user)
Copy link
Contributor

Choose a reason for hiding this comment

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

In the event that this is nil can we add a check to prevent a panic?

Suggested change
userAndRole := nameRoleRegex.FindStringSubmatch(user)
userAndRole := nameRoleRegex.FindStringSubmatch(user)
if userAndRole == nil {
return xerrors.Errorf("invalid user format %q: must match pattern 'username:role'", user)
}

}

for _, group := range groups {
groupAndRole := nameRoleRegex.FindStringSubmatch(group)
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar validation question to userAndRole here

@brettkolodny brettkolodny requested a review from rafrdz September 4, 2025 20:58
@brettkolodny brettkolodny merged commit 909acbc into main Sep 4, 2025
31 checks passed
@brettkolodny brettkolodny deleted the brett/coder-sharing-share-command-859 branch September 4, 2025 21:37
@github-actions github-actions bot locked and limited conversation to collaborators Sep 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

coder sharing share command
3 participants