Skip to content

Commit

Permalink
Add build --load-restrictor completion
Browse files Browse the repository at this point in the history
Signed-off-by: Sylvain Rabot <sylvain@abstraction.fr>
  • Loading branch information
sylr committed Oct 28, 2023
1 parent e002b49 commit 7228a28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kustomize/commands/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ func NewCmdBuild(
AddFlagOutputPath(cmd.Flags())
AddFunctionBasicsFlags(cmd.Flags())
AddFlagLoadRestrictor(cmd.Flags())
AddFlagLoadRestrictorCompletion(cmd)
AddFlagEnablePlugins(cmd.Flags())
AddFlagReorderOutput(cmd.Flags())
AddFlagEnableManagedbyLabel(cmd.Flags())

msg := "Error marking flag '%s' as deprecated: %v"
err := cmd.Flags().MarkDeprecated(flagReorderOutputName,
"use the new 'sortOptions' field in kustomization.yaml instead.")
Expand Down
10 changes: 10 additions & 0 deletions kustomize/commands/build/flagloadrestrictor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package build
import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"sigs.k8s.io/kustomize/api/types"
)
Expand All @@ -23,6 +24,15 @@ func AddFlagLoadRestrictor(set *pflag.FlagSet) {
"relocatability of the kustomization.")
}

func AddFlagLoadRestrictorCompletion(cmd *cobra.Command) {
cmd.RegisterFlagCompletionFunc(flagLoadRestrictorName, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {

Check failure on line 28 in kustomize/commands/build/flagloadrestrictor.go

View workflow job for this annotation

GitHub Actions / Lint

Error return value of `cmd.RegisterFlagCompletionFunc` is not checked (errcheck)
return []string{
types.LoadRestrictionsNone.String(),
types.LoadRestrictionsRootOnly.String(),
}, cobra.ShellCompDirectiveNoFileComp
})
}

func validateFlagLoadRestrictor() error {
switch theFlags.loadRestrictor {
case types.LoadRestrictionsRootOnly.String(),
Expand Down

0 comments on commit 7228a28

Please sign in to comment.