Skip to content

chore!: allow CreateUser to accept multiple organizations #14383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 23, 2024

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Aug 21, 2024

In a multi-org deployment, it makes more sense to allow for multiple
org memberships to be assigned at create. The legacy param will still
be honored via the api.

This is to prepare for organization sync, a feature that requires creating a user with multiple orgs. Organization sync also introduces the possibility of a user having 0 orgs.

Breaking change

codersdk.CreateUserRequest no longer accepts the field OrganizationID in Go. There is no way to make this backwards compatible in Go, because the previous value would assume no value == default org. This would have to be changed to a *uuid.UUID to detect the zero value vs not setting it. Which would also be a breaking change.

Just made a new cli function and type. We should delete the deprecated methods in the future.

From an API POV (eg typescript), this is backwards compatible via the custom UnmarshalJSON function:

func (r *CreateUserRequest) UnmarshalJSON(data []byte) error {

@Emyrk Emyrk changed the title chore: allow CreateUser to accept multiple organizations chore!: allow CreateUser to accept multiple organizations Aug 21, 2024
@Emyrk Emyrk marked this pull request as ready for review August 21, 2024 16:10
@Emyrk Emyrk added the release/breaking This label is applied to PRs to detect breaking changes as part of the release process label Aug 21, 2024
@Emyrk Emyrk requested a review from f0ssel August 21, 2024 18:10
@Emyrk Emyrk force-pushed the stevenmasley/create_user_multi_org branch from 79eb9fa to c8e4bdc Compare August 22, 2024 16:15
@Emyrk Emyrk force-pushed the stevenmasley/create_user_multi_org branch from c8e4bdc to a8fcd42 Compare August 22, 2024 21:15
Copy link
Contributor

@f0ssel f0ssel left a comment

Choose a reason for hiding this comment

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

Unfortunate about the break change, do we have a plan for how to communicate this on release?

Comment on lines +389 to +401
if len(req.OrganizationIDs) == 0 {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
Message: "No organization specified to place the user as a member of. It is required to specify at least one organization id to place the user in.",
Detail: "required at least 1 value for the array 'organization_ids'",
Validations: []codersdk.ValidationError{
{
Field: "organization_ids",
Detail: "Missing values, this cannot be empty",
},
},
})
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify, when creating a user they must be in at least 1 org, but later on it's possible to remove them and they have 0 orgs. What is the limitation requiring an org on creation? Just more UI work?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is correct. There is no limitation, just UX work. This was the existing constraint, and I did not want to change it yet. It'll have to change before multi-org goes live though.

@Emyrk
Copy link
Member Author

Emyrk commented Aug 23, 2024

Unfortunate about the break change, do we have a plan for how to communicate this on release?

I don't have a great idea. From an API view, all will still work. It's a codersdk breaking change.

@bpmct do we know how many users are using our sdk?

@Emyrk
Copy link
Member Author

Emyrk commented Aug 23, 2024

@bpmct mentioned the SDK is used externally. Maybe I can make a new sdk function and deprecate the old. So it will work in the interim. I will spend some thought on this before I merge

* Handle sdk deprecation better by maintaining cli functions
@Emyrk Emyrk enabled auto-merge (squash) August 23, 2024 20:59
@Emyrk Emyrk merged commit c8eacc6 into main Aug 23, 2024
33 of 34 checks passed
@Emyrk Emyrk deleted the stevenmasley/create_user_multi_org branch August 23, 2024 21:23
@github-actions github-actions bot locked and limited conversation to collaborators Aug 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release/breaking This label is applied to PRs to detect breaking changes as part of the release process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants