Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --load-restrictor completion #5411

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions kustomize/commands/build/build.go
Original file line number Diff line number Diff line change
@@ -105,9 +105,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.")
10 changes: 10 additions & 0 deletions kustomize/commands/build/flagloadrestrictor.go
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ package build
import (
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"sigs.k8s.io/kustomize/api/types"
)
@@ -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) {
return []string{
types.LoadRestrictionsNone.String(),
types.LoadRestrictionsRootOnly.String(),
}, cobra.ShellCompDirectiveNoFileComp
})
}

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