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:
xiaomudk
2022-11-03 14:51:30 +08:00
committed by GitHub
parent 008e92de37
commit 6dcde20d7a
11 changed files with 501 additions and 5 deletions
+35
View File
@@ -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
}
+1
View File
@@ -81,6 +81,7 @@ func NewRootCmd(globalConfig *config.GlobalOptions) (*cobra.Command, error) {
}
cmd.AddCommand(
NewInitCmd(globalImpl),
NewApplyCmd(globalImpl),
NewBuildCmd(globalImpl),
NewCacheCmd(globalImpl),