diff --git a/completers/helm_completer/cmd/install.go b/completers/helm_completer/cmd/install.go index 634108220f..428e2a7876 100644 --- a/completers/helm_completer/cmd/install.go +++ b/completers/helm_completer/cmd/install.go @@ -76,7 +76,7 @@ func init() { "version": carapace.ActionCallback(func(c carapace.Context) carapace.Action { if len(c.Args) > 1 { if splitted := strings.Split(c.Args[1], "/"); len(splitted) == 2 { - return helm.ActionChartVersions(splitted[0], splitted[1]) + return helm.ActionChartVersions(helm.ChartVersionOpts{Repo: splitted[0], Chart: splitted[1]}) } } return carapace.ActionValues() diff --git a/completers/helm_completer/cmd/pull.go b/completers/helm_completer/cmd/pull.go index eb542f3edd..eb9ca6da00 100644 --- a/completers/helm_completer/cmd/pull.go +++ b/completers/helm_completer/cmd/pull.go @@ -45,7 +45,7 @@ func init() { "version": carapace.ActionCallback(func(c carapace.Context) carapace.Action { if len(c.Args) > 0 { if splitted := strings.Split(c.Args[0], "/"); len(splitted) == 2 { - return helm.ActionChartVersions(splitted[0], splitted[1]) + return helm.ActionChartVersions(helm.ChartVersionOpts{Repo: splitted[0], Chart: splitted[1]}) } } return carapace.ActionValues() diff --git a/completers/helm_completer/cmd/show_all.go b/completers/helm_completer/cmd/show_all.go index c2bf2b4d15..f258b004db 100644 --- a/completers/helm_completer/cmd/show_all.go +++ b/completers/helm_completer/cmd/show_all.go @@ -39,7 +39,7 @@ func init() { "version": carapace.ActionCallback(func(c carapace.Context) carapace.Action { if len(c.Args) > 0 { if splitted := strings.Split(c.Args[0], "/"); len(splitted) == 2 { - return helm.ActionChartVersions(splitted[0], splitted[1]) + return helm.ActionChartVersions(helm.ChartVersionOpts{Repo: splitted[0], Chart: splitted[1]}) } } return carapace.ActionValues() diff --git a/completers/helm_completer/cmd/show_chart.go b/completers/helm_completer/cmd/show_chart.go index 38138d3588..8b29633b72 100644 --- a/completers/helm_completer/cmd/show_chart.go +++ b/completers/helm_completer/cmd/show_chart.go @@ -39,7 +39,7 @@ func init() { "version": carapace.ActionCallback(func(c carapace.Context) carapace.Action { if len(c.Args) > 0 { if splitted := strings.Split(c.Args[0], "/"); len(splitted) == 2 { - return helm.ActionChartVersions(splitted[0], splitted[1]) + return helm.ActionChartVersions(helm.ChartVersionOpts{Repo: splitted[0], Chart: splitted[1]}) } } return carapace.ActionValues() diff --git a/completers/helm_completer/cmd/show_readme.go b/completers/helm_completer/cmd/show_readme.go index a0a180689b..18e8938c06 100644 --- a/completers/helm_completer/cmd/show_readme.go +++ b/completers/helm_completer/cmd/show_readme.go @@ -39,7 +39,7 @@ func init() { "version": carapace.ActionCallback(func(c carapace.Context) carapace.Action { if len(c.Args) > 0 { if splitted := strings.Split(c.Args[0], "/"); len(splitted) == 2 { - return helm.ActionChartVersions(splitted[0], splitted[1]) + return helm.ActionChartVersions(helm.ChartVersionOpts{Repo: splitted[0], Chart: splitted[1]}) } } return carapace.ActionValues() diff --git a/completers/helm_completer/cmd/show_values.go b/completers/helm_completer/cmd/show_values.go index 931ccb5b78..055a53c0a7 100644 --- a/completers/helm_completer/cmd/show_values.go +++ b/completers/helm_completer/cmd/show_values.go @@ -40,7 +40,7 @@ func init() { "version": carapace.ActionCallback(func(c carapace.Context) carapace.Action { if len(c.Args) > 0 { if splitted := strings.Split(c.Args[0], "/"); len(splitted) == 2 { - return helm.ActionChartVersions(splitted[0], splitted[1]) + return helm.ActionChartVersions(helm.ChartVersionOpts{Repo: splitted[0], Chart: splitted[1]}) } } return carapace.ActionValues() diff --git a/completers/helm_completer/cmd/upgrade.go b/completers/helm_completer/cmd/upgrade.go index 18b29c48bb..1df4ddccc8 100644 --- a/completers/helm_completer/cmd/upgrade.go +++ b/completers/helm_completer/cmd/upgrade.go @@ -80,7 +80,7 @@ func init() { "version": carapace.ActionCallback(func(c carapace.Context) carapace.Action { if len(c.Args) > 1 { if splitted := strings.Split(c.Args[1], "/"); len(splitted) == 2 { - return helm.ActionChartVersions(splitted[0], splitted[1]) + return helm.ActionChartVersions(helm.ChartVersionOpts{Repo: splitted[0], Chart: splitted[1]}) } } return carapace.ActionValues() diff --git a/pkg/actions/tools/helm/repo.go b/pkg/actions/tools/helm/repo.go index 3119a618f7..702a5cba54 100644 --- a/pkg/actions/tools/helm/repo.go +++ b/pkg/actions/tools/helm/repo.go @@ -88,10 +88,15 @@ func ActionCharts(repo string) carapace.Action { }) } +type ChartVersionOpts struct { + Repo string + Chart string +} + // ActionChartVersions completes chart versions -func ActionChartVersions(repo string, chart string) carapace.Action { +func ActionChartVersions(opts ChartVersionOpts) carapace.Action { return carapace.ActionCallback(func(c carapace.Context) carapace.Action { - index, err := loadIndex(repo) + index, err := loadIndex(opts.Repo) if err != nil { return carapace.ActionMessage(err.Error()) } @@ -99,7 +104,7 @@ func ActionChartVersions(repo string, chart string) carapace.Action { vals := make([]string, 0) for _, charts := range index.Entries { for _, c := range charts { - if c.Name == chart { + if c.Name == opts.Chart { vals = append(vals, c.Version) } }