forked from helmfile/helmfile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.go
42 lines (34 loc) · 1.31 KB
/
test.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
package cmd
import (
"github.com/spf13/cobra"
"github.com/helmfile/helmfile/pkg/app"
"github.com/helmfile/helmfile/pkg/config"
)
// NewTestCmd returns test 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.NewCLIConfigImpl(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))
},
}
testImpl.Cmd = cmd
f := cmd.Flags()
f.IntVar(&testOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited")
f.BoolVar(&testOptions.Cleanup, "cleanup", false, "delete test pods upon completion")
f.BoolVar(&testOptions.Logs, "logs", false, "Dump the logs from test pods (this runs after all tests are complete, but before any cleanup)")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
f.IntVar(&testOptions.Timeout, "timeout", 300, "maximum time for tests to run before being considered failed")
return cmd
}