mirror of
https://github.com/strongdm/comply
synced 2024-11-16 21:04:54 +00:00
Allow a procedure definition to include custom labels
This commit is contained in:
parent
c5a1bd804b
commit
0a17a03637
@ -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
|
||||
}
|
||||
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user