forked from helmfile/helmfile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite-values.go
40 lines (32 loc) · 1.52 KB
/
write-values.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
package cmd
import (
"github.com/spf13/cobra"
"github.com/helmfile/helmfile/pkg/app"
"github.com/helmfile/helmfile/pkg/config"
)
// NewWriteValuesCmd returns write-values subcmd
func NewWriteValuesCmd(globalCfg *config.GlobalImpl) *cobra.Command {
writeValuesOptions := config.NewWriteValuesOptions()
cmd := &cobra.Command{
Use: "write-values",
Short: "Write values files for releases. Similar to `helmfile template`, write values files instead of manifests.",
RunE: func(cmd *cobra.Command, args []string) error {
writeValuesImpl := config.NewWriteValuesImpl(globalCfg, writeValuesOptions)
err := config.NewCLIConfigImpl(writeValuesImpl.GlobalImpl)
if err != nil {
return err
}
if err := writeValuesImpl.ValidateConfig(); err != nil {
return err
}
a := app.New(writeValuesImpl)
return toCLIError(writeValuesImpl.GlobalImpl, a.WriteValues(writeValuesImpl))
},
}
f := cmd.Flags()
f.IntVar(&writeValuesOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited")
f.StringArrayVar(&writeValuesOptions.Set, "set", nil, "additional values to be merged into the helm command --set flag")
f.StringArrayVar(&writeValuesOptions.Values, "values", nil, "additional value files to be merged into the helm command --values flag")
f.StringVar(&writeValuesOptions.OutputFileTemplate, "output-file-template", "", "go text template for generating the output file. Default: {{ .State.BaseName }}-{{ .State.AbsPathSHA1 }}/{{ .Release.Name}}.yaml")
return cmd
}