feat(cli): support non-active template version pushes (#7488)

So that we can push template updates for testing without impacting
normal users of the template.

---------

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>
Co-authored-by: Muhammad Atif Ali <matifali@live.com>
Co-authored-by: Atif Ali <atif@coder.com>
This commit is contained in:
goodspark
2023-06-03 22:39:00 +00:00
committed by GitHub
co-authored by Ammar Bandukwala Muhammad Atif Ali Atif Ali
parent 1f8e817da7
commit e2613c91a7
4 changed files with 68 additions and 5 deletions
+14 -5
View File
@@ -115,6 +115,7 @@ func (r *RootCmd) templatePush() *clibase.Cmd {
alwaysPrompt bool
provisionerTags []string
uploadFlags templateUploadFlags
activate bool
)
client := new(codersdk.Client)
cmd := &clibase.Cmd{
@@ -172,11 +173,13 @@ func (r *RootCmd) templatePush() *clibase.Cmd {
return xerrors.Errorf("job failed: %s", job.Job.Status)
}
err = client.UpdateActiveTemplateVersion(inv.Context(), template.ID, codersdk.UpdateActiveTemplateVersion{
ID: job.ID,
})
if err != nil {
return err
if activate {
err = client.UpdateActiveTemplateVersion(inv.Context(), template.ID, codersdk.UpdateActiveTemplateVersion{
ID: job.ID,
})
if err != nil {
return err
}
}
_, _ = fmt.Fprintf(inv.Stdout, "Updated version at %s!\n", cliui.Styles.DateTimeStamp.Render(time.Now().Format(time.Stamp)))
@@ -226,6 +229,12 @@ func (r *RootCmd) templatePush() *clibase.Cmd {
Description: "Always prompt all parameters. Does not pull parameter values from active template version.",
Value: clibase.BoolOf(&alwaysPrompt),
},
{
Flag: "activate",
Description: "Whether the new template will be marked active.",
Default: "true",
Value: clibase.BoolOf(&activate),
},
cliui.SkipPromptOption(),
uploadFlags.option(),
}