mirror of
https://github.com/strongdm/comply
synced 2024-12-24 14:31:36 +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 {
|
for _, procedure := range procedures {
|
||||||
if procedure.ID == procedureID {
|
if procedure.ID == procedureID {
|
||||||
err = tp.Create(&model.Ticket{
|
err = tp.Create(procedure.NewTicket(), procedure.Labels())
|
||||||
Name: procedure.Name,
|
|
||||||
Body: fmt.Sprintf("%s\n\n\n---\nProcedure-ID: %s", procedure.Body, procedure.ID),
|
|
||||||
}, []string{"comply", "comply-procedure"})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var defaultLabels = []string{"comply", "comply-procedure"}
|
||||||
|
|
||||||
type Procedure struct {
|
type Procedure struct {
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
ID string `yaml:"id"`
|
ID string `yaml:"id"`
|
||||||
Cron string `yaml:"cron"`
|
Cron string `yaml:"cron"`
|
||||||
|
CustomLabels []string `yaml:"labels"`
|
||||||
|
|
||||||
Revisions []Revision `yaml:"majorRevisions"`
|
Revisions []Revision `yaml:"majorRevisions"`
|
||||||
Satisfies Satisfaction `yaml:"satisfies"`
|
Satisfies Satisfaction `yaml:"satisfies"`
|
||||||
@ -14,3 +20,14 @@ type Procedure struct {
|
|||||||
ModifiedAt time.Time
|
ModifiedAt time.Time
|
||||||
Body string
|
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))
|
tp := model.GetPlugin(model.TicketSystem(ts))
|
||||||
err = tp.Create(&model.Ticket{
|
err = tp.Create(procedure.NewTicket(), procedure.Labels())
|
||||||
Name: procedure.Name,
|
|
||||||
Body: fmt.Sprintf("%s\n\n\n---\nProcedure-ID: %s", procedure.Body, procedure.ID),
|
|
||||||
}, []string{"comply", "comply-procedure"})
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user