From 871f2a9ed3163f8aabc43a8e6a9ad380c16da287 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Tue, 17 May 2022 16:31:59 +0800 Subject: [PATCH] refactor cmd dir Signed-off-by: yxxhero --- cmd/{helmfile => }/deps.go | 2 +- cmd/{helmfile => }/root.go | 2 +- main.go | 42 +++++++++++++++++++------------------- 3 files changed, 23 insertions(+), 23 deletions(-) rename cmd/{helmfile => }/deps.go (97%) rename cmd/{helmfile => }/root.go (99%) diff --git a/cmd/helmfile/deps.go b/cmd/deps.go similarity index 97% rename from cmd/helmfile/deps.go rename to cmd/deps.go index 1f3a564f..a6179cc0 100644 --- a/cmd/helmfile/deps.go +++ b/cmd/deps.go @@ -1,4 +1,4 @@ -package helmfile +package cmd import ( "github.com/helmfile/helmfile/pkg/app" diff --git a/cmd/helmfile/root.go b/cmd/root.go similarity index 99% rename from cmd/helmfile/root.go rename to cmd/root.go index 2dfb0b64..f9bb0f3d 100644 --- a/cmd/helmfile/root.go +++ b/cmd/root.go @@ -1,4 +1,4 @@ -package helmfile +package cmd import ( "fmt" diff --git a/main.go b/main.go index f417b242..7d099bca 100644 --- a/main.go +++ b/main.go @@ -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)