mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-21 11:48:10 +02:00
Add subcommand init for checks and installs helmfile deps (#389)
* Add subcommand init for checks and installs helmfile deps Signed-off-by: xiaomudk <xiaomudk@gmail.com>
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/helmfile/helmfile/pkg/app"
|
||||
"github.com/helmfile/helmfile/pkg/config"
|
||||
)
|
||||
|
||||
// NewInitCmd helmfile checks and installs deps
|
||||
func NewInitCmd(globalCfg *config.GlobalImpl) *cobra.Command {
|
||||
options := config.NewInitOptions()
|
||||
cmd := &cobra.Command{
|
||||
Use: "init",
|
||||
Short: "Initialize the helmfile, includes version checking and installation of helm and plug-ins",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
initImpl := config.NewInitImpl(globalCfg, options)
|
||||
err := config.NewCLIConfigImpl(initImpl.GlobalImpl)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := initImpl.ValidateConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
a := app.New(initImpl)
|
||||
return toCLIError(initImpl.GlobalImpl, a.Init(initImpl))
|
||||
},
|
||||
}
|
||||
f := cmd.Flags()
|
||||
f.BoolVar(&options.Force, "force", false, "Do not prompt, install dependencies required by helmfile")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -81,6 +81,7 @@ func NewRootCmd(globalConfig *config.GlobalOptions) (*cobra.Command, error) {
|
||||
}
|
||||
|
||||
cmd.AddCommand(
|
||||
NewInitCmd(globalImpl),
|
||||
NewApplyCmd(globalImpl),
|
||||
NewBuildCmd(globalImpl),
|
||||
NewCacheCmd(globalImpl),
|
||||
|
||||
Reference in New Issue
Block a user