refactor cmd dir

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero 2022-05-17 16:31:59 +08:00 committed by yxxhero
parent 8024949d48
commit 871f2a9ed3
3 changed files with 23 additions and 23 deletions

View File

@ -1,4 +1,4 @@
package helmfile
package cmd
import (
"github.com/helmfile/helmfile/pkg/app"

View File

@ -1,4 +1,4 @@
package helmfile
package cmd
import (
"fmt"

42
main.go
View File

@ -4,7 +4,7 @@ import (
"fmt"
"os"
"github.com/helmfile/helmfile/cmd/helmfile"
"github.com/helmfile/helmfile/cmd"
"github.com/helmfile/helmfile/pkg/app"
"github.com/helmfile/helmfile/pkg/config"
"github.com/urfave/cli"
@ -12,7 +12,7 @@ import (
func main() {
cmd := helmfile.RootCommand()
rootCmd := cmd.RootCommand()
subCommands := []cli.Command{
{
Name: "repos",
@ -24,7 +24,7 @@ func main() {
Usage: "pass args to helm exec",
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.Repos(c)
}),
},
@ -51,7 +51,7 @@ func main() {
Usage: "maximum number of concurrent helm processes to run, 0 is unlimited",
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.DeprecatedSyncCharts(c)
}),
},
@ -129,7 +129,7 @@ func main() {
Usage: "output format for diff plugin",
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.Diff(c)
}),
},
@ -192,7 +192,7 @@ func main() {
Usage: "Stop cleaning up temporary values generated by helmfile and helm-secrets. Useful for debugging. Don't use in production for security",
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.Template(c)
}),
},
@ -222,7 +222,7 @@ func main() {
Usage: `skip running "helm repo update" and "helm dependency build"`,
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.WriteValues(c)
}),
},
@ -253,7 +253,7 @@ func main() {
Usage: `skip running "helm repo update" and "helm dependency build"`,
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.Lint(c)
}),
},
@ -275,7 +275,7 @@ func main() {
Usage: "directory to store charts (default: temporary directory which is deleted when the command terminates)",
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.Fetch(c)
}),
},
@ -334,7 +334,7 @@ func main() {
Usage: `Override helmDefaults.waitForJobs setting "helm upgrade --install --wait-for-jobs"`,
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.Sync(c)
}),
},
@ -439,7 +439,7 @@ func main() {
Usage: `Override helmDefaults.waitForJobs setting "helm upgrade --install --wait-for-jobs"`,
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.Apply(c)
}),
},
@ -458,7 +458,7 @@ func main() {
Usage: "pass args to helm exec",
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.Status(c)
}),
},
@ -485,7 +485,7 @@ func main() {
Usage: `skip running "helm repo update" and "helm dependency build"`,
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.Delete(c)
}),
},
@ -508,7 +508,7 @@ func main() {
Usage: `skip running "helm repo update" and "helm dependency build"`,
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.Destroy(c)
}),
},
@ -544,7 +544,7 @@ func main() {
Usage: `skip running "helm repo update" and "helm dependency build"`,
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.Test(c)
}),
},
@ -557,7 +557,7 @@ func main() {
Usage: "Read all the values files for every release and embed into the output helmfile.yaml",
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.PrintState(c)
}),
},
@ -575,7 +575,7 @@ func main() {
Usage: "Keep temporary directory",
},
},
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.ListReleases(c)
}),
},
@ -587,14 +587,14 @@ func main() {
{
Name: "info",
Usage: "cache info",
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.ShowCacheDir(c)
}),
},
{
Name: "cleanup",
Usage: "clean up cache directory",
Action: helmfile.Action(func(a *app.App, c config.ConfigImpl) error {
Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error {
return a.CleanCacheDir(c)
}),
},
@ -610,9 +610,9 @@ func main() {
},
},
}
cmd.Commands = append(cmd.Commands, subCommands...)
rootCmd.Commands = append(rootCmd.Commands, subCommands...)
err := cmd.Run(os.Args)
err := rootCmd.Run(os.Args)
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(3)