Skip to content

feat(coderd): add endpoints for editing and deleting organizations #13287

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 28 commits into from
May 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rework update error handling
Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
  • Loading branch information
aslilac and Emyrk authored May 17, 2024
commit f34b1eb9f4a467907cee15589e2af579e1104ebe
14 changes: 14 additions & 0 deletions coderd/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ func (api *API) patchOrganization(rw http.ResponseWriter, r *http.Request) {
UpdatedAt: dbtime.Now(),
Name: req.Name,
})
if httpapi.Is404Error(err) {
httpapi.ResourceNotFound(rw)
return
}
if database.IsUniqueViolation(err) {
httpapi.Write(ctx, rw, http.StatusConflict, codersdk.Response{
Message: "Organization already exists with that name.",
Validations: []codersdk.ValidationError{{
Field: "name",
Detail: "This value is already in use and should be unique.",
}},
})
return
}
if err != nil {
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Internal error updating organization.",
Expand Down
Loading