1
0
mirror of https://github.com/strongdm/comply synced 2024-12-23 14:07:34 +00:00

Allow a procedure definition to include custom labels

This commit is contained in:
Paddy Byers 2019-08-11 11:24:27 +01:00
parent c5a1bd804b
commit 0a17a03637
3 changed files with 23 additions and 12 deletions

View File

@ -38,10 +38,7 @@ func procedureAction(c *cli.Context) error {
for _, procedure := range procedures {
if procedure.ID == procedureID {
err = tp.Create(&model.Ticket{
Name: procedure.Name,
Body: fmt.Sprintf("%s\n\n\n---\nProcedure-ID: %s", procedure.Body, procedure.ID),
}, []string{"comply", "comply-procedure"})
err = tp.Create(procedure.NewTicket(), procedure.Labels())
if err != nil {
return err
}

View File

@ -1,11 +1,17 @@
package model
import "time"
import (
"fmt"
"time"
)
var defaultLabels = []string{"comply", "comply-procedure"}
type Procedure struct {
Name string `yaml:"name"`
ID string `yaml:"id"`
Cron string `yaml:"cron"`
Name string `yaml:"name"`
ID string `yaml:"id"`
Cron string `yaml:"cron"`
CustomLabels []string `yaml:"labels"`
Revisions []Revision `yaml:"majorRevisions"`
Satisfies Satisfaction `yaml:"satisfies"`
@ -14,3 +20,14 @@ type Procedure struct {
ModifiedAt time.Time
Body string
}
func (p *Procedure) Labels() []string {
return append(defaultLabels, p.CustomLabels...)
}
func (p *Procedure) NewTicket() *Ticket {
return &Ticket{
Name: p.Name,
Body: fmt.Sprintf("%s\n\n\n---\nProcedure-ID: %s", p.Body, p.ID),
}
}

View File

@ -114,9 +114,6 @@ func trigger(procedure *model.Procedure) error {
}
tp := model.GetPlugin(model.TicketSystem(ts))
err = tp.Create(&model.Ticket{
Name: procedure.Name,
Body: fmt.Sprintf("%s\n\n\n---\nProcedure-ID: %s", procedure.Body, procedure.ID),
}, []string{"comply", "comply-procedure"})
err = tp.Create(procedure.NewTicket(), procedure.Labels())
return err
}