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

Conversation

mtojek
Copy link
Member

@mtojek mtojek commented Nov 9, 2023

Fixes: #9923

This PR adds support for duplicating workspace using CLI. It is implemented as part of the coder create command according to this design (thanks @Parkreiner!).

./scripts/coder-dev.sh create --copy-parameters-from=workspace-5 workspace-6-copy

@mtojek mtojek self-assigned this Nov 9, 2023
@mtojek mtojek marked this pull request as ready for review November 9, 2023 16:17
@mtojek mtojek requested review from Parkreiner and johnstcn November 9, 2023 16:17
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Just an edge case I'd like to see tested, and some potential speed-ups in creation.

template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID)

// Firstly, create a regular workspace using template with parameters.
inv, root := clitest.New(t, "create", "my-workspace", "--template", template.Name, "-y",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: we now have dbfake.WorkspaceWithAgent if you want to speed things up

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WorkspaceWithAgent looks efficient, but I need a workspace with build parameters and a corresponding template with rich parameters. Not sure if the function supports it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢 🎺

@matifali
Copy link
Member

matifali commented Nov 9, 2023

May be we should call it coder clone. Thoughts?
Or coder create --clone=old-workdoace new-workspace

We can put a disclaimer that it only copies the parameters and not the data stored in persisted resources.

@mtojek
Copy link
Member Author

mtojek commented Nov 9, 2023

@matifali There were concerns raised around the word "clone": comment

@mtojek mtojek merged commit 61fac2d into main Nov 9, 2023
@mtojek mtojek deleted the 9923-cli-duplicate branch November 9, 2023 18:22
@github-actions github-actions bot locked and limited conversation to collaborators Nov 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Duplicate workspace
3 participants