Skip to content

feat(cli): create workspace using parameters from existing workspace #10604

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 10 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
copy-parameters-from
  • Loading branch information
mtojek committed Nov 9, 2023
commit 5861631d3b9fb36206b1193aa551b72c5ae2c294
18 changes: 9 additions & 9 deletions cli/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ func (r *RootCmd) create() *clibase.Cmd {
stopAfter time.Duration
workspaceName string

parameterFlags workspaceParameterFlags
autoUpdates string
copyParameters string
parameterFlags workspaceParameterFlags
autoUpdates string
copyParametersFrom string
)
client := new(codersdk.Client)
cmd := &clibase.Cmd{
Expand Down Expand Up @@ -78,8 +78,8 @@ func (r *RootCmd) create() *clibase.Cmd {
}

var sourceWorkspace codersdk.Workspace
if copyParameters != "" {
sourceWorkspaceOwner, sourceWorkspaceName, err := splitNamedWorkspace(copyParameters)
if copyParametersFrom != "" {
sourceWorkspaceOwner, sourceWorkspaceName, err := splitNamedWorkspace(copyParametersFrom)
if err != nil {
return err
}
Expand Down Expand Up @@ -157,7 +157,7 @@ func (r *RootCmd) create() *clibase.Cmd {
}

var sourceWorkspaceParameters []codersdk.WorkspaceBuildParameter
if copyParameters != "" {
if copyParametersFrom != "" {
sourceWorkspaceParameters, err = client.WorkspaceBuildParameters(inv.Context(), sourceWorkspace.LatestBuild.ID)
if err != nil {
return xerrors.Errorf("get source workspace build parameters: %w", err)
Expand Down Expand Up @@ -245,10 +245,10 @@ func (r *RootCmd) create() *clibase.Cmd {
Value: clibase.StringOf(&autoUpdates),
},
clibase.Option{
Flag: "copy-parameters",
Env: "CODER_WORKSPACE_COPY_PARAMETERS",
Flag: "copy-parameters-from",
Env: "CODER_WORKSPACE_COPY_PARAMETERS_FROM",
Description: "Specify the source workspace name to copy parameters from.",
Value: clibase.StringOf(&copyParameters),
Value: clibase.StringOf(&copyParametersFrom),
},
cliui.SkipPromptOption(),
)
Expand Down
2 changes: 1 addition & 1 deletion cli/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func TestCreateWithRichParameters(t *testing.T) {
// Secondly, create a new workspace using parameters from the previous workspace.
const otherWorkspace = "other-workspace"

inv, root = clitest.New(t, "create", "--copy-parameters", "my-workspace", otherWorkspace, "-y")
inv, root = clitest.New(t, "create", "--copy-parameters-from", "my-workspace", otherWorkspace, "-y")
clitest.SetupConfig(t, member, root)
pty = ptytest.New(t).Attach(inv)
inv.Stdout = pty.Output()
Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_create_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ OPTIONS:
Specify automatic updates setting for the workspace (accepts 'always'
or 'never').

--copy-parameters string, $CODER_WORKSPACE_COPY_PARAMETERS
--copy-parameters-from string, $CODER_WORKSPACE_COPY_PARAMETERS_FROM
Specify the source workspace name to copy parameters from.

--parameter string-array, $CODER_RICH_PARAMETER
Expand Down
10 changes: 5 additions & 5 deletions docs/cli/create.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.