kuberc: align internal and v1alpha1 go-types with v1beta1

Signed-off-by: Maciej Szulik <soltysh@gmail.com>

Kubernetes-commit: 0341b27c5d0dfb1d10818c9976f54af22971bedc
This commit is contained in:
Maciej Szulik 2025-05-21 13:32:37 +02:00 committed by Kubernetes Publisher
parent 2be4847754
commit cb7efba696
4 changed files with 159 additions and 157 deletions

View file

@ -24,26 +24,26 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
type Preference struct {
metav1.TypeMeta
// overrides allows changing default flag values of commands.
// Defaults allow changing default option values of commands.
// This is especially useful, when user doesn't want to explicitly
// set flags each time.
// set options each time.
// +optional
Overrides []CommandOverride
Defaults []CommandDefaults
// aliases allows defining command aliases for existing kubectl commands, with optional default flag values.
// Aliases allow defining command aliases for existing kubectl commands, with optional default option values.
// If the alias name collides with a built-in command, built-in command always takes precedence.
// Flag overrides defined in the overrides section do NOT apply to aliases for the same command.
// kubectl [ALIAS NAME] [USER_FLAGS] [USER_EXPLICIT_ARGS] expands to
// Option overrides defined in the defaults section do NOT apply to aliases for the same command.
// kubectl [ALIAS NAME] [USER_OPTIONS] [USER_EXPLICIT_ARGS] expands to
// kubectl [COMMAND] # built-in command alias points to
// [KUBERC_PREPEND_ARGS]
// [USER_FLAGS]
// [KUBERC_FLAGS] # rest of the flags that are not passed by user in [USER_FLAGS]
// [USER_OPTIONS]
// [KUBERC_OPTIONS] # rest of the options that are not passed by user in [USER_OPTIONS]
// [USER_EXPLICIT_ARGS]
// [KUBERC_APPEND_ARGS]
// e.g.
// - name: runx
// command: run
// flags:
// options:
// - name: image
// default: nginx
// appendArgs:
@ -53,7 +53,7 @@ type Preference struct {
// this will be expanded to "kubectl run --image=nginx test-pod -- custom-arg1"
// - name: getn
// command: get
// flags:
// options:
// - name: output
// default: wide
// prependArgs:
@ -78,26 +78,28 @@ type AliasOverride struct {
// AppendArgs stores the arguments such as resource names, etc.
// These arguments are appended to the USER_ARGS.
AppendArgs []string
// Flag is allocated to store the flag definitions of alias
Flags []CommandOverrideFlag
// Options is allocated to store the option definitions of alias.
// Options only modify the default value of the option and if
// user explicitly passes a value, explicit one is used.
Options []CommandOptionDefault
}
// CommandOverride stores the commands and their associated flag's
// CommandDefaults stores the commands and their associated option's
// default values.
type CommandOverride struct {
type CommandDefaults struct {
// Command refers to a command whose flag's default value is changed.
Command string
// Flags is a list of flags storing different default values.
Flags []CommandOverrideFlag
// Options is a list of options storing different default values.
Options []CommandOptionDefault
}
// CommandOverrideFlag stores the name and the specified default
// value of the flag.
type CommandOverrideFlag struct {
// Flag name (long form, without dashes).
Name string `json:"name"`
// CommandOptionDefault stores the name and the specified default
// value of an option.
type CommandOptionDefault struct {
// Option name (long form, without dashes).
Name string
// In a string format of a default value. It will be parsed
// by kubectl to the compatible value of the flag.
Default string `json:"default"`
// by kubectl to the compatible value of the option.
Default string
}

View file

@ -28,9 +28,9 @@ type Preference struct {
// This is especially useful, when user doesn't want to explicitly
// set flags each time.
// +listType=atomic
Overrides []CommandOverride `json:"overrides"`
Defaults []CommandDefaults `json:"overrides"`
// aliases allows defining command aliases for existing kubectl commands, with optional default flag values.
// aliases allow defining command aliases for existing kubectl commands, with optional default flag values.
// If the alias name collides with a built-in command, built-in command always takes precedence.
// Flag overrides defined in the overrides section do NOT apply to aliases for the same command.
// kubectl [ALIAS NAME] [USER_FLAGS] [USER_EXPLICIT_ARGS] expands to
@ -66,40 +66,40 @@ type Preference struct {
// AliasOverride stores the alias definitions.
type AliasOverride struct {
// Name is the name of alias that can only include alphabetical characters
// name is the name of alias that can only include alphabetical characters
// If the alias name conflicts with the built-in command,
// built-in command will be used.
Name string `json:"name"`
// Command is the single or set of commands to execute, such as "set env" or "create"
// command is the single or set of commands to execute, such as "set env" or "create"
Command string `json:"command"`
// PrependArgs stores the arguments such as resource names, etc.
// prependArgs stores the arguments such as resource names, etc.
// These arguments are inserted after the alias name.
// +listType=atomic
PrependArgs []string `json:"prependArgs,omitempty"`
// AppendArgs stores the arguments such as resource names, etc.
// appendArgs stores the arguments such as resource names, etc.
// These arguments are appended to the USER_ARGS.
// +listType=atomic
AppendArgs []string `json:"appendArgs,omitempty"`
// Flag is allocated to store the flag definitions of alias.
// Flag only modifies the default value of the flag and if
// flags is allocated to store the flag definitions of alias.
// flags only modifies the default value of the flag and if
// user explicitly passes a value, explicit one is used.
// +listType=atomic
Flags []CommandOverrideFlag `json:"flags,omitempty"`
Options []CommandOptionDefault `json:"flags,omitempty"`
}
// CommandOverride stores the commands and their associated flag's
// CommandDefaults stores the commands and their associated option's
// default values.
type CommandOverride struct {
// Command refers to a command whose flag's default value is changed.
type CommandDefaults struct {
// command refers to a command whose flag's default value is changed.
Command string `json:"command"`
// Flags is a list of flags storing different default values.
// flags is a list of flags storing different default values.
// +listType=atomic
Flags []CommandOverrideFlag `json:"flags"`
Options []CommandOptionDefault `json:"flags"`
}
// CommandOverrideFlag stores the name and the specified default
// value of the flag.
type CommandOverrideFlag struct {
// CommandOptionDefault stores the name and the specified default
// value of an option.
type CommandOptionDefault struct {
// Flag name (long form, without dashes).
Name string `json:"name"`

View file

@ -80,7 +80,7 @@ func NewPreferences() PreferencesHandler {
type aliasing struct {
appendArgs []string
prependArgs []string
flags []config.CommandOverrideFlag
flags []config.CommandOptionDefault
command *cobra.Command
}
@ -133,7 +133,7 @@ func (p *Preferences) applyOverrides(rootCmd *cobra.Command, kuberc *config.Pref
return nil
}
for _, c := range kuberc.Overrides {
for _, c := range kuberc.Defaults {
parsedCmds := strings.Fields(c.Command)
overrideCmd, _, err := rootCmd.Find(parsedCmds)
if err != nil {
@ -158,7 +158,7 @@ func (p *Preferences) applyOverrides(rootCmd *cobra.Command, kuberc *config.Pref
}
})
for _, fl := range c.Flags {
for _, fl := range c.Options {
existingFlag := cmd.Flag(fl.Name)
if existingFlag == nil {
return fmt.Errorf("invalid flag %s for command %s", fl.Name, c.Command)
@ -227,7 +227,7 @@ func (p *Preferences) applyAliases(rootCmd *cobra.Command, kuberc *config.Prefer
aliasArgs = &aliasing{
prependArgs: alias.PrependArgs,
appendArgs: alias.AppendArgs,
flags: alias.Flags,
flags: alias.Options,
command: aliasCmd,
}
break
@ -424,7 +424,7 @@ func searchInArgs(flagName string, shorthand string, allShorthands map[string]st
}
func validate(plugin *config.Preference) error {
validateFlag := func(flags []config.CommandOverrideFlag) error {
validateFlag := func(flags []config.CommandOptionDefault) error {
for _, flag := range flags {
if strings.HasPrefix(flag.Name, "-") {
return fmt.Errorf("flag name %s should be in long form without dashes", flag.Name)
@ -438,7 +438,7 @@ func validate(plugin *config.Preference) error {
return fmt.Errorf("invalid alias name, can only include alphabetical characters")
}
if err := validateFlag(alias.Flags); err != nil {
if err := validateFlag(alias.Options); err != nil {
return err
}
@ -448,8 +448,8 @@ func validate(plugin *config.Preference) error {
aliases[alias.Name] = struct{}{}
}
for _, override := range plugin.Overrides {
if err := validateFlag(override.Flags); err != nil {
for _, override := range plugin.Defaults {
if err := validateFlag(override.Options); err != nil {
return err
}
}

View file

@ -51,7 +51,7 @@ type testApplyOverride[T supportedTypes] struct {
nestedCmds []fakeCmds[T]
args []string
getPreferencesFunc func(kuberc string, errOut io.Writer) (*config.Preference, error)
expectedFLags []fakeFlag[T]
expectedFlags []fakeFlag[T]
expectedErr error
}
@ -60,7 +60,7 @@ type testApplyAlias[T supportedTypes] struct {
nestedCmds []fakeCmds[T]
args []string
getPreferencesFunc func(kuberc string, errOut io.Writer) (*config.Preference, error)
expectedFLags []fakeFlag[T]
expectedFlags []fakeFlag[T]
expectedCmd string
expectedArgs []string
expectedErr error
@ -91,10 +91,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -104,7 +104,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "changed",
@ -139,10 +139,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1 command2",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -152,7 +152,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "changed",
@ -193,10 +193,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1 command2",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "first",
Default: "changed",
@ -206,7 +206,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "first",
value: "changed",
@ -251,10 +251,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1 command2",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -264,7 +264,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -304,10 +304,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1 command2",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -317,7 +317,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -357,10 +357,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1 command2",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -370,7 +370,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -410,10 +410,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: " command1 command2 ",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -423,7 +423,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -463,10 +463,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1 command2",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -476,7 +476,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -512,10 +512,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1 command2",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -525,7 +525,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -562,10 +562,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1 command2",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -575,7 +575,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -613,10 +613,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1 command2",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -626,7 +626,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -663,10 +663,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1 command2",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -676,7 +676,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -718,10 +718,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1 command2",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -731,7 +731,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -781,10 +781,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1 command2",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -794,7 +794,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -824,10 +824,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -843,7 +843,7 @@ func TestApplyOverride(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "test",
@ -873,10 +873,10 @@ func TestApplyOverride(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "testalias",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -936,7 +936,7 @@ func TestApplyOverride(t *testing.T) {
t.Fatalf("unexpected error message %s\n", errWriter.String())
}
for _, expectedFlag := range test.expectedFLags {
for _, expectedFlag := range test.expectedFlags {
actualFlag := actualCmd.Flag(expectedFlag.name)
if actualFlag.Value.String() != expectedFlag.value {
t.Fatalf("unexpected flag value expected %s actual %s", expectedFlag.value, actualFlag.Value.String())
@ -972,10 +972,10 @@ func TestApplOverrideBool(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "false",
@ -985,7 +985,7 @@ func TestApplOverrideBool(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[bool]{
expectedFlags: []fakeFlag[bool]{
{
name: "firstflag",
value: false,
@ -1016,10 +1016,10 @@ func TestApplOverrideBool(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "false",
@ -1029,7 +1029,7 @@ func TestApplOverrideBool(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[bool]{
expectedFlags: []fakeFlag[bool]{
{
name: "firstflag",
value: true,
@ -1061,10 +1061,10 @@ func TestApplOverrideBool(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "false",
@ -1074,7 +1074,7 @@ func TestApplOverrideBool(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[bool]{
expectedFlags: []fakeFlag[bool]{
{
name: "firstflag",
value: true,
@ -1116,10 +1116,10 @@ func TestApplOverrideBool(t *testing.T) {
Kind: "Preference",
APIVersion: "kubectl.config.k8s.io/v1alpha1",
},
Overrides: []config.CommandOverride{
Defaults: []config.CommandDefaults{
{
Command: "command1",
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "false",
@ -1129,7 +1129,7 @@ func TestApplOverrideBool(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[bool]{
expectedFlags: []fakeFlag[bool]{
{
name: "firstflag",
value: true,
@ -1171,7 +1171,7 @@ func TestApplOverrideBool(t *testing.T) {
t.Fatalf("unexpected error message %s\n", errWriter.String())
}
for _, expectedFlag := range test.expectedFLags {
for _, expectedFlag := range test.expectedFlags {
actualFlag := actualCmd.Flag(expectedFlag.name)
actualValue, err := strconv.ParseBool(actualFlag.Value.String())
if err != nil {
@ -1219,7 +1219,7 @@ func TestApplyAliasBool(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "true",
@ -1229,7 +1229,7 @@ func TestApplyAliasBool(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[bool]{
expectedFlags: []fakeFlag[bool]{
{
name: "firstflag",
value: true,
@ -1273,7 +1273,7 @@ func TestApplyAliasBool(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "false",
@ -1283,7 +1283,7 @@ func TestApplyAliasBool(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[bool]{
expectedFlags: []fakeFlag[bool]{
{
name: "firstflag",
value: true,
@ -1328,7 +1328,7 @@ func TestApplyAliasBool(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "false",
@ -1338,7 +1338,7 @@ func TestApplyAliasBool(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[bool]{
expectedFlags: []fakeFlag[bool]{
{
name: "firstflag",
value: true,
@ -1393,7 +1393,7 @@ func TestApplyAliasBool(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "false",
@ -1403,7 +1403,7 @@ func TestApplyAliasBool(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[bool]{
expectedFlags: []fakeFlag[bool]{
{
name: "firstflag",
value: true,
@ -1469,7 +1469,7 @@ func TestApplyAliasBool(t *testing.T) {
t.Fatalf("unexpected command expected %s actual %s", test.expectedCmd, actualCmd.Name())
}
for _, expectedFlag := range test.expectedFLags {
for _, expectedFlag := range test.expectedFlags {
actualFlag := actualCmd.Flag(expectedFlag.name)
actualValue, err := strconv.ParseBool(actualFlag.Value.String())
if err != nil {
@ -1530,7 +1530,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -1540,7 +1540,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "changed",
@ -1583,7 +1583,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -1593,7 +1593,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "changed",
@ -1637,7 +1637,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -1647,7 +1647,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "changed",
@ -1695,7 +1695,7 @@ func TestApplyAlias(t *testing.T) {
"arg1",
"arg2",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -1705,7 +1705,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "changed",
@ -1756,7 +1756,7 @@ func TestApplyAlias(t *testing.T) {
"arg3",
"arg4",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -1766,7 +1766,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "changed",
@ -1821,7 +1821,7 @@ func TestApplyAlias(t *testing.T) {
"arg3",
"arg4",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -1831,7 +1831,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -1878,7 +1878,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -1892,7 +1892,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -1935,7 +1935,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "--firstflag",
Default: "changed",
@ -1949,7 +1949,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -1992,7 +1992,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -2035,7 +2035,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -2079,7 +2079,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -2089,7 +2089,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -2134,7 +2134,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -2144,7 +2144,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -2190,7 +2190,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -2200,7 +2200,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -2249,7 +2249,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -2259,7 +2259,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "explicit",
@ -2306,7 +2306,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -2316,7 +2316,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "changed",
@ -2360,7 +2360,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -2370,7 +2370,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "changed",
@ -2414,7 +2414,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed",
@ -2424,7 +2424,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "changed",
@ -2480,7 +2480,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed2",
@ -2490,7 +2490,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "changed2",
@ -2546,7 +2546,7 @@ func TestApplyAlias(t *testing.T) {
"resources",
"nodes",
},
Flags: []config.CommandOverrideFlag{
Options: []config.CommandOptionDefault{
{
Name: "firstflag",
Default: "changed2",
@ -2556,7 +2556,7 @@ func TestApplyAlias(t *testing.T) {
},
}, nil
},
expectedFLags: []fakeFlag[string]{
expectedFlags: []fakeFlag[string]{
{
name: "firstflag",
value: "changed2",
@ -2614,7 +2614,7 @@ func TestApplyAlias(t *testing.T) {
t.Fatalf("unexpected command expected %s actual %s", test.expectedCmd, actualCmd.Name())
}
for _, expectedFlag := range test.expectedFLags {
for _, expectedFlag := range test.expectedFlags {
actualFlag := actualCmd.Flag(expectedFlag.name)
if actualFlag.Value.String() != expectedFlag.value {
t.Fatalf("unexpected flag value expected %s actual %s", expectedFlag.value, actualFlag.Value.String())