github.com/helmwave/helmwave@v0.36.4-0.20240509190856-b35563eba4c6/pkg/action/list.go (about) 1 package action 2 3 import ( 4 "context" 5 6 "github.com/helmwave/helmwave/pkg/plan" 7 "github.com/urfave/cli/v2" 8 ) 9 10 var _ Action = (*List)(nil) 11 12 // List is a struct for running 'list' command. 13 type List struct { 14 build *Build 15 autoBuild bool 16 } 17 18 // Run is the main function for 'list' command. 19 func (l *List) Run(ctx context.Context) error { 20 if l.autoBuild { 21 if err := l.build.Run(ctx); err != nil { 22 return err 23 } 24 } 25 p, err := plan.NewAndImport(ctx, l.build.plandir) 26 if err != nil { 27 return err 28 } 29 30 return p.List() 31 } 32 33 // Cmd returns 'list' *cli.Command. 34 func (l *List) Cmd() *cli.Command { 35 return &cli.Command{ 36 Name: "list", 37 Category: Step2, 38 Aliases: []string{"ls"}, 39 Usage: "👀 list of deployed releases", 40 Flags: l.flags(), 41 Action: toCtx(l.Run), 42 } 43 } 44 45 // flags return flag set of CLI urfave. 46 func (l *List) flags() []cli.Flag { 47 // Init sub-structures 48 l.build = &Build{} 49 50 self := []cli.Flag{ 51 flagAutoBuild(&l.autoBuild), 52 } 53 54 return append(self, l.build.flags()...) 55 }