Skip to content

Commit 1213553

Browse files
committed
address PR comments
1 parent 0c7ddb0 commit 1213553

17 files changed

+32
-96
lines changed

cli/delete.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
// nolint
1313
func (r *RootCmd) deleteWorkspace() *serpent.Command {
1414
var (
15-
orphan bool
16-
buildDebug buildDebugFlags
15+
orphan bool
16+
prov buildFlags
1717
)
1818
client := new(codersdk.Client)
1919
cmd := &serpent.Command{
@@ -48,7 +48,7 @@ func (r *RootCmd) deleteWorkspace() *serpent.Command {
4848
ProvisionerState: state,
4949
Orphan: orphan,
5050
}
51-
if buildDebug.provisioner {
51+
if prov.provisionerLogDebug {
5252
req.LogLevel = codersdk.ProvisionerLogLevelDebug
5353
}
5454
build, err := client.CreateWorkspaceBuild(inv.Context(), workspace.ID, req)
@@ -78,6 +78,6 @@ func (r *RootCmd) deleteWorkspace() *serpent.Command {
7878
},
7979
cliui.SkipPromptOption(),
8080
}
81-
cmd.Options = append(cmd.Options, buildDebug.cliOptions()...)
81+
cmd.Options = append(cmd.Options, prov.cliOptions()...)
8282
return cmd
8383
}

cli/parameter.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,20 @@ func parseParameterMapFile(parameterFile string) (map[string]string, error) {
128128
return parameterMap, nil
129129
}
130130

131-
// buildDebugFlags contains options relating to troubleshooting build issues.
132-
type buildDebugFlags struct {
133-
provisioner bool
131+
// buildFlags contains options relating to troubleshooting provisioner jobs.
132+
type buildFlags struct {
133+
provisionerLogDebug bool
134134
}
135135

136-
func (bdf *buildDebugFlags) cliOptions() []serpent.Option {
136+
func (bf *buildFlags) cliOptions() []serpent.Option {
137137
return []serpent.Option{
138138
{
139-
Flag: "debug-provisioner",
139+
Flag: "provisioner-log-debug",
140140
Description: `Sets the provisioner log level to debug.
141141
This will print additional information about the build process.
142142
This is useful for troubleshooting build issues.`,
143-
Value: serpent.BoolOf(&bdf.provisioner),
143+
Value: serpent.BoolOf(&bf.provisionerLogDebug),
144+
Hidden: true,
144145
},
145146
}
146147
}

cli/restart.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
func (r *RootCmd) restart() *serpent.Command {
1717
var (
1818
parameterFlags workspaceParameterFlags
19-
debugFlags buildDebugFlags
19+
bflags buildFlags
2020
)
2121

2222
client := new(codersdk.Client)
@@ -38,7 +38,7 @@ func (r *RootCmd) restart() *serpent.Command {
3838
return err
3939
}
4040

41-
startReq, err := buildWorkspaceStartRequest(inv, client, workspace, parameterFlags, debugFlags, WorkspaceRestart)
41+
startReq, err := buildWorkspaceStartRequest(inv, client, workspace, parameterFlags, bflags, WorkspaceRestart)
4242
if err != nil {
4343
return err
4444
}
@@ -54,7 +54,7 @@ func (r *RootCmd) restart() *serpent.Command {
5454
wbr := codersdk.CreateWorkspaceBuildRequest{
5555
Transition: codersdk.WorkspaceTransitionStop,
5656
}
57-
if debugFlags.provisioner {
57+
if bflags.provisionerLogDebug {
5858
wbr.LogLevel = codersdk.ProvisionerLogLevelDebug
5959
}
6060
build, err := client.CreateWorkspaceBuild(ctx, workspace.ID, wbr)
@@ -72,7 +72,7 @@ func (r *RootCmd) restart() *serpent.Command {
7272
// workspaces with the active version.
7373
if cerr, ok := codersdk.AsError(err); ok && cerr.StatusCode() == http.StatusForbidden {
7474
_, _ = fmt.Fprintln(inv.Stdout, "Unable to restart the workspace with the template version from the last build. Policy may require you to restart with the current active template version.")
75-
build, err = startWorkspace(inv, client, workspace, parameterFlags, debugFlags, WorkspaceUpdate)
75+
build, err = startWorkspace(inv, client, workspace, parameterFlags, bflags, WorkspaceUpdate)
7676
if err != nil {
7777
return xerrors.Errorf("start workspace with active template version: %w", err)
7878
}
@@ -94,7 +94,7 @@ func (r *RootCmd) restart() *serpent.Command {
9494
}
9595

9696
cmd.Options = append(cmd.Options, parameterFlags.allOptions()...)
97-
cmd.Options = append(cmd.Options, debugFlags.cliOptions()...)
97+
cmd.Options = append(cmd.Options, bflags.cliOptions()...)
9898

9999
return cmd
100100
}

cli/ssh.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,9 @@ func getWorkspaceAndAgent(ctx context.Context, inv *serpent.Invocation, client *
649649
// It's possible for a workspace build to fail due to the template requiring starting
650650
// workspaces with the active version.
651651
_, _ = fmt.Fprintf(inv.Stderr, "Workspace was stopped, starting workspace to allow connecting to %q...\n", workspace.Name)
652-
_, err = startWorkspace(inv, client, workspace, workspaceParameterFlags{}, buildDebugFlags{}, WorkspaceStart)
652+
_, err = startWorkspace(inv, client, workspace, workspaceParameterFlags{}, buildFlags{}, WorkspaceStart)
653653
if cerr, ok := codersdk.AsError(err); ok && cerr.StatusCode() == http.StatusForbidden {
654-
_, err = startWorkspace(inv, client, workspace, workspaceParameterFlags{}, buildDebugFlags{}, WorkspaceUpdate)
654+
_, err = startWorkspace(inv, client, workspace, workspaceParameterFlags{}, buildFlags{}, WorkspaceUpdate)
655655
if err != nil {
656656
return codersdk.Workspace{}, codersdk.WorkspaceAgent{}, xerrors.Errorf("start workspace with active template version: %w", err)
657657
}

cli/start.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
func (r *RootCmd) start() *serpent.Command {
1616
var (
1717
parameterFlags workspaceParameterFlags
18-
debugFlags buildDebugFlags
18+
bflags buildFlags
1919
)
2020

2121
client := new(codersdk.Client)
@@ -48,12 +48,12 @@ func (r *RootCmd) start() *serpent.Command {
4848
)
4949
build = workspace.LatestBuild
5050
default:
51-
build, err = startWorkspace(inv, client, workspace, parameterFlags, debugFlags, WorkspaceStart)
51+
build, err = startWorkspace(inv, client, workspace, parameterFlags, bflags, WorkspaceStart)
5252
// It's possible for a workspace build to fail due to the template requiring starting
5353
// workspaces with the active version.
5454
if cerr, ok := codersdk.AsError(err); ok && cerr.StatusCode() == http.StatusForbidden {
5555
_, _ = fmt.Fprintln(inv.Stdout, "Unable to start the workspace with the template version from the last build. Policy may require you to restart with the current active template version.")
56-
build, err = startWorkspace(inv, client, workspace, parameterFlags, debugFlags, WorkspaceUpdate)
56+
build, err = startWorkspace(inv, client, workspace, parameterFlags, bflags, WorkspaceUpdate)
5757
if err != nil {
5858
return xerrors.Errorf("start workspace with active template version: %w", err)
5959
}
@@ -76,12 +76,12 @@ func (r *RootCmd) start() *serpent.Command {
7676
}
7777

7878
cmd.Options = append(cmd.Options, parameterFlags.allOptions()...)
79-
cmd.Options = append(cmd.Options, debugFlags.cliOptions()...)
79+
cmd.Options = append(cmd.Options, bflags.cliOptions()...)
8080

8181
return cmd
8282
}
8383

84-
func buildWorkspaceStartRequest(inv *serpent.Invocation, client *codersdk.Client, workspace codersdk.Workspace, parameterFlags workspaceParameterFlags, debugFlags buildDebugFlags, action WorkspaceCLIAction) (codersdk.CreateWorkspaceBuildRequest, error) {
84+
func buildWorkspaceStartRequest(inv *serpent.Invocation, client *codersdk.Client, workspace codersdk.Workspace, parameterFlags workspaceParameterFlags, buildFlags buildFlags, action WorkspaceCLIAction) (codersdk.CreateWorkspaceBuildRequest, error) {
8585
version := workspace.LatestBuild.TemplateVersionID
8686

8787
if workspace.AutomaticUpdates == codersdk.AutomaticUpdatesAlways || action == WorkspaceUpdate {
@@ -133,14 +133,14 @@ func buildWorkspaceStartRequest(inv *serpent.Invocation, client *codersdk.Client
133133
RichParameterValues: buildParameters,
134134
TemplateVersionID: version,
135135
}
136-
if debugFlags.provisioner {
136+
if buildFlags.provisionerLogDebug {
137137
wbr.LogLevel = codersdk.ProvisionerLogLevelDebug
138138
}
139139

140140
return wbr, nil
141141
}
142142

143-
func startWorkspace(inv *serpent.Invocation, client *codersdk.Client, workspace codersdk.Workspace, parameterFlags workspaceParameterFlags, debugFlags buildDebugFlags, action WorkspaceCLIAction) (codersdk.WorkspaceBuild, error) {
143+
func startWorkspace(inv *serpent.Invocation, client *codersdk.Client, workspace codersdk.Workspace, parameterFlags workspaceParameterFlags, buildFlags buildFlags, action WorkspaceCLIAction) (codersdk.WorkspaceBuild, error) {
144144
if workspace.DormantAt != nil {
145145
_, _ = fmt.Fprintln(inv.Stdout, "Activating dormant workspace...")
146146
err := client.UpdateWorkspaceDormancy(inv.Context(), workspace.ID, codersdk.UpdateWorkspaceDormancy{
@@ -150,7 +150,7 @@ func startWorkspace(inv *serpent.Invocation, client *codersdk.Client, workspace
150150
return codersdk.WorkspaceBuild{}, xerrors.Errorf("activate workspace: %w", err)
151151
}
152152
}
153-
req, err := buildWorkspaceStartRequest(inv, client, workspace, parameterFlags, debugFlags, action)
153+
req, err := buildWorkspaceStartRequest(inv, client, workspace, parameterFlags, buildFlags, action)
154154
if err != nil {
155155
return codersdk.WorkspaceBuild{}, err
156156
}

cli/stop.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func (r *RootCmd) stop() *serpent.Command {
13-
var debugFlags buildDebugFlags
13+
var bflags buildFlags
1414
client := new(codersdk.Client)
1515
cmd := &serpent.Command{
1616
Annotations: workspaceCommand,
@@ -39,7 +39,7 @@ func (r *RootCmd) stop() *serpent.Command {
3939
wbr := codersdk.CreateWorkspaceBuildRequest{
4040
Transition: codersdk.WorkspaceTransitionStop,
4141
}
42-
if debugFlags.provisioner {
42+
if bflags.provisionerLogDebug {
4343
wbr.LogLevel = codersdk.ProvisionerLogLevelDebug
4444
}
4545
build, err := client.CreateWorkspaceBuild(inv.Context(), workspace.ID, wbr)
@@ -61,7 +61,7 @@ func (r *RootCmd) stop() *serpent.Command {
6161
return nil
6262
},
6363
}
64-
cmd.Options = append(cmd.Options, debugFlags.cliOptions()...)
64+
cmd.Options = append(cmd.Options, bflags.cliOptions()...)
6565

6666
return cmd
6767
}

cli/testdata/coder_delete_--help.golden

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ USAGE:
88
Aliases: rm
99

1010
OPTIONS:
11-
--debug-provisioner bool
12-
Sets the provisioner log level to debug.
13-
This will print additional information about the build process.
14-
This is useful for troubleshooting build issues.
15-
1611
--orphan bool
1712
Delete a workspace without deleting its resources. This can delete a
1813
workspace in a broken state, but may also lead to unaccounted cloud

cli/testdata/coder_restart_--help.golden

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ OPTIONS:
1616
--build-options bool
1717
Prompt for one-time build options defined with ephemeral parameters.
1818

19-
--debug-provisioner bool
20-
Sets the provisioner log level to debug.
21-
This will print additional information about the build process.
22-
This is useful for troubleshooting build issues.
23-
2419
--parameter string-array, $CODER_RICH_PARAMETER
2520
Rich parameter value in the format "name=value".
2621

cli/testdata/coder_start_--help.golden

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ OPTIONS:
1616
--build-options bool
1717
Prompt for one-time build options defined with ephemeral parameters.
1818

19-
--debug-provisioner bool
20-
Sets the provisioner log level to debug.
21-
This will print additional information about the build process.
22-
This is useful for troubleshooting build issues.
23-
2419
--parameter string-array, $CODER_RICH_PARAMETER
2520
Rich parameter value in the format "name=value".
2621

cli/testdata/coder_stop_--help.golden

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ USAGE:
66
Stop a workspace
77

88
OPTIONS:
9-
--debug-provisioner bool
10-
Sets the provisioner log level to debug.
11-
This will print additional information about the build process.
12-
This is useful for troubleshooting build issues.
13-
149
-y, --yes bool
1510
Bypass prompts.
1611

cli/testdata/coder_update_--help.golden

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ OPTIONS:
1818
--build-options bool
1919
Prompt for one-time build options defined with ephemeral parameters.
2020

21-
--debug-provisioner bool
22-
Sets the provisioner log level to debug.
23-
This will print additional information about the build process.
24-
This is useful for troubleshooting build issues.
25-
2621
--parameter string-array, $CODER_RICH_PARAMETER
2722
Rich parameter value in the format "name=value".
2823

cli/update.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func (r *RootCmd) update() *serpent.Command {
1313
var (
1414
parameterFlags workspaceParameterFlags
15-
debugFlags buildDebugFlags
15+
bflags buildFlags
1616
)
1717
client := new(codersdk.Client)
1818
cmd := &serpent.Command{
@@ -34,7 +34,7 @@ func (r *RootCmd) update() *serpent.Command {
3434
return nil
3535
}
3636

37-
build, err := startWorkspace(inv, client, workspace, parameterFlags, debugFlags, WorkspaceUpdate)
37+
build, err := startWorkspace(inv, client, workspace, parameterFlags, bflags, WorkspaceUpdate)
3838
if err != nil {
3939
return xerrors.Errorf("start workspace: %w", err)
4040
}
@@ -56,6 +56,6 @@ func (r *RootCmd) update() *serpent.Command {
5656
}
5757

5858
cmd.Options = append(cmd.Options, parameterFlags.allOptions()...)
59-
cmd.Options = append(cmd.Options, debugFlags.cliOptions()...)
59+
cmd.Options = append(cmd.Options, bflags.cliOptions()...)
6060
return cmd
6161
}

docs/reference/cli/delete.md

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/cli/restart.md

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/cli/start.md

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/cli/stop.md

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/cli/update.md

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)