Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(coderd): add matched provisioner daemons information to more places#15688

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 16 commits intomainfromcj/more-matching-provisioners
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
16 commits
Select commitHold shift + click to select a range
ba944ab
feat(coderd/wsbuilder): return provisioners available at time of insert
johnstcnNov 29, 2024
4e51f20
feat(coderd): add matched provisioner daemons information to addition…
johnstcnNov 29, 2024
47036e8
fix linter complaint re nil ptr deref
johnstcnDec 1, 2024
16be03b
add test coverage for matched provisioners with workspace build creation
johnstcnDec 1, 2024
4304a06
skip for non-postgres
johnstcnDec 1, 2024
9ef68dd
add tests for workspace creation
johnstcnDec 1, 2024
38788d5
revert fe changes in this pr
johnstcnDec 1, 2024
1c95ffe
coderd/wsbuilder: use dbauthz.AsSystemReadProvisionerDaemons instead …
johnstcnDec 1, 2024
98521be
refactor: extract WarnMatchedProvisioners to cliutil
johnstcnDec 1, 2024
e1423f5
fixup! refactor: extract WarnMatchedProvisioners to cliutil
johnstcnDec 1, 2024
517a505
feat(cli): add provisioner warning to create/start/stop commands
johnstcnDec 1, 2024
c4295ef
Apply suggestions from code review
johnstcnDec 2, 2024
c5fb83b
feat(coderd): add endpoint for matched provisioners of template versi…
johnstcnDec 2, 2024
3bd62fd
feat(cli): delete: warn on no matched provisioners
johnstcnDec 2, 2024
2f625bc
address linter complaint
johnstcnDec 2, 2024
848338e
add test for cli/delete
johnstcnDec 2, 2024
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
PrevPrevious commit
NextNext commit
feat(cli): add provisioner warning to create/start/stop commands
  • Loading branch information
@johnstcn
johnstcn committedDec 1, 2024
commit517a5050648e154085d67ca515ea6913999cec32
5 changes: 4 additions & 1 deletioncli/create.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ import (
"github.com/coder/pretty"

"github.com/coder/coder/v2/cli/cliui"
"github.com/coder/coder/v2/cli/cliutil"
"github.com/coder/coder/v2/coderd/util/ptr"
"github.com/coder/coder/v2/coderd/util/slice"
"github.com/coder/coder/v2/codersdk"
Expand DownExpand Up@@ -289,7 +290,7 @@ func (r *RootCmd) create() *serpent.Command {
ttlMillis = ptr.Ref(stopAfter.Milliseconds())
}

workspace, err := client.CreateWorkspace(inv.Context(), template.OrganizationID, workspaceOwner, codersdk.CreateWorkspaceRequest{
workspace, err := client.CreateUserWorkspace(inv.Context(), workspaceOwner, codersdk.CreateWorkspaceRequest{
TemplateVersionID: templateVersionID,
Name: workspaceName,
AutostartSchedule: schedSpec,
Expand All@@ -301,6 +302,8 @@ func (r *RootCmd) create() *serpent.Command {
return xerrors.Errorf("create workspace: %w", err)
}

cliutil.WarnMatchedProvisioners(inv.Stderr, workspace.LatestBuild.MatchedProvisioners, workspace.LatestBuild.Job)

err = cliui.WorkspaceBuild(inv.Context(), inv.Stdout, client, workspace.LatestBuild.ID)
if err != nil {
return xerrors.Errorf("watch build: %w", err)
Expand Down
19 changes: 19 additions & 0 deletionscli/start.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import (
"golang.org/x/xerrors"

"github.com/coder/coder/v2/cli/cliui"
"github.com/coder/coder/v2/cli/cliutil"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/serpent"
)
Expand DownExpand Up@@ -35,6 +36,23 @@ func (r *RootCmd) start() *serpent.Command {
}
var build codersdk.WorkspaceBuild
switch workspace.LatestBuild.Status {
case codersdk.WorkspaceStatusPending:
// The above check is technically duplicated in cliutil.WarnmatchedProvisioners
// but we still want to avoid users spamming multiple builds that will
// not be picked up.
_, _ = fmt.Fprintf(
inv.Stdout,
"\nThe %s workspace is waiting to start!\n",
cliui.Keyword(workspace.Name),
)
cliutil.WarnMatchedProvisioners(inv.Stderr, workspace.LatestBuild.MatchedProvisioners, workspace.LatestBuild.Job)
if _, err := cliui.Prompt(inv, cliui.PromptOptions{
Text: "Enqueue another start?",
IsConfirm: true,
Default: cliui.ConfirmNo,
}); err != nil {
return err
}
case codersdk.WorkspaceStatusRunning:
_, _ = fmt.Fprintf(
inv.Stdout, "\nThe %s workspace is already running!\n",
Expand DownExpand Up@@ -159,6 +177,7 @@ func startWorkspace(inv *serpent.Invocation, client *codersdk.Client, workspace
if err != nil {
return codersdk.WorkspaceBuild{}, xerrors.Errorf("create workspace build: %w", err)
}
cliutil.WarnMatchedProvisioners(inv.Stderr, build.MatchedProvisioners, build.Job)

return build, nil
}
17 changes: 17 additions & 0 deletionscli/stop.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@ import (
"time"

"github.com/coder/coder/v2/cli/cliui"
"github.com/coder/coder/v2/cli/cliutil"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/serpent"
)
Expand DownExpand Up@@ -36,6 +37,21 @@ func (r *RootCmd) stop() *serpent.Command {
if err != nil {
return err
}
if workspace.LatestBuild.Job.Status == codersdk.ProvisionerJobPending {
// cliutil.WarnMatchedProvisioners also checks if the job is pending
// but we still want to avoid users spamming multiple builds that will
// not be picked up.
cliui.Warn(inv.Stderr, "The workspace is already stopping!")
cliutil.WarnMatchedProvisioners(inv.Stderr, workspace.LatestBuild.MatchedProvisioners, workspace.LatestBuild.Job)
if _, err := cliui.Prompt(inv, cliui.PromptOptions{
Text: "Enqueue another stop?",
IsConfirm: true,
Default: cliui.ConfirmNo,
}); err != nil {
return err
}
}

wbr := codersdk.CreateWorkspaceBuildRequest{
Transition: codersdk.WorkspaceTransitionStop,
}
Expand All@@ -46,6 +62,7 @@ func (r *RootCmd) stop() *serpent.Command {
if err != nil {
return err
}
cliutil.WarnMatchedProvisioners(inv.Stderr, build.MatchedProvisioners, build.Job)

err = cliui.WorkspaceBuild(inv.Context(), inv.Stdout, client, build.ID)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletioncli/templatepush.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -416,7 +416,7 @@ func createValidTemplateVersion(inv *serpent.Invocation, args createValidTemplat
if err != nil {
return nil, err
}
cliutil.WarnMatchedProvisioners(inv.Stderr, version)
cliutil.WarnMatchedProvisioners(inv.Stderr, version.MatchedProvisioners, version.Job)
err = cliui.ProvisionerJob(inv.Context(), inv.Stdout, cliui.ProvisionerJobOptions{
Fetch: func() (codersdk.ProvisionerJob, error) {
version, err := client.TemplateVersion(inv.Context(), version.ID)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp