/
get.go
53 lines (40 loc) · 1.22 KB
/
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
package cmd
import (
"io"
"github.com/spf13/cobra"
"github.com/kudobuilder/kudo/pkg/kudoctl/cmd/get"
"github.com/kudobuilder/kudo/pkg/kudoctl/env"
)
const getExample = ` # Get all available instances
kubectl kudo get instances
# Get all available operators
kubectl kudo get operators
# Get all available operatorversions
kubectl kudo get operatorversions
# Get all installed components
kubectl kudo get all
# Get all installed components as yaml
kubectl kudo get all -o yaml
`
// newGetCmd creates a command that lists the instances in the cluster
func newGetCmd(out io.Writer) *cobra.Command {
opts := get.CmdOpts{
Out: out,
}
getCmd := &cobra.Command{
Use: "get <instances|operators|operatorversions|all> [flags]",
Short: "Gets list of installed components (instances, operators, operatorversions or all).",
Example: getExample,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := env.GetClient(&Settings)
if err != nil {
return err
}
opts.Client = client
opts.Namespace = Settings.Namespace
return get.Run(args, opts)
},
}
getCmd.Flags().StringVarP(opts.Output.AsStringPtr(), "output", "o", "", "Output format. One of: json|yaml")
return getCmd
}