oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package equipo
2
3import (
4 "amadan.net/oficina/equipo/internal/equipo/team"
5 "amadan.net/oficina/equipo/internal/runnerproto"
6 "encoding/json"
7 "gorm.io/gorm"
8)
9
10func dropProfileApproval(tx *gorm.DB, assignment, id string) error {
11 var a runnerAssignment
12 if err := tx.First(&a, "id=?", assignment).Error; err != nil {
13 return storeError(err)
14 }
15 value, err := assignmentValue(a)
16 if err != nil {
17 return err
18 }
19 iso := runnerproto.WithoutApproval(value.Selection.Isolation, id)
20 raw, err := json.Marshal(iso)
21 if err != nil {
22 return err
23 }
24 if err = tx.Model(&runnerAssignment{}).Where("id=?", assignment).Select("Isolation").Updates(&runnerAssignment{Isolation: string(raw)}).Error; err != nil {
25 return storeError(err)
26 }
27 if err = syncRunnerEventExposure(tx, assignment, iso, id); err != nil {
28 return err
29 }
30 var artifacts []executionArtifacts
31 if err = tx.Where("attempt_id=? AND job_id=?", a.AttemptID, a.JobID).Find(&artifacts).Error; err != nil {
32 return storeError(err)
33 }
34 for _, art := range artifacts {
35 var p team.Provenance
36 if err = json.Unmarshal([]byte(art.Provenance), &p); err != nil {
37 return err
38 }
39 p.Isolation = runnerproto.WithoutApproval(p.Isolation, id)
40 raw, err = json.Marshal(p)
41 if err != nil {
42 return err
43 }
44 if err = tx.Model(&executionArtifacts{}).Where("id=?", art.ID).Select("Provenance").Updates(&executionArtifacts{Provenance: string(raw)}).Error; err != nil {
45 return storeError(err)
46 }
47 }
48 return nil
49}
50