Skip to content

feat(cli): support ephemeral parameters #8415

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 14 commits into from
Jul 13, 2023
Prev Previous commit
Next Next commit
golden updates
  • Loading branch information
mtojek committed Jul 11, 2023
commit 8980fcefed8febeaae3b47e9b8857625739c219b
8 changes: 8 additions & 0 deletions cli/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func (r *RootCmd) create() *clibase.Cmd {
startAt string
stopAfter time.Duration
workspaceName string
buildOptions bool
)
client := new(codersdk.Client)
cmd := &clibase.Cmd{
Expand Down Expand Up @@ -123,6 +124,7 @@ func (r *RootCmd) create() *clibase.Cmd {
Template: template,
RichParameterFile: richParameterFile,
NewWorkspaceName: workspaceName,
BuildOptions: buildOptions,
})
if err != nil {
return xerrors.Errorf("prepare build: %w", err)
Expand Down Expand Up @@ -189,6 +191,11 @@ func (r *RootCmd) create() *clibase.Cmd {
Description: "Specify a duration after which the workspace should shut down (e.g. 8h).",
Value: clibase.DurationOf(&stopAfter),
},
clibase.Option{
Flag: "build-options",
Description: "Prompt for one-time build options defined with ephemeral parameters.",
Value: clibase.BoolOf(&buildOptions),
},
cliui.SkipPromptOption(),
)

Expand All @@ -202,6 +209,7 @@ type prepWorkspaceBuildArgs struct {
NewWorkspaceName string

UpdateWorkspace bool
BuildOptions bool
WorkspaceID uuid.UUID
}

Expand Down
3 changes: 3 additions & 0 deletions cli/testdata/coder_create_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Usage: coder create [flags] [name]
Create a workspace

Options
--build-options bool
Prompt for one-time build options defined with ephemeral parameters.

--rich-parameter-file string, $CODER_RICH_PARAMETER_FILE
Specify a file path with values for rich parameters defined in the
template.
Expand Down
3 changes: 3 additions & 0 deletions cli/testdata/coder_update_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Use --always-prompt to change the parameter values of the workspace.
Always prompt all parameters. Does not pull parameter values from
existing workspace.

--build-options bool
Prompt for one-time build options defined with ephemeral parameters.

--rich-parameter-file string, $CODER_RICH_PARAMETER_FILE
Specify a file path with values for rich parameters defined in the
template.
Expand Down
11 changes: 9 additions & 2 deletions cli/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func (r *RootCmd) update() *clibase.Cmd {
var (
richParameterFile string
alwaysPrompt bool
buildOptions bool
)

client := new(codersdk.Client)
Expand Down Expand Up @@ -53,6 +54,8 @@ func (r *RootCmd) update() *clibase.Cmd {

UpdateWorkspace: true,
WorkspaceID: workspace.LatestBuild.ID,

BuildOptions: buildOptions,
})
if err != nil {
return nil
Expand Down Expand Up @@ -86,15 +89,19 @@ func (r *RootCmd) update() *clibase.Cmd {
{
Flag: "always-prompt",
Description: "Always prompt all parameters. Does not pull parameter values from existing workspace.",

Value: clibase.BoolOf(&alwaysPrompt),
Value: clibase.BoolOf(&alwaysPrompt),
},
{
Flag: "rich-parameter-file",
Description: "Specify a file path with values for rich parameters defined in the template.",
Env: "CODER_RICH_PARAMETER_FILE",
Value: clibase.StringOf(&richParameterFile),
},
{
Flag: "build-options",
Description: "Prompt for one-time build options defined with ephemeral parameters.",
Value: clibase.BoolOf(&buildOptions),
},
}
return cmd
}