Optimize cmd pkg (#384)

Signed-off-by: yxxhero <aiopsclub@163.com>

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero 2022-10-05 10:02:24 +08:00 committed by GitHub
parent 3165551f9a
commit 5f699656df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 14 additions and 14 deletions

View File

@ -10,12 +10,12 @@ import (
// NewBuildCmd returns build subcmd // NewBuildCmd returns build subcmd
func NewBuildCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewBuildCmd(globalCfg *config.GlobalImpl) *cobra.Command {
buildOptions := config.NewBuildOptions() buildOptions := config.NewBuildOptions()
buildImpl := config.NewBuildImpl(globalCfg, buildOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "build", Use: "build",
Short: "Build all resources from state file", Short: "Build all resources from state file",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
buildImpl := config.NewBuildImpl(globalCfg, buildOptions)
err := config.NewCLIConfigImpl(buildImpl.GlobalImpl) err := config.NewCLIConfigImpl(buildImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewChartsCmd returns charts subcmd // NewChartsCmd returns charts subcmd
func NewChartsCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewChartsCmd(globalCfg *config.GlobalImpl) *cobra.Command {
chartsOptions := config.NewChartsOptions() chartsOptions := config.NewChartsOptions()
chartsImpl := config.NewChartsImpl(globalCfg, chartsOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "charts", Use: "charts",
Short: "DEPRECATED: sync releases from state file (helm upgrade --install)", Short: "DEPRECATED: sync releases from state file (helm upgrade --install)",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
chartsImpl := config.NewChartsImpl(globalCfg, chartsOptions)
err := config.NewCLIConfigImpl(chartsImpl.GlobalImpl) err := config.NewCLIConfigImpl(chartsImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewDeleteCmd returns delete subcmd // NewDeleteCmd returns delete subcmd
func NewDeleteCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewDeleteCmd(globalCfg *config.GlobalImpl) *cobra.Command {
deleteOptions := config.NewDeleteOptions() deleteOptions := config.NewDeleteOptions()
deleteImpl := config.NewDeleteImpl(globalCfg, deleteOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "delete", Use: "delete",
Short: "DEPRECATED: delete releases from state file (helm delete)", Short: "DEPRECATED: delete releases from state file (helm delete)",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
deleteImpl := config.NewDeleteImpl(globalCfg, deleteOptions)
err := config.NewCLIConfigImpl(deleteImpl.GlobalImpl) err := config.NewCLIConfigImpl(deleteImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewDepsCmd returns deps subcmd // NewDepsCmd returns deps subcmd
func NewDepsCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewDepsCmd(globalCfg *config.GlobalImpl) *cobra.Command {
depsOptions := config.NewDepsOptions() depsOptions := config.NewDepsOptions()
depsImpl := config.NewDepsImpl(globalCfg, depsOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "deps", Use: "deps",
Short: "Update charts based on their requirements", Short: "Update charts based on their requirements",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
depsImpl := config.NewDepsImpl(globalCfg, depsOptions)
err := config.NewCLIConfigImpl(depsImpl.GlobalImpl) err := config.NewCLIConfigImpl(depsImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewDestroyCmd returns destroy subcmd // NewDestroyCmd returns destroy subcmd
func NewDestroyCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewDestroyCmd(globalCfg *config.GlobalImpl) *cobra.Command {
destroyOptions := config.NewDestroyOptions() destroyOptions := config.NewDestroyOptions()
destroyImpl := config.NewDestroyImpl(globalCfg, destroyOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "destroy", Use: "destroy",
Short: "Destroys and then purges releases", Short: "Destroys and then purges releases",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
destroyImpl := config.NewDestroyImpl(globalCfg, destroyOptions)
err := config.NewCLIConfigImpl(destroyImpl.GlobalImpl) err := config.NewCLIConfigImpl(destroyImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewDiffCmd returns diff subcmd // NewDiffCmd returns diff subcmd
func NewDiffCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewDiffCmd(globalCfg *config.GlobalImpl) *cobra.Command {
diffOptions := config.NewDiffOptions() diffOptions := config.NewDiffOptions()
diffImpl := config.NewDiffImpl(globalCfg, diffOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "diff", Use: "diff",
Short: "Diff releases defined in state file", Short: "Diff releases defined in state file",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
diffImpl := config.NewDiffImpl(globalCfg, diffOptions)
err := config.NewCLIConfigImpl(diffImpl.GlobalImpl) err := config.NewCLIConfigImpl(diffImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewFetchCmd returns diff subcmd // NewFetchCmd returns diff subcmd
func NewFetchCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewFetchCmd(globalCfg *config.GlobalImpl) *cobra.Command {
fetchOptions := config.NewFetchOptions() fetchOptions := config.NewFetchOptions()
fetchImpl := config.NewFetchImpl(globalCfg, fetchOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "fetch", Use: "fetch",
Short: "Fetch charts from state file", Short: "Fetch charts from state file",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
fetchImpl := config.NewFetchImpl(globalCfg, fetchOptions)
err := config.NewCLIConfigImpl(fetchImpl.GlobalImpl) err := config.NewCLIConfigImpl(fetchImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewLintCmd returns lint subcmd // NewLintCmd returns lint subcmd
func NewLintCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewLintCmd(globalCfg *config.GlobalImpl) *cobra.Command {
lintOptions := config.NewLintOptions() lintOptions := config.NewLintOptions()
lintImpl := config.NewLintImpl(globalCfg, lintOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "lint", Use: "lint",
Short: "Lint charts from state file (helm lint)", Short: "Lint charts from state file (helm lint)",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
lintImpl := config.NewLintImpl(globalCfg, lintOptions)
err := config.NewCLIConfigImpl(lintImpl.GlobalImpl) err := config.NewCLIConfigImpl(lintImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewListCmd returns list subcmd // NewListCmd returns list subcmd
func NewListCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewListCmd(globalCfg *config.GlobalImpl) *cobra.Command {
listOptions := config.NewListOptions() listOptions := config.NewListOptions()
listImpl := config.NewListImpl(globalCfg, listOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "list", Use: "list",
Short: "List releases defined in state file", Short: "List releases defined in state file",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
listImpl := config.NewListImpl(globalCfg, listOptions)
err := config.NewCLIConfigImpl(listImpl.GlobalImpl) err := config.NewCLIConfigImpl(listImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewReposCmd returns repos subcmd // NewReposCmd returns repos subcmd
func NewReposCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewReposCmd(globalCfg *config.GlobalImpl) *cobra.Command {
reposOptions := config.NewReposOptions() reposOptions := config.NewReposOptions()
reposImpl := config.NewReposImpl(globalCfg, reposOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "repos", Use: "repos",
Short: "Repos releases defined in state file", Short: "Repos releases defined in state file",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
reposImpl := config.NewReposImpl(globalCfg, reposOptions)
err := config.NewCLIConfigImpl(reposImpl.GlobalImpl) err := config.NewCLIConfigImpl(reposImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewStatusCmd returns status subcmd // NewStatusCmd returns status subcmd
func NewStatusCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewStatusCmd(globalCfg *config.GlobalImpl) *cobra.Command {
statusOptions := config.NewStatusOptions() statusOptions := config.NewStatusOptions()
statusImpl := config.NewStatusImpl(globalCfg, statusOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "status", Use: "status",
Short: "Retrieve status of releases in state file", Short: "Retrieve status of releases in state file",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
statusImpl := config.NewStatusImpl(globalCfg, statusOptions)
err := config.NewCLIConfigImpl(statusImpl.GlobalImpl) err := config.NewCLIConfigImpl(statusImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewSyncCmd returns sync subcmd // NewSyncCmd returns sync subcmd
func NewSyncCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewSyncCmd(globalCfg *config.GlobalImpl) *cobra.Command {
syncOptions := config.NewSyncOptions() syncOptions := config.NewSyncOptions()
syncImpl := config.NewSyncImpl(globalCfg, syncOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "sync", Use: "sync",
Short: "Sync releases defined in state file", Short: "Sync releases defined in state file",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
syncImpl := config.NewSyncImpl(globalCfg, syncOptions)
err := config.NewCLIConfigImpl(syncImpl.GlobalImpl) err := config.NewCLIConfigImpl(syncImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewTemplateCmd returm template subcmd // NewTemplateCmd returm template subcmd
func NewTemplateCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewTemplateCmd(globalCfg *config.GlobalImpl) *cobra.Command {
templateOptions := config.NewTemplateOptions() templateOptions := config.NewTemplateOptions()
templateImpl := config.NewTemplateImpl(globalCfg, templateOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "template", Use: "template",
Short: "Template releases defined in state file", Short: "Template releases defined in state file",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
templateImpl := config.NewTemplateImpl(globalCfg, templateOptions)
err := config.NewCLIConfigImpl(templateImpl.GlobalImpl) err := config.NewCLIConfigImpl(templateImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err

View File

@ -10,12 +10,12 @@ import (
// NewWriteValuesCmd returns write subcmd // NewWriteValuesCmd returns write subcmd
func NewWriteValuesCmd(globalCfg *config.GlobalImpl) *cobra.Command { func NewWriteValuesCmd(globalCfg *config.GlobalImpl) *cobra.Command {
writeValuesOptions := config.NewWriteValuesOptions() writeValuesOptions := config.NewWriteValuesOptions()
writeValuesImpl := config.NewWriteValuesImpl(globalCfg, writeValuesOptions)
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "write-values", Use: "write-values",
Short: "Write values files for releases. Similar to `helmfile template`, write values files instead of manifests.", Short: "Write values files for releases. Similar to `helmfile template`, write values files instead of manifests.",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
writeValuesImpl := config.NewWriteValuesImpl(globalCfg, writeValuesOptions)
err := config.NewCLIConfigImpl(writeValuesImpl.GlobalImpl) err := config.NewCLIConfigImpl(writeValuesImpl.GlobalImpl)
if err != nil { if err != nil {
return err return err