8000 feat: Allow inheriting parameters from previous template_versions when updating a template by Emyrk · Pull Request #2397 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: Allow inheriting parameters from previous template_versions when updating a template #2397

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 18 commits into from
Jun 17, 2022
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
Rename field
  • Loading branch information
Emyrk committed Jun 16, 2022
commit 5f881aaece83f6c4f33cb4142539e4e4611d27f0
6 changes: 3 additions & 3 deletions cli/templatecreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ type createValidTemplateVersionArgs struct {
ParameterFile string
// Template is only required if updating a template's active version.
Template *codersdk.Template
// ReuseParams will attempt to reuse params from the Template field
// ReuseParameters will attempt to reuse params from the Template field
// before prompting the user. Set to false to always prompt for param
// values.
ReuseParams bool
ReuseParameters bool
}

func createValidTemplateVersion(cmd *cobra.Command, args createValidTemplateVersionArgs, parameters ...codersdk.CreateParameterRequest) (*codersdk.TemplateVersion, []codersdk.CreateParameterRequest, error) {
Copy link
Member
@johnstcn johnstcn Jun 16, 2022

Choose a reason for hiding this comment

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

yeah we're there now :D (args struct)

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 really want to try refactoring this function. It's growing limbs and becoming quite large lol.

"Get it working" was my first step...

Expand Down Expand Up @@ -204,7 +204,7 @@ func createValidTemplateVersion(cmd *cobra.Command, args createValidTemplateVers
// templateID is provided. This allows pulling params from the last
// version instead of prompting if we are updating template versions.
lastParameterValues := make(map[string]codersdk.Parameter)
if args.ReuseParams && args.Template != nil {
if args.ReuseParameters && args.Template != nil {
activeVersion, err := client.TemplateVersion(cmd.Context(), args.Template.ActiveVersionID)
if err != nil {
return nil, nil, xerrors.Errorf("Fetch current active template version: %w", err)
Expand Down
14 changes: 7 additions & 7 deletions cli/templateupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ func templateUpdate() *cobra.Command {
spin.Stop()

job, _, err := createValidTemplateVersion(cmd, createValidTemplateVersionArgs{
Client: client,
Organization: organization,
Provisioner: database.ProvisionerType(provisioner),
FileHash: resp.Hash,
ParameterFile: parameterFile,
Template: &template,
ReuseParams: true,
Client: client,
Organization: organization,
Provisioner: database.ProvisionerType(provisioner),
FileHash: resp.Hash,
ParameterFile: parameterFile,
Template: &template,
ReuseParameters: true,
})
if err != nil {
return err
Expand Down
0