Skip to content

Commit

Permalink
execute helm.ActionReleases during completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Trojan295 committed Feb 21, 2024
1 parent da5d30a commit 0c8b774
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pkg/actions/tools/helm/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ type ReleasesOpts struct {

// ActionReleases completes releases
func ActionReleases(opts ReleasesOpts) carapace.Action {
return carapace.ActionExecCommand("helm", "list", "--kube-context", opts.KubeContext, "--namespace", opts.Namespace, "--output", "json")(func(output []byte) carapace.Action {
var releases []release
if err := json.Unmarshal(output, &releases); err != nil {
return carapace.ActionMessage(err.Error())
}
return carapace.ActionCallback(func(_ carapace.Context) carapace.Action {
return carapace.ActionExecCommand("helm", "list", "--kube-context", opts.KubeContext, "--namespace", opts.Namespace, "--output", "json")(func(output []byte) carapace.Action {
var releases []release
if err := json.Unmarshal(output, &releases); err != nil {
return carapace.ActionMessage(err.Error())
}

vals := make([]string, 0, len(releases)*2)
for _, release := range releases {
vals = append(vals, release.Name, release.Chart)
}
return carapace.ActionValuesDescribed(vals...)
vals := make([]string, 0, len(releases)*2)
for _, release := range releases {
vals = append(vals, release.Name, release.Chart)
}
return carapace.ActionValuesDescribed(vals...)
})
})
}

0 comments on commit 0c8b774

Please sign in to comment.