@@ -482,9 +482,9 @@ func As(ctx context.Context, actor rbac.Subject) context.Context {
482
482
// running the insertFunc. The insertFunc is expected to return the object that
483
483
// was inserted.
484
484
func insert [
485
- ObjectType any ,
486
- ArgumentType any ,
487
- Insert func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
485
+ ObjectType any ,
486
+ ArgumentType any ,
487
+ Insert func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
488
488
](
489
489
logger slog.Logger ,
490
490
authorizer rbac.Authorizer ,
@@ -495,9 +495,9 @@ func insert[
495
495
}
496
496
497
497
func insertWithAction [
498
- ObjectType any ,
499
- ArgumentType any ,
500
- Insert func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
498
+ ObjectType any ,
499
+ ArgumentType any ,
500
+ Insert func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
501
501
](
502
502
logger slog.Logger ,
503
503
authorizer rbac.Authorizer ,
@@ -524,10 +524,10 @@ func insertWithAction[
524
524
}
525
525
526
526
func deleteQ [
527
- ObjectType rbac.Objecter ,
528
- ArgumentType any ,
529
- Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
530
- Delete func (ctx context.Context , arg ArgumentType ) error ,
527
+ ObjectType rbac.Objecter ,
528
+ ArgumentType any ,
529
+ Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
530
+ Delete func (ctx context.Context , arg ArgumentType ) error ,
531
531
](
532
532
logger slog.Logger ,
533
533
authorizer rbac.Authorizer ,
@@ -539,10 +539,10 @@ func deleteQ[
539
539
}
540
540
541
541
func updateWithReturn [
542
- ObjectType rbac.Objecter ,
543
- ArgumentType any ,
544
- Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
545
- UpdateQuery func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
542
+ ObjectType rbac.Objecter ,
543
+ ArgumentType any ,
544
+ Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
545
+ UpdateQuery func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
546
546
](
547
547
logger slog.Logger ,
548
548
authorizer rbac.Authorizer ,
@@ -553,10 +553,10 @@ func updateWithReturn[
553
553
}
554
554
555
555
func update [
556
- ObjectType rbac.Objecter ,
557
- ArgumentType any ,
558
- Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
559
- Exec func (ctx context.Context , arg ArgumentType ) error ,
556
+ ObjectType rbac.Objecter ,
557
+ ArgumentType any ,
558
+ Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
559
+ Exec func (ctx context.Context , arg ArgumentType ) error ,
560
560
](
561
561
logger slog.Logger ,
562
562
authorizer rbac.Authorizer ,
@@ -574,9 +574,9 @@ func update[
574
574
// user cannot read the resource. This is because the resource details are
575
575
// required to run a proper authorization check.
576
576
func fetchWithAction [
577
- ArgumentType any ,
578
- ObjectType rbac.Objecter ,
579
- DatabaseFunc func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
577
+ ArgumentType any ,
578
+ ObjectType rbac.Objecter ,
579
+ DatabaseFunc func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
580
580
](
581
581
logger slog.Logger ,
582
582
authorizer rbac.Authorizer ,
@@ -607,9 +607,9 @@ func fetchWithAction[
607
607
}
608
608
609
609
func fetch [
610
- ArgumentType any ,
611
- ObjectType rbac.Objecter ,
612
- DatabaseFunc func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
610
+ ArgumentType any ,
611
+ ObjectType rbac.Objecter ,
612
+ DatabaseFunc func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
613
613
](
614
614
logger slog.Logger ,
615
615
authorizer rbac.Authorizer ,
@@ -622,10 +622,10 @@ func fetch[
622
622
// from SQL 'exec' functions which only return an error.
623
623
// See fetchAndQuery for more information.
624
624
func fetchAndExec [
625
- ObjectType rbac.Objecter ,
626
- ArgumentType any ,
627
- Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
628
- Exec func (ctx context.Context , arg ArgumentType ) error ,
625
+ ObjectType rbac.Objecter ,
626
+ ArgumentType any ,
627
+ Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
628
+ Exec func (ctx context.Context , arg ArgumentType ) error ,
629
629
](
630
630
logger slog.Logger ,
631
631
authorizer rbac.Authorizer ,
@@ -648,10 +648,10 @@ func fetchAndExec[
648
648
// **before** the query runs. The returns from the fetch are only used to
649
649
// assert rbac. The final return of this function comes from the Query function.
650
650
func fetchAndQuery [
651
- ObjectType rbac.Objecter ,
652
- ArgumentType any ,
653
- Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
654
- Query func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
651
+ ObjectType rbac.Objecter ,
652
+ ArgumentType any ,
653
+ Fetch func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
654
+ Query func (ctx context.Context , arg ArgumentType ) (ObjectType , error ),
655
655
](
656
656
logger slog.Logger ,
657
657
authorizer rbac.Authorizer ,
@@ -685,9 +685,9 @@ func fetchAndQuery[
685
685
// fetchWithPostFilter is like fetch, but works with lists of objects.
686
686
// SQL filters are much more optimal.
687
687
func fetchWithPostFilter [
688
- ArgumentType any ,
689
- ObjectType rbac.Objecter ,
690
- DatabaseFunc func (ctx context.Context , arg ArgumentType ) ([]ObjectType , error ),
688
+ ArgumentType any ,
689
+ ObjectType rbac.Objecter ,
690
+ DatabaseFunc func (ctx context.Context , arg ArgumentType ) ([]ObjectType , error ),
691
691
](
692
692
authorizer rbac.Authorizer ,
693
693
action policy.Action ,
@@ -1074,6 +1074,24 @@ func (q *querier) customRoleCheck(ctx context.Context, role database.CustomRole)
1074
1074
return nil
1075
1075
}
1076
1076
1077
+ func (q * querier ) UpdatePresetPrebuildStatus (ctx context.Context , arg database.UpdatePresetPrebuildStatusParams ) error {
1078
+ preset , err := q .db .GetPresetByID (ctx , arg .PresetID )
1079
+ if err != nil {
1080
+ return err
1081
+ }
1082
+
1083
+ object := rbac .ResourceTemplate .
1084
+ WithID (preset .TemplateID .UUID ).
1085
+ InOrg (preset .OrganizationID )
1086
+
1087
+ err = q .authorizeContext (ctx , policy .ActionUpdate , object )
1088
+ if err != nil {
1089
+ return err
1090
+ }
1091
+
1092
+ return q .db .UpdatePresetPrebuildStatus (ctx , arg )
1093
+ }
1094
+
1077
1095
func (q * querier ) AcquireLock (ctx context.Context , id int64 ) error {
1078
1096
return q .db .AcquireLock (ctx , id )
1079
1097
}
@@ -4178,24 +4196,6 @@ func (q *querier) UpdateOrganizationDeletedByID(ctx context.Context, arg databas
4178
4196
return deleteQ (q .log , q .auth , q .db .GetOrganizationByID , deleteF )(ctx , arg .ID )
4179
4197
}
4180
4198
4181
- func (q * querier ) UpdatePrebuildStatus (ctx context.Context , arg database.UpdatePrebuildStatusParams ) error {
4182
- preset , err := q .db .GetPresetByID (ctx , arg .PresetID )
4183
- if err != nil {
4184
- return err
4185
- }
4186
-
4187
- object := rbac .ResourceTemplate .
4188
- WithID (preset .TemplateID .UUID ).
4189
- InOrg (preset .OrganizationID )
4190
-
4191
- err = q .authorizeContext (ctx , policy .ActionUpdate , object )
4192
- if err != nil {
4193
- return err
4194
- }
4195
-
4196
- return q .db .UpdatePrebuildStatus (ctx , arg )
4197
- }
4198
-
4199
4199
func (q * querier ) UpdateProvisionerDaemonLastSeenAt (ctx context.Context , arg database.UpdateProvisionerDaemonLastSeenAtParams ) error {
4200
4200
if err := q .authorizeContext (ctx , policy .ActionUpdate , rbac .ResourceProvisionerDaemon ); err != nil {
4201
4201
return err
0 commit comments