mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-18 03:08:18 +02:00
Use cobra (#234)
switch to cobra Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
+33
-37
@@ -3,44 +3,40 @@ package cmd
|
||||
import (
|
||||
"github.com/helmfile/helmfile/pkg/app"
|
||||
"github.com/helmfile/helmfile/pkg/config"
|
||||
"github.com/urfave/cli"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func addTestSubcommand(cliApp *cli.App) {
|
||||
cliApp.Commands = append(cliApp.Commands, cli.Command{
|
||||
Name: "test",
|
||||
Usage: "test releases from state file (helm test)",
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "cleanup",
|
||||
Usage: "delete test pods upon completion",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "logs",
|
||||
Usage: "Dump the logs from test pods (this runs after all tests are complete, but before any cleanup)",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "args",
|
||||
Value: "",
|
||||
Usage: "pass additional args to helm exec",
|
||||
},
|
||||
cli.IntFlag{
|
||||
Name: "timeout",
|
||||
Value: 300,
|
||||
Usage: "maximum time for tests to run before being considered failed",
|
||||
},
|
||||
cli.IntFlag{
|
||||
Name: "concurrency",
|
||||
Value: 0,
|
||||
Usage: "maximum number of concurrent helm processes to run, 0 is unlimited",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "skip-deps",
|
||||
Usage: `skip running "helm repo update" and "helm dependency build"`,
|
||||
},
|
||||
// NewTestCmd returm build subcmd
|
||||
func NewTestCmd(globalCfg *config.GlobalImpl) *cobra.Command {
|
||||
testOptions := config.NewTestOptions()
|
||||
testImpl := config.NewTestImpl(globalCfg, testOptions)
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "test",
|
||||
Short: "Test charts from state file (helm test)",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
err := config.NewUrfaveCliConfigImplIns(testImpl.GlobalImpl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := testImpl.ValidateConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a := app.New(testImpl)
|
||||
return toCLIError(testImpl.GlobalImpl, a.Test(testImpl))
|
||||
},
|
||||
Action: Action(func(a *app.App, c config.ConfigImpl) error {
|
||||
return a.Test(c)
|
||||
}),
|
||||
})
|
||||
}
|
||||
testImpl.Cmd = cmd
|
||||
|
||||
f := cmd.Flags()
|
||||
f.IntVar(&testOptions.Concurrency, "concurrency", 0, "maximum number of concurrent downloads of release charts")
|
||||
f.BoolVar(&testOptions.SkipDeps, "skip-deps", testOptions.SkipDeps, `skip running "helm repo update" and "helm dependency build"`)
|
||||
f.BoolVar(&testOptions.Cleanup, "cleanup", testOptions.Cleanup, "delete test pods upon completion")
|
||||
f.BoolVar(&testOptions.Logs, "logs", testOptions.Logs, "Dump the logs from test pods (this runs after all tests are complete, but before any cleanup)")
|
||||
f.StringVar(&testOptions.Args, "args", testOptions.Args, "pass args to helm exec")
|
||||
f.IntVar(&testOptions.Timeout, "timeout", 300, "maximum time for tests to run before being considered failed")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user