Skip to content

chore(coderd): allow creating workspaces without specifying an organization #14048

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 8 commits into from
Jul 30, 2024
Merged
Changes from 1 commit
Commits
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
structs 4 u
  • Loading branch information
aslilac committed Jul 30, 2024
commit 6b75cbf7cda07c60242fb3a7e279aeb71f06da80
19 changes: 15 additions & 4 deletions coderd/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,13 @@
return
}

user := database.User{
owner := workspaceOwner{
ID: member.UserID,
Username: member.Username,
AvatarURL: member.AvatarURL,
}

createWorkspace(ctx, aReq, apiKey.UserID, api, user, req, rw, r)
createWorkspace(ctx, aReq, apiKey.UserID, api, owner, req, rw, r)
}

// Create a new workspace for the currently authenticated user.
Expand Down Expand Up @@ -436,15 +436,26 @@
return
}

createWorkspace(ctx, aReq, apiKey.UserID, api, user, req, rw, r)
owner := workspaceOwner{
ID: user.ID,
Username: user.Username,
AvatarURL: user.AvatarURL,
}
createWorkspace(ctx, aReq, apiKey.UserID, api, owner, req, rw, r)
}

type workspaceOwner struct {
ID uuid.UUID
Username string
AvatarURL string
}

func createWorkspace(
ctx context.Context,
auditReq *audit.Request[database.Workspace],
initiatorID uuid.UUID,
api *API,
user database.User,
owner workspaceOwner,
req codersdk.CreateWorkspaceRequest,
rw http.ResponseWriter,
r *http.Request,
Expand Down Expand Up @@ -567,7 +578,7 @@
// read other workspaces. Ideally we check the error on create and look for
// a postgres conflict error.
workspace, err := api.Database.GetWorkspaceByOwnerIDAndName(ctx, database.GetWorkspaceByOwnerIDAndNameParams{
OwnerID: user.ID,

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-e2e-enterprise

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-e2e

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / lint

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / lint

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / gen

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / offlinedocs

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-race

undefined: user

Check failure on line 581 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-race

undefined: user
Name: req.Name,
})
if err == nil {
Expand Down Expand Up @@ -600,7 +611,7 @@
ID: uuid.New(),
CreatedAt: now,
UpdatedAt: now,
OwnerID: user.ID,

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-e2e-enterprise

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-e2e

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / lint

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / lint

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / gen

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / offlinedocs

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-race

undefined: user

Check failure on line 614 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-race

undefined: user
OrganizationID: template.OrganizationID,
TemplateID: template.ID,
Name: req.Name,
Expand Down Expand Up @@ -668,8 +679,8 @@
ProvisionerJob: *provisionerJob,
QueuePosition: 0,
},
user.Username,

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-e2e-enterprise

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-e2e

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / lint

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / gen

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / offlinedocs

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-race

undefined: user

Check failure on line 682 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-race

undefined: user
user.AvatarURL,

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-e2e-enterprise

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-e2e

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / lint

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / gen

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / offlinedocs

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-race

undefined: user

Check failure on line 683 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-race

undefined: user
[]database.WorkspaceResource{},
[]database.WorkspaceResourceMetadatum{},
[]database.WorkspaceAgent{},
Expand All @@ -691,8 +702,8 @@
workspace,
apiBuild,
template,
user.Username,

Check failure on line 705 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

undefined: user

Check failure on line 705 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-e2e-enterprise

undefined: user

Check failure on line 705 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-e2e

undefined: user

Check failure on line 705 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / lint

undefined: user

Check failure on line 705 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / gen

undefined: user

Check failure on line 705 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / offlinedocs

undefined: user

Check failure on line 705 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg

undefined: user

Check failure on line 705 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

undefined: user

Check failure on line 705 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

undefined: user

Check failure on line 705 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

undefined: user

Check failure on line 705 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-race

undefined: user
user.AvatarURL,

Check failure on line 706 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (macos-latest)

undefined: user

Check failure on line 706 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-e2e-enterprise

undefined: user

Check failure on line 706 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-e2e

undefined: user

Check failure on line 706 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / lint

undefined: user) (typecheck)

Check failure on line 706 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / gen

undefined: user

Check failure on line 706 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / offlinedocs

undefined: user

Check failure on line 706 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg

undefined: user

Check failure on line 706 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-pg-16

undefined: user

Check failure on line 706 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (windows-2022)

undefined: user

Check failure on line 706 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go (ubuntu-latest)

undefined: user

Check failure on line 706 in coderd/workspaces.go

View workflow job for this annotation

GitHub Actions / test-go-race

undefined: user
api.Options.AllowWorkspaceRenames,
)
if err != nil {
Expand Down
Loading