harness-drone/drone/sign.go

51 lines
777 B
Go
Raw Normal View History

2016-04-23 11:27:28 +00:00
package main
import (
"io/ioutil"
2017-03-16 10:14:02 +00:00
"github.com/urfave/cli"
2016-04-23 11:27:28 +00:00
)
var signCmd = cli.Command{
2017-03-16 10:14:02 +00:00
Name: "sign",
Usage: "creates a secure yaml file",
Action: sign,
2016-04-23 11:27:28 +00:00
Flags: []cli.Flag{
cli.StringFlag{
Name: "in",
Usage: "input file",
Value: ".drone.yml",
},
cli.StringFlag{
Name: "out",
Usage: "output file signature",
Value: ".drone.yml.sig",
},
},
}
func sign(c *cli.Context) error {
repo := c.Args().First()
owner, name, err := parseRepo(repo)
if err != nil {
return err
}
in, err := readInput(c.String("in"))
if err != nil {
return err
}
client, err := newClient(c)
if err != nil {
return err
}
sig, err := client.Sign(owner, name, in)
if err != nil {
return err
}
return ioutil.WriteFile(c.String("out"), sig, 0664)
}