Skip to content

Commit

Permalink
Merge pull request #2261 from rsteube/helm-actionreleases
Browse files Browse the repository at this point in the history
helm: extracted local ActionReleases
  • Loading branch information
rsteube authored Feb 22, 2024
2 parents 9f62c84 + d6d52bd commit 31bd8bb
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 75 deletions.
16 changes: 16 additions & 0 deletions completers/helm_completer/cmd/action/release.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package action

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/helm"
"github.com/spf13/cobra"
)

func ActionReleases(cmd *cobra.Command) carapace.Action {
return carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionReleases(helm.ReleasesOpts{
Namespace: cmd.Root().Flag("namespace").Value.String(),
KubeContext: cmd.Root().Flag("kube-context").Value.String(),
})
})
}
9 changes: 2 additions & 7 deletions completers/helm_completer/cmd/get_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/helm"
"github.com/rsteube/carapace-bin/completers/helm_completer/cmd/action"
"github.com/spf13/cobra"
)

Expand All @@ -19,11 +19,6 @@ func init() {
getCmd.AddCommand(get_allCmd)

carapace.Gen(get_allCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionReleases(helm.ReleasesOpts{
Namespace: rootCmd.Flag("namespace").Value.String(),
KubeContext: rootCmd.Flag("kube-context").Value.String(),
})
}),
action.ActionReleases(get_allCmd),
)
}
9 changes: 2 additions & 7 deletions completers/helm_completer/cmd/get_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/helm"
"github.com/rsteube/carapace-bin/completers/helm_completer/cmd/action"
"github.com/spf13/cobra"
)

Expand All @@ -18,11 +18,6 @@ func init() {
getCmd.AddCommand(get_hooksCmd)

carapace.Gen(get_hooksCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionReleases(helm.ReleasesOpts{
Namespace: rootCmd.Flag("namespace").Value.String(),
KubeContext: rootCmd.Flag("kube-context").Value.String(),
})
}),
action.ActionReleases(get_hooksCmd),
)
}
9 changes: 2 additions & 7 deletions completers/helm_completer/cmd/get_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/helm"
"github.com/rsteube/carapace-bin/completers/helm_completer/cmd/action"
"github.com/spf13/cobra"
)

Expand All @@ -18,11 +18,6 @@ func init() {
getCmd.AddCommand(get_manifestCmd)

carapace.Gen(get_manifestCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionReleases(helm.ReleasesOpts{
Namespace: rootCmd.Flag("namespace").Value.String(),
KubeContext: rootCmd.Flag("kube-context").Value.String(),
})
}),
action.ActionReleases(get_manifestCmd),
)
}
9 changes: 2 additions & 7 deletions completers/helm_completer/cmd/get_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/helm"
"github.com/rsteube/carapace-bin/completers/helm_completer/cmd/action"
"github.com/spf13/cobra"
)

Expand All @@ -18,11 +18,6 @@ func init() {
getCmd.AddCommand(get_notesCmd)

carapace.Gen(get_notesCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionReleases(helm.ReleasesOpts{
Namespace: rootCmd.Flag("namespace").Value.String(),
KubeContext: rootCmd.Flag("kube-context").Value.String(),
})
}),
action.ActionReleases(get_notesCmd),
)
}
9 changes: 2 additions & 7 deletions completers/helm_completer/cmd/get_values.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/helm"
"github.com/rsteube/carapace-bin/completers/helm_completer/cmd/action"
"github.com/spf13/cobra"
)

Expand All @@ -24,11 +24,6 @@ func init() {
})

carapace.Gen(get_valuesCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionReleases(helm.ReleasesOpts{
Namespace: rootCmd.Flag("namespace").Value.String(),
KubeContext: rootCmd.Flag("kube-context").Value.String(),
})
}),
action.ActionReleases(get_valuesCmd),
)
}
9 changes: 2 additions & 7 deletions completers/helm_completer/cmd/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/helm"
"github.com/rsteube/carapace-bin/completers/helm_completer/cmd/action"
"github.com/spf13/cobra"
)

Expand All @@ -24,11 +24,6 @@ func init() {
})

carapace.Gen(historyCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionReleases(helm.ReleasesOpts{
Namespace: rootCmd.Flag("namespace").Value.String(),
KubeContext: rootCmd.Flag("kube-context").Value.String(),
})
}),
action.ActionReleases(historyCmd),
)
}
8 changes: 2 additions & 6 deletions completers/helm_completer/cmd/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"time"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/helm_completer/cmd/action"
"github.com/rsteube/carapace-bin/pkg/actions/tools/helm"
"github.com/spf13/cobra"
)
Expand All @@ -29,12 +30,7 @@ func init() {
rootCmd.AddCommand(rollbackCmd)

carapace.Gen(rollbackCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionReleases(helm.ReleasesOpts{
Namespace: rootCmd.Flag("namespace").Value.String(),
KubeContext: rootCmd.Flag("kube-context").Value.String(),
})
}),
action.ActionReleases(rollbackCmd),
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionRevisions(c.Args[0])
}),
Expand Down
9 changes: 2 additions & 7 deletions completers/helm_completer/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/helm"
"github.com/rsteube/carapace-bin/completers/helm_completer/cmd/action"
"github.com/spf13/cobra"
)

Expand All @@ -25,11 +25,6 @@ func init() {
})

carapace.Gen(statusCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionReleases(helm.ReleasesOpts{
Namespace: rootCmd.Flag("namespace").Value.String(),
KubeContext: rootCmd.Flag("kube-context").Value.String(),
})
}),
action.ActionReleases(statusCmd),
)
}
9 changes: 2 additions & 7 deletions completers/helm_completer/cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/helm"
"github.com/rsteube/carapace-bin/completers/helm_completer/cmd/action"
"github.com/spf13/cobra"
)

Expand All @@ -23,11 +23,6 @@ func init() {
rootCmd.AddCommand(testCmd)

carapace.Gen(testCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionReleases(helm.ReleasesOpts{
Namespace: rootCmd.Flag("namespace").Value.String(),
KubeContext: rootCmd.Flag("kube-context").Value.String(),
})
}),
action.ActionReleases(testCmd),
)
}
9 changes: 2 additions & 7 deletions completers/helm_completer/cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/helm"
"github.com/rsteube/carapace-bin/completers/helm_completer/cmd/action"
"github.com/spf13/cobra"
)

Expand All @@ -25,11 +25,6 @@ func init() {
rootCmd.AddCommand(uninstallCmd)

carapace.Gen(uninstallCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionReleases(helm.ReleasesOpts{
Namespace: rootCmd.Flag("namespace").Value.String(),
KubeContext: rootCmd.Flag("kube-context").Value.String(),
})
}),
action.ActionReleases(uninstallCmd),
)
}
8 changes: 2 additions & 6 deletions completers/helm_completer/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/helm_completer/cmd/action"
"github.com/rsteube/carapace-bin/pkg/actions/tools/helm"
"github.com/rsteube/carapace/pkg/condition"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -86,12 +87,7 @@ func init() {
})

carapace.Gen(upgradeCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return helm.ActionReleases(helm.ReleasesOpts{
Namespace: rootCmd.Flag("namespace").Value.String(),
KubeContext: rootCmd.Flag("kube-context").Value.String(),
})
}),
action.ActionReleases(upgradeCmd),
carapace.Batch(
carapace.ActionFiles(),
helm.ActionRepositoryCharts().Unless(condition.CompletingPath),
Expand Down

0 comments on commit 31bd8bb

Please sign in to comment.