forked from openshift/origin
/
status.go
59 lines (48 loc) · 1.49 KB
/
status.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
55
56
57
58
59
package cmd
import (
"fmt"
"io"
"github.com/spf13/cobra"
cmdutil "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
"github.com/openshift/origin/pkg/cmd/cli/describe"
"github.com/openshift/origin/pkg/cmd/util/clientcmd"
)
const (
status_long = `Show a high level overview of the current project. Links components by their relationships.
For more information about individual items, use the describe command (e.g. osc describe buildConfig,
osc describe deploymentConfig, osc describe service).`
status_example = ` // Show an overview of the current project
$ %[1]s status`
)
// NewCmdStatus implements the OpenShift cli status command
func NewCmdStatus(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Use: "status",
Short: "Show an overview of the current project",
Long: status_long,
Example: fmt.Sprintf(status_example, fullName),
Run: func(cmd *cobra.Command, args []string) {
err := RunStatus(f, out)
cmdutil.CheckErr(err)
},
}
return cmd
}
// RunStatus contains all the necessary functionality for the OpenShift cli status command
func RunStatus(f *clientcmd.Factory, out io.Writer) error {
client, kclient, err := f.Clients()
if err != nil {
return err
}
namespace, err := f.DefaultNamespace()
if err != nil {
return err
}
describer := &describe.ProjectStatusDescriber{kclient, client}
s, err := describer.Describe(namespace, "")
if err != nil {
return err
}
fmt.Fprintf(out, s)
return nil
}