This repository has been archived by the owner on Mar 16, 2024. It is now read-only.
/
all.go
93 lines (82 loc) · 1.71 KB
/
all.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package cli
import (
"fmt"
"github.com/acorn-io/baaah/pkg/merr"
cli "github.com/acorn-io/runtime/pkg/cli/builder"
"github.com/spf13/cobra"
)
func NewAll(c CommandContext) *cobra.Command {
return cli.Command(&All{client: c.ClientFactory}, cobra.Command{
Use: "all",
Example: `
acorn all`,
SilenceUsage: true,
Short: "List (almost) all objects",
})
}
type All struct {
Quiet bool `usage:"Output only names" short:"q"`
Output string `usage:"Output format (json, yaml, {{gotemplate}})" short:"o"`
Images bool `usage:"Include images in output" short:"i"`
All bool `usage:"Include stopped apps/containers" short:"a"`
client ClientFactory
}
func (a *All) Run(cmd *cobra.Command, args []string) error {
if !a.Quiet {
fmt.Println("")
fmt.Println("ACORNS:")
}
ps := &Ps{
Quiet: a.Quiet,
Output: a.Output,
All: a.All,
client: a.client,
}
psErr := ps.Run(cmd, nil)
con := &Container{
Quiet: a.Quiet,
Output: a.Output,
All: a.All,
client: a.client,
}
if !a.Quiet {
fmt.Println("")
fmt.Println("CONTAINERS:")
}
conErr := con.Run(cmd, nil)
vol := &Volume{
Quiet: a.Quiet,
Output: a.Output,
client: a.client,
}
if !a.Quiet {
fmt.Println("")
fmt.Println("VOLUMES:")
}
volErr := vol.Run(cmd, nil)
sec := &Secret{
Quiet: a.Quiet,
Output: a.Output,
client: a.client,
}
if !a.Quiet {
fmt.Println("")
fmt.Println("SECRETS:")
}
secErr := sec.Run(cmd, nil)
var imgErr error
if a.Images {
img := &Image{
Quiet: a.Quiet,
Output: a.Output,
All: a.All,
client: a.client,
}
if !a.Quiet {
fmt.Println("")
fmt.Println("IMAGES:")
}
imgErr = img.Run(cmd, nil)
}
return merr.NewErrors(psErr, conErr, volErr, secErr, imgErr)
}