Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 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
Fix: restart, create
  • Loading branch information
mtojek committed Aug 8, 2023
commit 9e05ce61853ca8ed82519a1cebfd45801c8f6db5
3 changes: 2 additions & 1 deletion cli/parameter_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ func (pr *ParameterResolver) resolveWithInput(resolved []codersdk.WorkspaceBuild

if (tvp.Ephemeral && pr.promptBuildOptions) ||
tvp.Required ||
(!tvp.Mutable && action == WorkspaceUpdate) {
(!tvp.Mutable && action == WorkspaceUpdate) ||
(!tvp.Ephemeral && action == WorkspaceCreate) {

parameterValue, err := cliui.RichParameter(inv, tvp)
if err != nil {
Expand Down
12 changes: 10 additions & 2 deletions cli/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func (r *RootCmd) restart() *clibase.Cmd {
return err
}

lastBuildParameters, err := client.WorkspaceBuildParameters(inv.Context(), workspace.LatestBuild.ID)
if err != nil {
return err
}

template, err := client.Template(inv.Context(), workspace.TemplateID)
if err != nil {
return err
Expand All @@ -44,8 +49,11 @@ func (r *RootCmd) restart() *clibase.Cmd {
}

buildParameters, err := prepStartWorkspace(inv, client, prepStartWorkspaceArgs{
Action: WorkspaceRestart,
Template: template,
Action: WorkspaceRestart,
Template: template,

LastBuildParameters: lastBuildParameters,

PromptBuildOptions: parameterFlags.promptBuildOptions,
BuildOptions: buildOptions,
})
Expand Down
20 changes: 16 additions & 4 deletions cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func (r *RootCmd) start() *clibase.Cmd {
return err
}

lastBuildParameters, err := client.WorkspaceBuildParameters(inv.Context(), workspace.LatestBuild.ID)
if err != nil {
return err
}

template, err := client.Template(inv.Context(), workspace.TemplateID)
if err != nil {
return err
Expand All @@ -41,8 +46,11 @@ func (r *RootCmd) start() *clibase.Cmd {
}

buildParameters, err := prepStartWorkspace(inv, client, prepStartWorkspaceArgs{
Action: WorkspaceStart,
Template: template,
Action: WorkspaceStart,
Template: template,

LastBuildParameters: lastBuildParameters,

PromptBuildOptions: parameterFlags.promptBuildOptions,
BuildOptions: buildOptions,
})
Expand Down Expand Up @@ -71,8 +79,11 @@ func (r *RootCmd) start() *clibase.Cmd {
}

type prepStartWorkspaceArgs struct {
Action WorkspaceCLIAction
Template codersdk.Template
Action WorkspaceCLIAction
Template codersdk.Template

LastBuildParameters []codersdk.WorkspaceBuildParameter

PromptBuildOptions bool
BuildOptions []codersdk.WorkspaceBuildParameter
}
Expand All @@ -91,6 +102,7 @@ func prepStartWorkspace(inv *clibase.Invocation, client *codersdk.Client, args p
}

resolver := new(ParameterResolver).
WithLastBuildParameters(args.LastBuildParameters).
WithPromptBuildOptions(args.PromptBuildOptions).
WithBuildOptions(args.BuildOptions)
return resolver.Resolve(inv, args.Action, templateVersionParameters)
Expand Down