mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
chore(cli): rename build options to ephemeral parameters in cli (#15030)
This PR aims to rename `build-option` to `ephemeral-parameters` based on #10488 conversation. `build-option` has been renamed `ephemeral-parameter` and can be used to define a value for an ephemeral parameter in the template. `build-options` has been renamed `prompt-ephemeral-parameters` and can be used to prompt the user to put values for the ephemeral parameters in the template. --------- Co-authored-by: Mathias Fredriksson <mafredri@gmail.com> Co-authored-by: EdwardAngert <17991901+EdwardAngert@users.noreply.github.com> Co-authored-by: defelmnq <yvincent@coder.com>
This commit is contained in:
+4
-4
@@ -370,8 +370,8 @@ type prepWorkspaceBuildArgs struct {
|
||||
LastBuildParameters []codersdk.WorkspaceBuildParameter
|
||||
SourceWorkspaceParameters []codersdk.WorkspaceBuildParameter
|
||||
|
||||
PromptBuildOptions bool
|
||||
BuildOptions []codersdk.WorkspaceBuildParameter
|
||||
PromptEphemeralParameters bool
|
||||
EphemeralParameters []codersdk.WorkspaceBuildParameter
|
||||
|
||||
PromptRichParameters bool
|
||||
RichParameters []codersdk.WorkspaceBuildParameter
|
||||
@@ -405,8 +405,8 @@ func prepWorkspaceBuild(inv *serpent.Invocation, client *codersdk.Client, args p
|
||||
resolver := new(ParameterResolver).
|
||||
WithLastBuildParameters(args.LastBuildParameters).
|
||||
WithSourceWorkspaceParameters(args.SourceWorkspaceParameters).
|
||||
WithPromptBuildOptions(args.PromptBuildOptions).
|
||||
WithBuildOptions(args.BuildOptions).
|
||||
WithPromptEphemeralParameters(args.PromptEphemeralParameters).
|
||||
WithEphemeralParameters(args.EphemeralParameters).
|
||||
WithPromptRichParameters(args.PromptRichParameters).
|
||||
WithRichParameters(args.RichParameters).
|
||||
WithRichParametersFile(parameterFile).
|
||||
|
||||
+23
-6
@@ -15,8 +15,9 @@ import (
|
||||
|
||||
// workspaceParameterFlags are used by commands processing rich parameters and/or build options.
|
||||
type workspaceParameterFlags struct {
|
||||
promptBuildOptions bool
|
||||
buildOptions []string
|
||||
promptEphemeralParameters bool
|
||||
|
||||
ephemeralParameters []string
|
||||
|
||||
richParameterFile string
|
||||
richParameters []string
|
||||
@@ -26,23 +27,39 @@ type workspaceParameterFlags struct {
|
||||
}
|
||||
|
||||
func (wpf *workspaceParameterFlags) allOptions() []serpent.Option {
|
||||
options := append(wpf.cliBuildOptions(), wpf.cliParameters()...)
|
||||
options := append(wpf.cliEphemeralParameters(), wpf.cliParameters()...)
|
||||
options = append(options, wpf.cliParameterDefaults()...)
|
||||
return append(options, wpf.alwaysPrompt())
|
||||
}
|
||||
|
||||
func (wpf *workspaceParameterFlags) cliBuildOptions() []serpent.Option {
|
||||
func (wpf *workspaceParameterFlags) cliEphemeralParameters() []serpent.Option {
|
||||
return serpent.OptionSet{
|
||||
// Deprecated - replaced with ephemeral-parameter
|
||||
{
|
||||
Flag: "build-option",
|
||||
Env: "CODER_BUILD_OPTION",
|
||||
Description: `Build option value in the format "name=value".`,
|
||||
Value: serpent.StringArrayOf(&wpf.buildOptions),
|
||||
UseInstead: []serpent.Option{{Flag: "ephemeral-parameter"}},
|
||||
Value: serpent.StringArrayOf(&wpf.ephemeralParameters),
|
||||
},
|
||||
// Deprecated - replaced with prompt-ephemeral-parameters
|
||||
{
|
||||
Flag: "build-options",
|
||||
Description: "Prompt for one-time build options defined with ephemeral parameters.",
|
||||
Value: serpent.BoolOf(&wpf.promptBuildOptions),
|
||||
UseInstead: []serpent.Option{{Flag: "prompt-ephemeral-parameters"}},
|
||||
Value: serpent.BoolOf(&wpf.promptEphemeralParameters),
|
||||
},
|
||||
{
|
||||
Flag: "ephemeral-parameter",
|
||||
Env: "CODER_EPHEMERAL_PARAMETER",
|
||||
Description: `Set the value of ephemeral parameters defined in the template. The format is "name=value".`,
|
||||
Value: serpent.StringArrayOf(&wpf.ephemeralParameters),
|
||||
},
|
||||
{
|
||||
Flag: "prompt-ephemeral-parameters",
|
||||
Env: "CODER_PROMPT_EPHEMERAL_PARAMETERS",
|
||||
Description: "Prompt to set values of ephemeral parameters defined in the template. If a value has been set via --ephemeral-parameter, it will not be prompted for.",
|
||||
Value: serpent.BoolOf(&wpf.promptEphemeralParameters),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
+16
-16
@@ -29,10 +29,10 @@ type ParameterResolver struct {
|
||||
richParameters []codersdk.WorkspaceBuildParameter
|
||||
richParametersDefaults map[string]string
|
||||
richParametersFile map[string]string
|
||||
buildOptions []codersdk.WorkspaceBuildParameter
|
||||
ephemeralParameters []codersdk.WorkspaceBuildParameter
|
||||
|
||||
promptRichParameters bool
|
||||
promptBuildOptions bool
|
||||
promptRichParameters bool
|
||||
promptEphemeralParameters bool
|
||||
}
|
||||
|
||||
func (pr *ParameterResolver) WithLastBuildParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver {
|
||||
@@ -50,8 +50,8 @@ func (pr *ParameterResolver) WithRichParameters(params []codersdk.WorkspaceBuild
|
||||
return pr
|
||||
}
|
||||
|
||||
func (pr *ParameterResolver) WithBuildOptions(params []codersdk.WorkspaceBuildParameter) *ParameterResolver {
|
||||
pr.buildOptions = params
|
||||
func (pr *ParameterResolver) WithEphemeralParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver {
|
||||
pr.ephemeralParameters = params
|
||||
return pr
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ func (pr *ParameterResolver) WithPromptRichParameters(promptRichParameters bool)
|
||||
return pr
|
||||
}
|
||||
|
||||
func (pr *ParameterResolver) WithPromptBuildOptions(promptBuildOptions bool) *ParameterResolver {
|
||||
pr.promptBuildOptions = promptBuildOptions
|
||||
func (pr *ParameterResolver) WithPromptEphemeralParameters(promptEphemeralParameters bool) *ParameterResolver {
|
||||
pr.promptEphemeralParameters = promptEphemeralParameters
|
||||
return pr
|
||||
}
|
||||
|
||||
@@ -128,16 +128,16 @@ nextRichParameter:
|
||||
resolved = append(resolved, richParameter)
|
||||
}
|
||||
|
||||
nextBuildOption:
|
||||
for _, buildOption := range pr.buildOptions {
|
||||
nextEphemeralParameter:
|
||||
for _, ephemeralParameter := range pr.ephemeralParameters {
|
||||
for i, r := range resolved {
|
||||
if r.Name == buildOption.Name {
|
||||
resolved[i].Value = buildOption.Value
|
||||
continue nextBuildOption
|
||||
if r.Name == ephemeralParameter.Name {
|
||||
resolved[i].Value = ephemeralParameter.Value
|
||||
continue nextEphemeralParameter
|
||||
}
|
||||
}
|
||||
|
||||
resolved = append(resolved, buildOption)
|
||||
resolved = append(resolved, ephemeralParameter)
|
||||
}
|
||||
return resolved
|
||||
}
|
||||
@@ -209,8 +209,8 @@ func (pr *ParameterResolver) verifyConstraints(resolved []codersdk.WorkspaceBuil
|
||||
return templateVersionParametersNotFound(r.Name, templateVersionParameters)
|
||||
}
|
||||
|
||||
if tvp.Ephemeral && !pr.promptBuildOptions && findWorkspaceBuildParameter(tvp.Name, pr.buildOptions) == nil {
|
||||
return xerrors.Errorf("ephemeral parameter %q can be used only with --build-options or --build-option flag", r.Name)
|
||||
if tvp.Ephemeral && !pr.promptEphemeralParameters && findWorkspaceBuildParameter(tvp.Name, pr.ephemeralParameters) == nil {
|
||||
return xerrors.Errorf("ephemeral parameter %q can be used only with --prompt-ephemeral-parameters or --ephemeral-parameter flag", r.Name)
|
||||
}
|
||||
|
||||
if !tvp.Mutable && action != WorkspaceCreate {
|
||||
@@ -231,7 +231,7 @@ func (pr *ParameterResolver) resolveWithInput(resolved []codersdk.WorkspaceBuild
|
||||
firstTimeUse := pr.isFirstTimeUse(tvp.Name)
|
||||
promptParameterOption := pr.isLastBuildParameterInvalidOption(tvp)
|
||||
|
||||
if (tvp.Ephemeral && pr.promptBuildOptions) ||
|
||||
if (tvp.Ephemeral && pr.promptEphemeralParameters) ||
|
||||
(action == WorkspaceCreate && tvp.Required) ||
|
||||
(action == WorkspaceCreate && !tvp.Ephemeral) ||
|
||||
(action == WorkspaceUpdate && promptParameterOption) ||
|
||||
|
||||
+110
-2
@@ -60,7 +60,115 @@ func TestRestart(t *testing.T) {
|
||||
require.NoError(t, err, "execute failed")
|
||||
})
|
||||
|
||||
t.Run("BuildOptions", func(t *testing.T) {
|
||||
t.Run("PromptEphemeralParameters", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
||||
owner := coderdtest.CreateFirstUser(t, client)
|
||||
member, memberUser := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
|
||||
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses)
|
||||
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
|
||||
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
|
||||
workspace := coderdtest.CreateWorkspace(t, member, template.ID)
|
||||
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
|
||||
|
||||
inv, root := clitest.New(t, "restart", workspace.Name, "--prompt-ephemeral-parameters")
|
||||
clitest.SetupConfig(t, member, root)
|
||||
doneChan := make(chan struct{})
|
||||
pty := ptytest.New(t).Attach(inv)
|
||||
go func() {
|
||||
defer close(doneChan)
|
||||
err := inv.Run()
|
||||
assert.NoError(t, err)
|
||||
}()
|
||||
|
||||
matches := []string{
|
||||
ephemeralParameterDescription, ephemeralParameterValue,
|
||||
"Restart workspace?", "yes",
|
||||
"Stopping workspace", "",
|
||||
"Starting workspace", "",
|
||||
"workspace has been restarted", "",
|
||||
}
|
||||
for i := 0; i < len(matches); i += 2 {
|
||||
match := matches[i]
|
||||
value := matches[i+1]
|
||||
pty.ExpectMatch(match)
|
||||
|
||||
if value != "" {
|
||||
pty.WriteLine(value)
|
||||
}
|
||||
}
|
||||
<-doneChan
|
||||
|
||||
// Verify if build option is set
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, memberUser.ID.String(), workspace.Name, codersdk.WorkspaceOptions{})
|
||||
require.NoError(t, err)
|
||||
actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID)
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, actualParameters, codersdk.WorkspaceBuildParameter{
|
||||
Name: ephemeralParameterName,
|
||||
Value: ephemeralParameterValue,
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("EphemeralParameterFlags", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
||||
owner := coderdtest.CreateFirstUser(t, client)
|
||||
member, memberUser := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID)
|
||||
version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, echoResponses)
|
||||
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
|
||||
template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)
|
||||
workspace := coderdtest.CreateWorkspace(t, member, template.ID)
|
||||
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
|
||||
|
||||
inv, root := clitest.New(t, "restart", workspace.Name,
|
||||
"--ephemeral-parameter", fmt.Sprintf("%s=%s", ephemeralParameterName, ephemeralParameterValue))
|
||||
clitest.SetupConfig(t, member, root)
|
||||
doneChan := make(chan struct{})
|
||||
pty := ptytest.New(t).Attach(inv)
|
||||
go func() {
|
||||
defer close(doneChan)
|
||||
err := inv.Run()
|
||||
assert.NoError(t, err)
|
||||
}()
|
||||
|
||||
matches := []string{
|
||||
"Restart workspace?", "yes",
|
||||
"Stopping workspace", "",
|
||||
"Starting workspace", "",
|
||||
"workspace has been restarted", "",
|
||||
}
|
||||
for i := 0; i < len(matches); i += 2 {
|
||||
match := matches[i]
|
||||
value := matches[i+1]
|
||||
pty.ExpectMatch(match)
|
||||
|
||||
if value != "" {
|
||||
pty.WriteLine(value)
|
||||
}
|
||||
}
|
||||
<-doneChan
|
||||
|
||||
// Verify if build option is set
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
|
||||
workspace, err := client.WorkspaceByOwnerAndName(ctx, memberUser.ID.String(), workspace.Name, codersdk.WorkspaceOptions{})
|
||||
require.NoError(t, err)
|
||||
actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID)
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, actualParameters, codersdk.WorkspaceBuildParameter{
|
||||
Name: ephemeralParameterName,
|
||||
Value: ephemeralParameterValue,
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("with deprecated build-options flag", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
||||
@@ -114,7 +222,7 @@ func TestRestart(t *testing.T) {
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("BuildOptionFlags", func(t *testing.T) {
|
||||
t.Run("with deprecated build-option flag", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
||||
|
||||
+7
-7
@@ -96,7 +96,7 @@ func buildWorkspaceStartRequest(inv *serpent.Invocation, client *codersdk.Client
|
||||
return codersdk.CreateWorkspaceBuildRequest{}, err
|
||||
}
|
||||
|
||||
buildOptions, err := asWorkspaceBuildParameters(parameterFlags.buildOptions)
|
||||
ephemeralParameters, err := asWorkspaceBuildParameters(parameterFlags.ephemeralParameters)
|
||||
if err != nil {
|
||||
return codersdk.CreateWorkspaceBuildRequest{}, xerrors.Errorf("unable to parse build options: %w", err)
|
||||
}
|
||||
@@ -117,12 +117,12 @@ func buildWorkspaceStartRequest(inv *serpent.Invocation, client *codersdk.Client
|
||||
NewWorkspaceName: workspace.Name,
|
||||
LastBuildParameters: lastBuildParameters,
|
||||
|
||||
PromptBuildOptions: parameterFlags.promptBuildOptions,
|
||||
BuildOptions: buildOptions,
|
||||
PromptRichParameters: parameterFlags.promptRichParameters,
|
||||
RichParameters: cliRichParameters,
|
||||
RichParameterFile: parameterFlags.richParameterFile,
|
||||
RichParameterDefaults: cliRichParameterDefaults,
|
||||
PromptEphemeralParameters: parameterFlags.promptEphemeralParameters,
|
||||
EphemeralParameters: ephemeralParameters,
|
||||
PromptRichParameters: parameterFlags.promptRichParameters,
|
||||
RichParameters: cliRichParameters,
|
||||
RichParameterFile: parameterFlags.richParameterFile,
|
||||
RichParameterDefaults: cliRichParameterDefaults,
|
||||
})
|
||||
if err != nil {
|
||||
return codersdk.CreateWorkspaceBuildRequest{}, err
|
||||
|
||||
+5
-5
@@ -115,7 +115,7 @@ func TestStart(t *testing.T) {
|
||||
workspaceBuild := coderdtest.CreateWorkspaceBuild(t, client, workspace, database.WorkspaceTransitionStop)
|
||||
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspaceBuild.ID)
|
||||
|
||||
inv, root := clitest.New(t, "start", workspace.Name, "--build-options")
|
||||
inv, root := clitest.New(t, "start", workspace.Name, "--prompt-ephemeral-parameters")
|
||||
clitest.SetupConfig(t, member, root)
|
||||
doneChan := make(chan struct{})
|
||||
pty := ptytest.New(t).Attach(inv)
|
||||
@@ -140,7 +140,7 @@ func TestStart(t *testing.T) {
|
||||
}
|
||||
<-doneChan
|
||||
|
||||
// Verify if build option is set
|
||||
// Verify if ephemeral parameter is set
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
|
||||
@@ -154,7 +154,7 @@ func TestStart(t *testing.T) {
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("BuildOptionFlags", func(t *testing.T) {
|
||||
t.Run("EphemeralParameterFlags", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
||||
@@ -170,7 +170,7 @@ func TestStart(t *testing.T) {
|
||||
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspaceBuild.ID)
|
||||
|
||||
inv, root := clitest.New(t, "start", workspace.Name,
|
||||
"--build-option", fmt.Sprintf("%s=%s", ephemeralParameterName, ephemeralParameterValue))
|
||||
"--ephemeral-parameter", fmt.Sprintf("%s=%s", ephemeralParameterName, ephemeralParameterValue))
|
||||
clitest.SetupConfig(t, member, root)
|
||||
doneChan := make(chan struct{})
|
||||
pty := ptytest.New(t).Attach(inv)
|
||||
@@ -183,7 +183,7 @@ func TestStart(t *testing.T) {
|
||||
pty.ExpectMatch("workspace has been started")
|
||||
<-doneChan
|
||||
|
||||
// Verify if build option is set
|
||||
// Verify if ephemeral parameter is set
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
|
||||
|
||||
+11
@@ -12,9 +12,15 @@ OPTIONS:
|
||||
|
||||
--build-option string-array, $CODER_BUILD_OPTION
|
||||
Build option value in the format "name=value".
|
||||
DEPRECATED: Use --ephemeral-parameter instead.
|
||||
|
||||
--build-options bool
|
||||
Prompt for one-time build options defined with ephemeral parameters.
|
||||
DEPRECATED: Use --prompt-ephemeral-parameters instead.
|
||||
|
||||
--ephemeral-parameter string-array, $CODER_EPHEMERAL_PARAMETER
|
||||
Set the value of ephemeral parameters defined in the template. The
|
||||
format is "name=value".
|
||||
|
||||
--parameter string-array, $CODER_RICH_PARAMETER
|
||||
Rich parameter value in the format "name=value".
|
||||
@@ -22,6 +28,11 @@ OPTIONS:
|
||||
--parameter-default string-array, $CODER_RICH_PARAMETER_DEFAULT
|
||||
Rich parameter default values in the format "name=value".
|
||||
|
||||
--prompt-ephemeral-parameters bool, $CODER_PROMPT_EPHEMERAL_PARAMETERS
|
||||
Prompt to set values of ephemeral parameters defined in the template.
|
||||
If a value has been set via --ephemeral-parameter, it will not be
|
||||
prompted for.
|
||||
|
||||
--rich-parameter-file string, $CODER_RICH_PARAMETER_FILE
|
||||
Specify a file path with values for rich parameters defined in the
|
||||
template. The file should be in YAML format, containing key-value
|
||||
|
||||
+11
@@ -12,9 +12,15 @@ OPTIONS:
|
||||
|
||||
--build-option string-array, $CODER_BUILD_OPTION
|
||||
Build option value in the format "name=value".
|
||||
DEPRECATED: Use --ephemeral-parameter instead.
|
||||
|
||||
--build-options bool
|
||||
Prompt for one-time build options defined with ephemeral parameters.
|
||||
DEPRECATED: Use --prompt-ephemeral-parameters instead.
|
||||
|
||||
--ephemeral-parameter string-array, $CODER_EPHEMERAL_PARAMETER
|
||||
Set the value of ephemeral parameters defined in the template. The
|
||||
format is "name=value".
|
||||
|
||||
--parameter string-array, $CODER_RICH_PARAMETER
|
||||
Rich parameter value in the format "name=value".
|
||||
@@ -22,6 +28,11 @@ OPTIONS:
|
||||
--parameter-default string-array, $CODER_RICH_PARAMETER_DEFAULT
|
||||
Rich parameter default values in the format "name=value".
|
||||
|
||||
--prompt-ephemeral-parameters bool, $CODER_PROMPT_EPHEMERAL_PARAMETERS
|
||||
Prompt to set values of ephemeral parameters defined in the template.
|
||||
If a value has been set via --ephemeral-parameter, it will not be
|
||||
prompted for.
|
||||
|
||||
--rich-parameter-file string, $CODER_RICH_PARAMETER_FILE
|
||||
Specify a file path with values for rich parameters defined in the
|
||||
template. The file should be in YAML format, containing key-value
|
||||
|
||||
+11
@@ -14,9 +14,15 @@ OPTIONS:
|
||||
|
||||
--build-option string-array, $CODER_BUILD_OPTION
|
||||
Build option value in the format "name=value".
|
||||
DEPRECATED: Use --ephemeral-parameter instead.
|
||||
|
||||
--build-options bool
|
||||
Prompt for one-time build options defined with ephemeral parameters.
|
||||
DEPRECATED: Use --prompt-ephemeral-parameters instead.
|
||||
|
||||
--ephemeral-parameter string-array, $CODER_EPHEMERAL_PARAMETER
|
||||
Set the value of ephemeral parameters defined in the template. The
|
||||
format is "name=value".
|
||||
|
||||
--parameter string-array, $CODER_RICH_PARAMETER
|
||||
Rich parameter value in the format "name=value".
|
||||
@@ -24,6 +30,11 @@ OPTIONS:
|
||||
--parameter-default string-array, $CODER_RICH_PARAMETER_DEFAULT
|
||||
Rich parameter default values in the format "name=value".
|
||||
|
||||
--prompt-ephemeral-parameters bool, $CODER_PROMPT_EPHEMERAL_PARAMETERS
|
||||
Prompt to set values of ephemeral parameters defined in the template.
|
||||
If a value has been set via --ephemeral-parameter, it will not be
|
||||
prompted for.
|
||||
|
||||
--rich-parameter-file string, $CODER_RICH_PARAMETER_FILE
|
||||
Specify a file path with values for rich parameters defined in the
|
||||
template. The file should be in YAML format, containing key-value
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ func (r *RootCmd) update() *serpent.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !workspace.Outdated && !parameterFlags.promptRichParameters && !parameterFlags.promptBuildOptions && len(parameterFlags.buildOptions) == 0 {
|
||||
if !workspace.Outdated && !parameterFlags.promptRichParameters && !parameterFlags.promptEphemeralParameters && len(parameterFlags.ephemeralParameters) == 0 {
|
||||
_, _ = fmt.Fprintf(inv.Stdout, "Workspace is up-to-date.\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
+6
-6
@@ -160,7 +160,7 @@ func TestUpdateWithRichParameters(t *testing.T) {
|
||||
<-doneChan
|
||||
})
|
||||
|
||||
t.Run("BuildOptions", func(t *testing.T) {
|
||||
t.Run("PromptEphemeralParameters", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
||||
@@ -186,7 +186,7 @@ func TestUpdateWithRichParameters(t *testing.T) {
|
||||
err := inv.Run()
|
||||
assert.NoError(t, err)
|
||||
|
||||
inv, root = clitest.New(t, "update", workspaceName, "--build-options")
|
||||
inv, root = clitest.New(t, "update", workspaceName, "--prompt-ephemeral-parameters")
|
||||
clitest.SetupConfig(t, member, root)
|
||||
|
||||
doneChan := make(chan struct{})
|
||||
@@ -211,7 +211,7 @@ func TestUpdateWithRichParameters(t *testing.T) {
|
||||
}
|
||||
<-doneChan
|
||||
|
||||
// Verify if build option is set
|
||||
// Verify if ephemeral parameter is set
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
|
||||
@@ -225,7 +225,7 @@ func TestUpdateWithRichParameters(t *testing.T) {
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("BuildOptionFlags", func(t *testing.T) {
|
||||
t.Run("EphemeralParameterFlags", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
|
||||
@@ -247,7 +247,7 @@ func TestUpdateWithRichParameters(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
inv, root = clitest.New(t, "update", workspaceName,
|
||||
"--build-option", fmt.Sprintf("%s=%s", ephemeralParameterName, ephemeralParameterValue))
|
||||
"--ephemeral-parameter", fmt.Sprintf("%s=%s", ephemeralParameterName, ephemeralParameterValue))
|
||||
clitest.SetupConfig(t, member, root)
|
||||
|
||||
doneChan := make(chan struct{})
|
||||
@@ -261,7 +261,7 @@ func TestUpdateWithRichParameters(t *testing.T) {
|
||||
pty.ExpectMatch("Planning workspace")
|
||||
<-doneChan
|
||||
|
||||
// Verify if build option is set
|
||||
// Verify if ephemeral parameter is set
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
|
||||
defer cancel()
|
||||
|
||||
|
||||
@@ -204,10 +204,11 @@ operational issue, but it is not advised to overuse this opportunity.
|
||||
|
||||
## Ephemeral parameters
|
||||
|
||||
Ephemeral parameters are introduced to users in the form of "build options." Use
|
||||
ephemeral parameters to model specific behaviors in a Coder workspace, such as
|
||||
reverting to a previous image, restoring from a volume snapshot, or building a
|
||||
project without using cache.
|
||||
Ephemeral parameters are introduced to users in order to model specific
|
||||
behaviors in a Coder workspace, such as reverting to a previous image, restoring
|
||||
from a volume snapshot, or building a project without using cache. These
|
||||
parameters are only settable when starting, updating, or restarting a workspace
|
||||
and do not persist after the workspace is stopped.
|
||||
|
||||
Since these parameters are ephemeral in nature, subsequent builds proceed in the
|
||||
standard manner:
|
||||
|
||||
Generated
+18
@@ -37,6 +37,24 @@ Build option value in the format "name=value".
|
||||
|
||||
Prompt for one-time build options defined with ephemeral parameters.
|
||||
|
||||
### --ephemeral-parameter
|
||||
|
||||
| | |
|
||||
| ----------- | --------------------------------------- |
|
||||
| Type | <code>string-array</code> |
|
||||
| Environment | <code>$CODER_EPHEMERAL_PARAMETER</code> |
|
||||
|
||||
Set the value of ephemeral parameters defined in the template. The format is "name=value".
|
||||
|
||||
### --prompt-ephemeral-parameters
|
||||
|
||||
| | |
|
||||
| ----------- | ----------------------------------------------- |
|
||||
| Type | <code>bool</code> |
|
||||
| Environment | <code>$CODER_PROMPT_EPHEMERAL_PARAMETERS</code> |
|
||||
|
||||
Prompt to set values of ephemeral parameters defined in the template. If a value has been set via --ephemeral-parameter, it will not be prompted for.
|
||||
|
||||
### --parameter
|
||||
|
||||
| | |
|
||||
|
||||
Generated
+18
@@ -37,6 +37,24 @@ Build option value in the format "name=value".
|
||||
|
||||
Prompt for one-time build options defined with ephemeral parameters.
|
||||
|
||||
### --ephemeral-parameter
|
||||
|
||||
| | |
|
||||
| ----------- | --------------------------------------- |
|
||||
| Type | <code>string-array</code> |
|
||||
| Environment | <code>$CODER_EPHEMERAL_PARAMETER</code> |
|
||||
|
||||
Set the value of ephemeral parameters defined in the template. The format is "name=value".
|
||||
|
||||
### --prompt-ephemeral-parameters
|
||||
|
||||
| | |
|
||||
| ----------- | ----------------------------------------------- |
|
||||
| Type | <code>bool</code> |
|
||||
| Environment | <code>$CODER_PROMPT_EPHEMERAL_PARAMETERS</code> |
|
||||
|
||||
Prompt to set values of ephemeral parameters defined in the template. If a value has been set via --ephemeral-parameter, it will not be prompted for.
|
||||
|
||||
### --parameter
|
||||
|
||||
| | |
|
||||
|
||||
Generated
+18
@@ -35,6 +35,24 @@ Build option value in the format "name=value".
|
||||
|
||||
Prompt for one-time build options defined with ephemeral parameters.
|
||||
|
||||
### --ephemeral-parameter
|
||||
|
||||
| | |
|
||||
| ----------- | --------------------------------------- |
|
||||
| Type | <code>string-array</code> |
|
||||
| Environment | <code>$CODER_EPHEMERAL_PARAMETER</code> |
|
||||
|
||||
Set the value of ephemeral parameters defined in the template. The format is "name=value".
|
||||
|
||||
### --prompt-ephemeral-parameters
|
||||
|
||||
| | |
|
||||
| ----------- | ----------------------------------------------- |
|
||||
| Type | <code>bool</code> |
|
||||
| Environment | <code>$CODER_PROMPT_EPHEMERAL_PARAMETERS</code> |
|
||||
|
||||
Prompt to set values of ephemeral parameters defined in the template. If a value has been set via --ephemeral-parameter, it will not be prompted for.
|
||||
|
||||
### --parameter
|
||||
|
||||
| | |
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# Guide Title (Only Visible in Github)
|
||||
|
||||
<div>
|
||||
<a href="https://github.com/<your_github_handle>" style="text-decoration: none; color: inherit;">
|
||||
<a href="https://github.com/coder" style="text-decoration: none; color: inherit;">
|
||||
<span style="vertical-align:middle;">Your Name</span>
|
||||
<img src="https://github.com/ericpaulsen.png" width="24px" height="24px" style="vertical-align:middle; margin: 0px;"/>
|
||||
<img src="https://github.com/coder.png" width="24px" height="24px" style="vertical-align:middle; margin: 0px;"/>
|
||||
</a>
|
||||
</div>
|
||||
December 13, 2023
|
||||
@@ -11,15 +11,14 @@ December 13, 2023
|
||||
---
|
||||
|
||||
This is a guide on how to make Coder guides, it is not listed on our
|
||||
[official guides page](https://coder.com/docs/guides) in the docs. Intended for
|
||||
those who don't frequently contribute documentation changes to the `coder/coder`
|
||||
[official tutorials page](../tutorials/index.md) in the docs. Intended for those
|
||||
who don't frequently contribute documentation changes to the `coder/coder`
|
||||
repository.
|
||||
|
||||
## Content
|
||||
|
||||
Defer to our
|
||||
[Contributing/Documentation](https://coder.com/docs/contributing/documentation)
|
||||
page for rules on technical writing.
|
||||
Defer to our [Contributing/Documentation](../contributing/documentation.md) page
|
||||
for rules on technical writing.
|
||||
|
||||
### Adding Photos
|
||||
|
||||
|
||||
Reference in New Issue
Block a user