forked from brigadecore/brigade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject_get.go
54 lines (44 loc) · 1020 Bytes
/
project_get.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
54
package commands
import (
"errors"
"fmt"
"io"
"github.com/deis/brigade/pkg/storage/kube"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)
const projectGetUsage = `Get details for a project.
Print the attributes of a project.
The PROJECT may either be the ID or the name of a project.
`
func init() {
project.AddCommand(projectGet)
}
var projectGet = &cobra.Command{
Use: "get PROJECT",
Short: "get a project",
Long: projectGetUsage,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("project name is a required argument")
}
return getProject(cmd.OutOrStdout(), globalNamespace, args[0])
},
}
func getProject(out io.Writer, ns, name string) error {
c, err := kube.GetClient("", kubeConfigPath())
if err != nil {
return err
}
store := kube.New(c, globalNamespace)
p, err := store.GetProject(name)
if err != nil {
return err
}
bytes, err := yaml.Marshal(p)
if err != nil {
return err
}
fmt.Fprintln(out, string(bytes))
return nil
}