/
deploy.list.go
53 lines (49 loc) · 1.55 KB
/
deploy.list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package cmd
import (
"github.com/5sigma/conduit/log"
"github.com/spf13/cobra"
"strconv"
)
// listCmd represents the list command
var listCmd = &cobra.Command{
Use: "list",
Short: "List past deployments",
Long: `Lists past deployments, by default it will list the last 10 deployments
made by your access key.`,
Run: func(cmd *cobra.Command, args []string) {
client, err := AdminClientFromConfig()
if err != nil {
log.Debug(err.Error())
log.Fatal("Could not configure client")
}
limitToken := (cmd.Flag("all").Value.String() == "false")
count, _ := strconv.ParseInt(cmd.Flag("count").Value.String(), 10, 64)
resp, err := client.ListDeploys(cmd.Flag("name").Value.String(),
limitToken, int(count))
if err != nil {
log.Debug(err.Error())
log.Error("Could not list deploys")
return
}
if len(resp.Deployments) == 0 {
log.Warn("There are no open deployments")
}
for _, dep := range resp.Deployments {
log.Alertf("%s:", dep.Name)
log.Infof(" Deployed at: %s",
dep.CreatedAt.Format("01/02 03:04 PM"))
log.Infof(" Deployed by: %s", dep.DeployedBy)
log.Infof(" Executions: %d/%d",
dep.MessageCount-dep.PendingCount, dep.MessageCount)
log.Infof(" Repsonses: %d/%d", dep.ResponseCount, dep.MessageCount)
}
},
}
func init() {
deployCmd.AddCommand(listCmd)
listCmd.Flags().IntP("count", "c", 10,
"The maximum number of deployments to return")
listCmd.Flags().BoolP("all", "a", false, "Return all deployments")
listCmd.Flags().StringP("name", "n", ".*",
"A search pattern to limit deployment names")
}