| 1 | package library |
| 2 | |
| 3 | import ( |
| 4 | "amadan.net/oficina/equipo/internal/equipo/kernel" |
| 5 | "amadan.net/oficina/equipo/internal/taskplan" |
| 6 | "context" |
| 7 | ) |
| 8 | |
| 9 | func (s *Application) SavePlaybook(ctx context.Context, a kernel.Actor, in PlaybookInput, m kernel.Mutation) (row Playbook, err error) { |
| 10 | a.Address = s.Normalize(a.Address) |
| 11 | err = s.libraryWrite(ctx, func(l *Store) error { row, err = l.SavePlaybook(a, in, m); return err }) |
| 12 | return |
| 13 | } |
| 14 | func (s *Application) DeletePlaybook(ctx context.Context, a kernel.Actor, id string, m kernel.Mutation) error { |
| 15 | a.Address = s.Normalize(a.Address) |
| 16 | return s.libraryWrite(ctx, func(l *Store) error { return l.DeletePlaybook(a, id, m) }) |
| 17 | } |
| 18 | func (s *Application) SetPlaybookDefault(ctx context.Context, a kernel.Actor, project int64, kind taskplan.Kind, id string, m kernel.Mutation) error { |
| 19 | a.Address = s.Normalize(a.Address) |
| 20 | return s.libraryWrite(ctx, func(l *Store) error { return l.SetPlaybookDefault(a, project, kind, id, m) }) |
| 21 | } |
| 22 | func (s *Application) InstantiatePlaybook(ctx context.Context, a kernel.Actor, id, task string) (p taskplan.Plan, err error) { |
| 23 | a.Address = s.Normalize(a.Address) |
| 24 | err = s.libraryWrite(ctx, func(l *Store) error { p, err = l.InstantiatePlaybook(a, id, task); return err }) |
| 25 | return |
| 26 | } |
| 27 | func (s *Application) ResolvePlaybook(ctx context.Context, a kernel.Actor, project int64, kind taskplan.Kind) (row Playbook, err error) { |
| 28 | err = s.read(ctx, a, func(l *Store) error { row, err = l.ResolvePlaybook(a, project, kind); return err }) |
| 29 | return |
| 30 | } |
| 31 | func (s *Application) Playbook(ctx context.Context, a kernel.Actor, id string) (row Playbook, err error) { |
| 32 | err = s.read(ctx, a, func(l *Store) error { row, err = l.Playbook(a, id); return err }) |
| 33 | return |
| 34 | } |
| 35 | func (s *Application) Playbooks(ctx context.Context, a kernel.Actor) (rows []Playbook, err error) { |
| 36 | err = s.read(ctx, a, func(l *Store) error { rows, err = l.Playbooks(a); return err }) |
| 37 | return |
| 38 | } |
| 39 | func (s *Application) InstallPlaybookTemplate(ctx context.Context, a kernel.Actor, ref TemplateRef, m kernel.Mutation) (row Playbook, err error) { |
| 40 | a.Address = s.Normalize(a.Address) |
| 41 | err = s.libraryWrite(ctx, func(l *Store) error { row, err = l.InstallPlaybookTemplate(a, ref, m); return err }) |
| 42 | return |
| 43 | } |
| 44 | func (s *Application) PlaybookTemplateDiff(ctx context.Context, a kernel.Actor, id string, ref TemplateRef) (diff TemplateDiff, err error) { |
| 45 | err = s.read(ctx, a, func(l *Store) error { diff, err = l.PlaybookTemplateDiff(a, id, ref); return err }) |
| 46 | return |
| 47 | } |
| 48 | func (s *Application) ApplyPlaybookTemplate(ctx context.Context, a kernel.Actor, id string, diff TemplateDiff, fields []string, m kernel.Mutation) (row Playbook, err error) { |
| 49 | a.Address = s.Normalize(a.Address) |
| 50 | err = s.libraryWrite(ctx, func(l *Store) error { row, err = l.ApplyPlaybookTemplate(a, id, diff, fields, m); return err }) |
| 51 | return |
| 52 | } |
| 53 | func (s *Application) SavePlaybookSuggestion(ctx context.Context, a kernel.Actor, id string, in PlaybookInput, m kernel.Mutation) (row Playbook, err error) { |
| 54 | a.Address = s.Normalize(a.Address) |
| 55 | err = s.libraryWrite(ctx, func(l *Store) error { row, err = l.SavePlaybookSuggestion(a, id, in, m); return err }) |
| 56 | return |
| 57 | } |
| 58 | func (s *Application) PlaybookSuggestion(ctx context.Context, a kernel.Actor, id string) (raw string, revision int64, err error) { |
| 59 | err = s.read(ctx, a, func(l *Store) error { raw, revision, err = l.PlaybookSuggestion(a, id); return err }) |
| 60 | return |
| 61 | } |
| 62 | |