mirror of
https://github.com/strongdm/comply
synced 2024-12-23 14:07:34 +00:00
trigger procedure by ID
This commit is contained in:
parent
8fbc7ab65a
commit
4c1b6fad7e
@ -44,6 +44,7 @@ func newApp() *cli.App {
|
||||
}
|
||||
|
||||
app.Commands = append(app.Commands, beforeCommand(buildCommand, projectMustExist))
|
||||
app.Commands = append(app.Commands, beforeCommand(procedureCommand, projectMustExist))
|
||||
app.Commands = append(app.Commands, beforeCommand(schedulerCommand, projectMustExist))
|
||||
app.Commands = append(app.Commands, beforeCommand(serveCommand, projectMustExist))
|
||||
app.Commands = append(app.Commands, beforeCommand(syncCommand, projectMustExist))
|
||||
|
44
internal/cli/procedure.go
Normal file
44
internal/cli/procedure.go
Normal file
@ -0,0 +1,44 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/strongdm/comply/internal/model"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var procedureCommand = cli.Command{
|
||||
Name: "procedure",
|
||||
ShortName: "proc",
|
||||
Usage: "create ticket by procedure ID",
|
||||
ArgsUsage: "procedureID",
|
||||
Action: procedureAction,
|
||||
Before: projectMustExist,
|
||||
}
|
||||
|
||||
func procedureAction(c *cli.Context) error {
|
||||
procedures, err := model.ReadProcedures()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if c.NArg() != 1 {
|
||||
return cli.NewExitError("provide a procedure ID", 1)
|
||||
}
|
||||
|
||||
procedureID := c.Args().First()
|
||||
|
||||
for _, procedure := range procedures {
|
||||
if procedure.ID == procedureID {
|
||||
// TODO: don't hardcode GH
|
||||
tp := model.GetPlugin(model.GitHub)
|
||||
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"})
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return cli.NewExitError(fmt.Sprintf("unknown procedure ID: %s", procedureID), 1)
|
||||
}
|
Loading…
Reference in New Issue
Block a user