(ctx context.Context, request *proto.CommitQuotaRequest)
| 916 | } |
| 917 | |
| 918 | func (s *server) CommitQuota(ctx context.Context, request *proto.CommitQuotaRequest) (*proto.CommitQuotaResponse, error) { |
| 919 | ctx, span := s.startTrace(ctx, tracing.FuncName()) |
| 920 | defer span.End() |
| 921 | |
| 922 | //nolint:gocritic // Provisionerd has specific authz rules. |
| 923 | ctx = dbauthz.AsProvisionerd(ctx) |
| 924 | jobID, err := uuid.Parse(request.JobId) |
| 925 | if err != nil { |
| 926 | return nil, xerrors.Errorf("parse job id: %w", err) |
| 927 | } |
| 928 | |
| 929 | job, err := s.Database.GetProvisionerJobByID(ctx, jobID) |
| 930 | if err != nil { |
| 931 | return nil, xerrors.Errorf("get job: %w", err) |
| 932 | } |
| 933 | if !job.WorkerID.Valid { |
| 934 | return nil, xerrors.New("job isn't running yet") |
| 935 | } |
| 936 | |
| 937 | if job.WorkerID.UUID.String() != s.ID.String() { |
| 938 | return nil, xerrors.New("you don't own this job") |
| 939 | } |
| 940 | |
| 941 | q := s.QuotaCommitter.Load() |
| 942 | if q == nil { |
| 943 | // We're probably in community edition or a test. |
| 944 | return &proto.CommitQuotaResponse{ |
| 945 | Budget: -1, |
| 946 | Ok: true, |
| 947 | }, nil |
| 948 | } |
| 949 | return (*q).CommitQuota(ctx, request) |
| 950 | } |
| 951 | |
| 952 | func (s *server) UpdateJob(ctx context.Context, request *proto.UpdateJobRequest) (*proto.UpdateJobResponse, error) { |
| 953 | ctx, span := s.startTrace(ctx, tracing.FuncName()) |
nothing calls this directly
no test coverage detected