@@ -227,6 +227,9 @@ func (r *RootCmd) templatePush() *clibase.Cmd {
227
227
allowUserAutostop :allowUserAutostop ,
228
228
requireActiveVersion :requireActiveVersion ,
229
229
})
230
+ if err != nil {
231
+ return err
232
+ }
230
233
231
234
organization ,err := CurrentOrganization (inv ,client )
232
235
if err != nil {
@@ -323,53 +326,47 @@ func (r *RootCmd) templatePush() *clibase.Cmd {
323
326
}
324
327
}
325
328
326
- editTemplate := requireActiveVersion ||
327
- disableEveryone ||
328
- defaultTTL != 0 ||
329
- failureTTL != 0 ||
330
- dormancyThreshold != 0 ||
331
- dormancyAutoDeletion != 0 ||
332
- maxTTL != 0
333
- if editTemplate {
334
- template ,err := client .TemplateByName (inv .Context (),organization .ID ,name )
335
- if err != nil {
336
- return err
337
- }
338
- req := updateTemplateMetaRequest (updateTemplateMetaArgs {
339
- client :client ,
340
- inv :inv ,
341
- template :template ,
342
- unsetAutostopRequirementDaysOfWeek :unsetAutostopRequirementDaysOfWeek ,
343
-
344
- displayName :displayName ,
345
- description :description ,
346
- icon :icon ,
347
- requireActiveVersion :requireActiveVersion ,
348
- disableEveryone :disableEveryone ,
349
- defaultTTL :defaultTTL ,
350
- failureTTL :failureTTL ,
351
- dormancyThreshold :dormancyThreshold ,
352
- dormancyAutoDeletion :dormancyAutoDeletion ,
353
- maxTTL :maxTTL ,
354
- autostopRequirementDaysOfWeek :autostopRequirementDaysOfWeek ,
355
- autostopRequirementWeeks :autostopRequirementWeeks ,
356
- autostartRequirementDaysOfWeek :autostartRequirementDaysOfWeek ,
357
- allowUserAutostart :allowUserAutostart ,
358
- allowUserAutostop :allowUserAutostop ,
359
- allowUserCancelWorkspaceJobs :allowUserCancelWorkspaceJobs ,
360
- deprecationMessage :deprecationMessage ,
361
- })
329
+ _ ,_ = fmt .Fprintf (inv .Stdout ,"Updated version at %s!\n " ,pretty .Sprint (cliui .DefaultStyles .DateTimeStamp ,time .Now ().Format (time .Stamp )))
362
330
363
- _ ,err = client .UpdateTemplateMeta (inv .Context (),template .ID ,req )
364
- if err != nil {
365
- return xerrors .Errorf ("update template metadata: %w" ,err )
366
- }
367
- if err != nil {
368
- return err
369
- }
331
+ // refresh template data for edit api call
332
+ template ,err = client .TemplateByName (inv .Context (),organization .ID ,name )
333
+ if err != nil {
334
+ return err
370
335
}
336
+ req := updateTemplateMetaRequest (updateTemplateMetaArgs {
337
+ client :client ,
338
+ inv :inv ,
339
+ template :template ,
340
+ unsetAutostopRequirementDaysOfWeek :unsetAutostopRequirementDaysOfWeek ,
341
+
342
+ displayName :displayName ,
343
+ description :description ,
344
+ icon :icon ,
345
+ requireActiveVersion :requireActiveVersion ,
346
+ disableEveryone :disableEveryone ,
347
+ defaultTTL :defaultTTL ,
348
+ failureTTL :failureTTL ,
349
+ dormancyThreshold :dormancyThreshold ,
350
+ dormancyAutoDeletion :dormancyAutoDeletion ,
351
+ maxTTL :maxTTL ,
352
+ autostopRequirementDaysOfWeek :autostopRequirementDaysOfWeek ,
353
+ autostopRequirementWeeks :autostopRequirementWeeks ,
354
+ autostartRequirementDaysOfWeek :autostartRequirementDaysOfWeek ,
355
+ allowUserAutostart :allowUserAutostart ,
356
+ allowUserAutostop :allowUserAutostop ,
357
+ allowUserCancelWorkspaceJobs :allowUserCancelWorkspaceJobs ,
358
+ deprecationMessage :deprecationMessage ,
359
+ })
360
+
361
+ _ ,err = client .UpdateTemplateMeta (inv .Context (),template .ID ,req )
362
+ if err != nil {
363
+ return xerrors .Errorf ("update template metadata: %w" ,err )
364
+ }
365
+ if err != nil {
366
+ return err
367
+ }
368
+ _ ,_ = fmt .Fprintf (inv .Stdout ,"Updated template metadata at %s!\n " ,pretty .Sprint (cliui .DefaultStyles .DateTimeStamp ,time .Now ().Format (time .Stamp )))
371
369
372
- _ ,_ = fmt .Fprintf (inv .Stdout ,"Updated version at %s!\n " ,pretty .Sprint (cliui .DefaultStyles .DateTimeStamp ,time .Now ().Format (time .Stamp )))
373
370
return nil
374
371
},
375
372
}