mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-17 23:58:45 +02:00
Use cobra (#234)
switch to cobra Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
+30
-28
@@ -3,35 +3,37 @@ package cmd
|
||||
import (
|
||||
"github.com/helmfile/helmfile/pkg/app"
|
||||
"github.com/helmfile/helmfile/pkg/config"
|
||||
"github.com/urfave/cli"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func addDeleteSubcommand(cliApp *cli.App) {
|
||||
cliApp.Commands = append(cliApp.Commands, cli.Command{
|
||||
Name: "delete",
|
||||
Usage: "DEPRECATED: delete releases from state file (helm delete)",
|
||||
Flags: []cli.Flag{
|
||||
cli.IntFlag{
|
||||
Name: "concurrency",
|
||||
Value: 0,
|
||||
Usage: "maximum number of concurrent helm processes to run, 0 is unlimited",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "args",
|
||||
Value: "",
|
||||
Usage: "pass args to helm exec",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "purge",
|
||||
Usage: "purge releases i.e. free release names and histories",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "skip-deps",
|
||||
Usage: `skip running "helm repo update" and "helm dependency build"`,
|
||||
},
|
||||
// NewDeleteCmd returm build subcmd
|
||||
func NewDeleteCmd(globalCfg *config.GlobalImpl) *cobra.Command {
|
||||
deleteOptions := config.NewDeleteOptions()
|
||||
deleteImpl := config.NewDeleteImpl(globalCfg, deleteOptions)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "delete",
|
||||
Short: "DEPRECATED: delete releases from state file (helm delete)",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
err := config.NewUrfaveCliConfigImplIns(deleteImpl.GlobalImpl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := deleteImpl.ValidateConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a := app.New(deleteImpl)
|
||||
return toCLIError(deleteImpl.GlobalImpl, a.Delete(deleteImpl))
|
||||
},
|
||||
Action: Action(func(a *app.App, c config.ConfigImpl) error {
|
||||
return a.Delete(c)
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
f := cmd.Flags()
|
||||
f.StringVar(&deleteOptions.Args, "args", deleteOptions.Args, "pass args to helm exec")
|
||||
f.IntVar(&deleteOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited")
|
||||
f.BoolVar(&deleteOptions.Purge, "purge", deleteOptions.Purge, "purge releases i.e. free release names and histories")
|
||||
f.BoolVar(&deleteOptions.SkipDeps, "skip-deps", deleteOptions.SkipDeps, `skip running "helm repo update" and "helm dependency build"`)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user