forked from brigadecore/brigade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_list.go
50 lines (40 loc) · 942 Bytes
/
project_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 projectListUsage = `List all installed projects.
Print a list of all of the projects in the given namespace.
`
func init() {
project.AddCommand(projectList)
}
var projectList = &cobra.Command{
Use: "list",
Short: "list projects",
Long: projectListUsage,
RunE: func(cmd *cobra.Command, args []string) error {
return listProjects(cmd.OutOrStdout(), globalNamespace)
},
}
func listProjects(out io.Writer, ns string) error {
c, err := kube.GetClient("", kubeConfigPath())
if err != nil {
return err
}
store := kube.New(c, globalNamespace)
ps, err := store.GetProjects()
if err != nil {
return err
}
table := uitable.New()
table.AddRow("NAME", "ID", "REPO")
for _, p := range ps {
table.AddRow(p.Name, p.ID, p.Repo.Name)
}
fmt.Fprintln(out, table)
return nil
}