forked from brigadecore/brigade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_list.go
50 lines (40 loc) · 932 Bytes
/
build_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
package commands
import (
"fmt"
"io"
"github.com/deis/brigade/pkg/storage/kube"
"github.com/gosuri/uitable"
"github.com/spf13/cobra"
)
const buildListUsage = `List all installed builds.
Print a list of all of the current builds.
`
func init() {
build.AddCommand(buildList)
}
var buildList = &cobra.Command{
Use: "list",
Short: "list builds",
Long: buildListUsage,
RunE: func(cmd *cobra.Command, args []string) error {
return listBuilds(cmd.OutOrStdout(), globalNamespace)
},
}
func listBuilds(out io.Writer, ns string) error {
c, err := kube.GetClient("", kubeConfigPath())
if err != nil {
return err
}
store := kube.New(c, globalNamespace)
bs, err := store.GetBuilds()
if err != nil {
return err
}
table := uitable.New()
table.AddRow("ID", "TYPE", "PROVIDER", "PROJECT")
for _, b := range bs {
table.AddRow(b.ID, b.Type, b.Provider, b.ProjectID)
}
fmt.Fprintln(out, table)
return nil
}