Download this file
| 1 | package planflow |
| 2 | |
| 3 | import ( |
| 4 | "amadan.net/oficina/equipo/internal/runner/provider" |
| 5 | "amadan.net/oficina/equipo/internal/runnerproto" |
| 6 | "reflect" |
| 7 | ) |
| 8 | |
| 9 | type Profile = provider.ActionProfile |
| 10 | |
| 11 | func Resolve(b runnerproto.StepBrief) (Profile, error) { |
| 12 | if b.PlanRevision < 1 || b.StepKey == "" || b.Action == "" { |
| 13 | return Profile{}, provider.ErrIdentity |
| 14 | } |
| 15 | switch b.Action { |
| 16 | case "checks", "publish": |
| 17 | return Profile{Action: b.Action, ReadOnly: true}, nil |
| 18 | } |
| 19 | if b.SpecialistKey == "" || b.SpecialistRevision < 1 { |
| 20 | return Profile{}, provider.ErrIdentity |
| 21 | } |
| 22 | return provider.Profile(b.Action) |
| 23 | } |
| 24 | func Validate(a runnerproto.Assignment, b runnerproto.RunnerBrief) (Profile, error) { |
| 25 | if !reflect.DeepEqual(a.Selection, b.Selection) || a.StepKey != b.Step.StepKey { |
| 26 | return Profile{}, provider.ErrIdentity |
| 27 | } |
| 28 | if b.Target.Kind == "project_read" && b.Step.Action == "scope" { |
| 29 | return provider.Profile("recommend") |
| 30 | } |
| 31 | return Resolve(b.Step) |
| 32 | } |
| 33 | |