2016-05-06 17:59:36 +00:00
|
|
|
package main
|
2016-06-27 21:06:02 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/codegangsta/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var secretListCmd = cli.Command{
|
|
|
|
Name: "ls",
|
|
|
|
Usage: "list all secrets",
|
|
|
|
Action: func(c *cli.Context) {
|
|
|
|
if err := secretList(c); err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
},
|
2016-10-20 00:13:21 +00:00
|
|
|
Flags: secretListFlags(),
|
2016-06-27 21:06:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func secretList(c *cli.Context) error {
|
|
|
|
owner, name, err := parseRepo(c.Args().First())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
client, err := newClient(c)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
secrets, err := client.SecretList(owner, name)
|
|
|
|
|
|
|
|
if err != nil || len(secrets) == 0 {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-10-20 00:13:21 +00:00
|
|
|
return secretDisplayList(secrets, c)
|
2016-06-27 21:06:02 +00:00
|
|
|
}
|