Skip to content

feat: Updating workspace prompts new parameters #2598

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 7 commits into from
Jun 27, 2022

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Jun 22, 2022

What this does

Prompts users if they update a workspace that requires new parameters.

Optionally always prompt params and force updating even if not out of date.

coder update <name> --always-prompt

#2463

@Emyrk Emyrk marked this pull request as ready for review June 22, 2022 23:44
@Emyrk Emyrk requested a review from a team as a code owner June 22, 2022 23:44
@Emyrk
Copy link
Member Author

Emyrk commented Jun 22, 2022

I might spend some time trying to refactor this and template update to share param prompt code.
For now, I just make workspace create and workspace update share the same param handling code

Copy link
Contributor

@presleyp presleyp left a comment

Choose a reason for hiding this comment

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

frontend ✔️

@Emyrk Emyrk requested a review from deansheather June 24, 2022 15:19
@@ -53,4 +80,8 @@ func update() *cobra.Command {
return nil
},
}

cmd.Flags().BoolVar(&alwaysPrompt, "always-prompt", false, "Always prompt all parameters. Does not pull parameter values from existing workspace")
Copy link
Member

Choose a reason for hiding this comment

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

--reprompt sounds better. Or we could keep it called --always-prompt and ask the user if they want to edit their parameters using a y/n prompt.

Copy link
Member Author

Choose a reason for hiding this comment

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

Use --always-prompt and a y/n prompt?

I am not sold on always-prompt either, was unsure on what exactly to use 🤔

Copy link
Member

Choose a reason for hiding this comment

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

I meant --always-prompt, but if not specified ask them if they want to change values with a y/n prompt

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh. I was trying to keep the flow quick.

I think we need to invest time into thinking about our UX in general. Idk if we should do coder edit or coder configure to adjust params, but we probably need some command UX to manage params in general.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can add this prompt though if always-prompt is omitted 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Our y/n prompt only returns yes or error. We need to modify it to accept a proper y/n if we want to do something other than abort on no.

@@ -37,6 +37,8 @@ type CreateWorkspaceBuildRequest struct {
Transition WorkspaceTransition `json:"transition" validate:"oneof=create start stop delete,required"`
DryRun bool `json:"dry_run,omitempty"`
ProvisionerState []byte `json:"state,omitempty"`
// ParameterValues are optional. It will write params to the 'workspace' scope.
Copy link
Member

Choose a reason for hiding this comment

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

You should explain the behavior that it doesn't delete the old values, but any present values will overwrite any existing values with the same name.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is true... I wonder if I should delete the unused params 🤔. I can add this in another PR and test it more

Comment on lines +50 to +55
parameters, err := prepWorkspaceBuild(cmd, client, prepWorkspaceBuildArgs{
Template: template,
ExistingParams: existingParams,
ParameterFile: parameterFile,
NewWorkspaceName: workspace.Name,
})
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if this always ran and had an argument to prompt for missing params or not instead of only running if they prompted for params. We'd be able to always dry-run this way

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean instead of passing "ExistingParams", detect that inside the prepWorkspaceBuild? Cause if so, I do want to do this. Templates use similar logic, so I want to refactor the create/update of both workspaces/templates to use the same code.

I was going to take a look in another PR.

@Emyrk Emyrk enabled auto-merge (squash) June 27, 2022 16:03
@Emyrk Emyrk merged commit f41b50a into main Jun 27, 2022
@Emyrk Emyrk deleted the stevenmasley/update_workspace branch June 27, 2022 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants