@@ -22,7 +22,6 @@ import (
22
22
"github.com/coder/coder/coderd/httpmw"
23
23
"github.com/coder/coder/coderd/rbac"
24
24
"github.com/coder/coder/coderd/telemetry"
25
- "github.com/coder/coder/coderd/util/ptr"
26
25
"github.com/coder/coder/codersdk"
27
26
)
28
27
@@ -236,28 +235,22 @@ func (api *API) postTemplateByOrganization(rw http.ResponseWriter, r *http.Reque
236
235
return
237
236
}
238
237
239
- minAutostartInterval := minAutostartIntervalDefault
240
- if ! ptr .NilOrZero (createTemplate .MinAutostartIntervalMillis ) {
241
- minAutostartInterval = time .Duration (* createTemplate .MinAutostartIntervalMillis ) * time .Millisecond
242
- }
243
-
244
238
var dbTemplate database.Template
245
239
var template codersdk.Template
246
240
err = api .Database .InTx (func (tx database.Store ) error {
247
241
now := database .Now ()
248
242
dbTemplate , err = tx .InsertTemplate (ctx , database.InsertTemplateParams {
249
- ID : uuid .New (),
250
- CreatedAt : now ,
251
- UpdatedAt : now ,
252
- OrganizationID : organization .ID ,
253
- Name : createTemplate .Name ,
254
- Provisioner : importJob .Provisioner ,
255
- ActiveVersionID : templateVersion .ID ,
256
- Description : createTemplate .Description ,
257
- MaxTtl : int64 (maxTTL ),
258
- MinAutostartInterval : int64 (minAutostartInterval ),
259
- CreatedBy : apiKey .UserID ,
260
- UserACL : database.TemplateACL {},
243
+ ID : uuid .New (),
244
+ CreatedAt : now ,
245
+ UpdatedAt : now ,
246
+ OrganizationID : organization .ID ,
247
+ Name : createTemplate .Name ,
248
+ Provisioner : importJob .Provisioner ,
249
+ ActiveVersionID : templateVersion .ID ,
250
+ Description : createTemplate .Description ,
251
+ MaxTtl : int64 (maxTTL ),
252
+ CreatedBy : apiKey .UserID ,
253
+ UserACL : database.TemplateACL {},
261
254
GroupACL : database.TemplateACL {
262
255
organization .ID .String (): []rbac.Action {rbac .ActionRead },
263
256
},
@@ -467,9 +460,6 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
467
460
if req .MaxTTLMillis < 0 {
468
461
validErrs = append (validErrs , codersdk.ValidationError {Field : "max_ttl_ms" , Detail : "Must be a positive integer." })
469
462
}
470
- if req .MinAutostartIntervalMillis < 0 {
471
- validErrs = append (validErrs , codersdk.ValidationError {Field : "min_autostart_interval_ms" , Detail : "Must be a positive integer." })
472
- }
473
463
if req .MaxTTLMillis > maxTTLDefault .Milliseconds () {
474
464
validErrs = append (validErrs , codersdk.ValidationError {Field : "max_ttl_ms" , Detail : "Cannot be greater than " + maxTTLDefault .String ()})
475
465
}
@@ -501,8 +491,7 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
501
491
if req .Name == template .Name &&
502
492
req .Description == template .Description &&
503
493
req .Icon == template .Icon &&
504
- req .MaxTTLMillis == time .Duration (template .MaxTtl ).Milliseconds () &&
505
- req .MinAutostartIntervalMillis == time .Duration (template .MinAutostartInterval ).Milliseconds () {
494
+ req .MaxTTLMillis == time .Duration (template .MaxTtl ).Milliseconds () {
506
495
return nil
507
496
}
508
497
@@ -511,26 +500,21 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
511
500
desc := req .Description
512
501
icon := req .Icon
513
502
maxTTL := time .Duration (req .MaxTTLMillis ) * time .Millisecond
514
- minAutostartInterval := time .Duration (req .MinAutostartIntervalMillis ) * time .Millisecond
515
503
516
504
if name == "" {
517
505
name = template .Name
518
506
}
519
507
if desc == "" {
520
508
desc = template .Description
521
509
}
522
- if minAutostartInterval == 0 {
523
- minAutostartInterval = time .Duration (template .MinAutostartInterval )
524
- }
525
510
526
511
updated , err = tx .UpdateTemplateMetaByID (ctx , database.UpdateTemplateMetaByIDParams {
527
- ID : template .ID ,
528
- UpdatedAt : database .Now (),
529
- Name : name ,
530
- Description : desc ,
531
- Icon : icon ,
532
- MaxTtl : int64 (maxTTL ),
533
- MinAutostartInterval : int64 (minAutostartInterval ),
512
+ ID : template .ID ,
513
+ UpdatedAt : database .Now (),
514
+ Name : name ,
515
+ Description : desc ,
516
+ Icon : icon ,
517
+ MaxTtl : int64 (maxTTL ),
534
518
})
535
519
if err != nil {
536
520
return err
@@ -666,18 +650,17 @@ func (api *API) autoImportTemplate(ctx context.Context, opts autoImportTemplateO
666
650
667
651
// Create template
668
652
template , err = tx .InsertTemplate (ctx , database.InsertTemplateParams {
669
- ID : uuid .New (),
670
- CreatedAt : now ,
671
- UpdatedAt : now ,
672
- OrganizationID : opts .orgID ,
673
- Name : opts .name ,
674
- Provisioner : job .Provisioner ,
675
- ActiveVersionID : templateVersion .ID ,
676
- Description : "This template was auto-imported by Coder." ,
677
- MaxTtl : int64 (maxTTLDefault ),
678
- MinAutostartInterval : int64 (minAutostartIntervalDefault ),
679
- CreatedBy : opts .userID ,
680
- UserACL : database.TemplateACL {},
653
+ ID : uuid .New (),
654
+ CreatedAt : now ,
655
+ UpdatedAt : now ,
656
+ OrganizationID : opts .orgID ,
657
+ Name : opts .name ,
658
+ Provisioner : job .Provisioner ,
659
+ ActiveVersionID : templateVersion .ID ,
660
+ Description : "This template was auto-imported by Coder." ,
661
+ MaxTtl : int64 (maxTTLDefault ),
662
+ CreatedBy : opts .userID ,
663
+ UserACL : database.TemplateACL {},
681
664
GroupACL : database.TemplateACL {
682
665
opts .orgID .String (): []rbac.Action {rbac .ActionRead },
683
666
},
0 commit comments