/
outputs.go
77 lines (65 loc) · 2.34 KB
/
outputs.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"get.porter.sh/porter/pkg/porter"
"github.com/spf13/cobra"
)
func buildInstallationOutputsCommands(p *porter.Porter) *cobra.Command {
cmd := &cobra.Command{
Use: "output",
Aliases: []string{"outputs"},
Short: "Output commands",
Annotations: map[string]string{
"group": "resource",
},
}
cmd.AddCommand(buildBundleOutputShowCommand(p))
cmd.AddCommand(buildBundleOutputListCommand(p))
return cmd
}
func buildBundleOutputListCommand(p *porter.Porter) *cobra.Command {
opts := porter.OutputListOptions{}
cmd := cobra.Command{
Use: "list [--installation|i INSTALLATION]",
Short: "List installation outputs",
Long: "Displays a listing of installation outputs.",
Example: ` porter installation outputs list
porter installation outputs list --installation another-bundle
`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return opts.Validate(args, p.Context)
},
RunE: func(cmd *cobra.Command, args []string) error {
return p.PrintBundleOutputs(cmd.Context(), opts)
},
}
f := cmd.Flags()
f.StringVarP(&opts.RawFormat, "output", "o", "plaintext",
"Specify an output format. Allowed values: plaintext, json, yaml")
f.StringVarP(&opts.Namespace, "namespace", "n", "",
"Namespace in which the installation is defined. Defaults to the global namespace.")
f.StringVarP(&opts.Name, "installation", "i", "",
"Specify the installation to which the output belongs.")
return &cmd
}
func buildBundleOutputShowCommand(p *porter.Porter) *cobra.Command {
opts := porter.OutputShowOptions{}
cmd := cobra.Command{
Use: "show NAME [--installation|-i INSTALLATION]",
Short: "Show the output of an installation",
Long: "Show the output of an installation",
Example: ` porter installation output show kubeconfig
porter installation output show subscription-id --installation azure-mysql`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return opts.Validate(args, p.Context)
},
RunE: func(cmd *cobra.Command, args []string) error {
return p.ShowBundleOutput(cmd.Context(), &opts)
},
}
f := cmd.Flags()
f.StringVarP(&opts.Namespace, "namespace", "n", "",
"Namespace in which the installation is defined. Defaults to the global namespace.")
f.StringVarP(&opts.Name, "installation", "i", "",
"Specify the installation to which the output belongs.")
return &cmd
}