Fix airshipctl config get-context maximum args
Limit the number of arguments that can be passed to get-context command to 1 for now Closes: #526 Change-Id: Ib140fc836e01c284c05719dfb7e3f29d0b191538
This commit is contained in:
parent
a0cfddab1b
commit
f70e93762f
@ -44,10 +44,12 @@ airshipctl config get-context exampleContext
|
|||||||
func NewGetContextCommand(cfgFactory config.Factory) *cobra.Command {
|
func NewGetContextCommand(cfgFactory config.Factory) *cobra.Command {
|
||||||
o := &config.ContextOptions{}
|
o := &config.ContextOptions{}
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "get-context [NAME]",
|
Use: "get-context CONTEXT_NAME",
|
||||||
Short: "Get context information from the airshipctl config",
|
Short: "Get context information from the airshipctl config",
|
||||||
Long: getContextLong[1:],
|
Long: getContextLong[1:],
|
||||||
Example: getContextExample,
|
Example: getContextExample,
|
||||||
|
// Adding a maximum args cap for documentation purpose
|
||||||
|
Args: cobra.MaximumNArgs(1),
|
||||||
Aliases: []string{"get-contexts"},
|
Aliases: []string{"get-contexts"},
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
airconfig, err := cfgFactory()
|
airconfig, err := cfgFactory()
|
||||||
|
@ -50,7 +50,7 @@ func TestGetContextCmd(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "get-all-contexts",
|
Name: "get-all-contexts",
|
||||||
CmdLine: fmt.Sprintf("%s %s", fooContext, barContext),
|
CmdLine: fmt.Sprintf("%s", barContext),
|
||||||
Cmd: cmd.NewGetContextCommand(settings),
|
Cmd: cmd.NewGetContextCommand(settings),
|
||||||
},
|
},
|
||||||
// This is not implemented yet
|
// This is not implemented yet
|
||||||
@ -58,6 +58,7 @@ func TestGetContextCmd(t *testing.T) {
|
|||||||
Name: "get-multiple-contexts",
|
Name: "get-multiple-contexts",
|
||||||
CmdLine: fmt.Sprintf("%s %s", fooContext, barContext),
|
CmdLine: fmt.Sprintf("%s %s", fooContext, barContext),
|
||||||
Cmd: cmd.NewGetContextCommand(settings),
|
Cmd: cmd.NewGetContextCommand(settings),
|
||||||
|
Error: fmt.Errorf("accepts at most 1 arg(s), received 2"),
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,3 @@
|
|||||||
managementConfiguration: ""
|
managementConfiguration: ""
|
||||||
manifest: Manifest_ContextBar
|
manifest: Manifest_ContextBar
|
||||||
|
|
||||||
managementConfiguration: ""
|
|
||||||
manifest: Manifest_ContextBaz
|
|
||||||
|
|
||||||
managementConfiguration: ""
|
|
||||||
manifest: Manifest_ContextFoo
|
|
||||||
|
|
||||||
|
@ -1,9 +1,23 @@
|
|||||||
managementConfiguration: ""
|
Error: accepts at most 1 arg(s), received 2
|
||||||
manifest: Manifest_ContextBar
|
Usage:
|
||||||
|
get-context CONTEXT_NAME [flags]
|
||||||
|
|
||||||
managementConfiguration: ""
|
Aliases:
|
||||||
manifest: Manifest_ContextBaz
|
get-context, get-contexts
|
||||||
|
|
||||||
managementConfiguration: ""
|
Examples:
|
||||||
manifest: Manifest_ContextFoo
|
|
||||||
|
# List all contexts
|
||||||
|
airshipctl config get-contexts
|
||||||
|
|
||||||
|
# Display the current context
|
||||||
|
airshipctl config get-context --current
|
||||||
|
|
||||||
|
# Display a specific context
|
||||||
|
airshipctl config get-context exampleContext
|
||||||
|
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
--current get the current context
|
||||||
|
-h, --help help for get-context
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Error: missing configuration: context with name 'contextMissing'
|
Error: missing configuration: context with name 'contextMissing'
|
||||||
Usage:
|
Usage:
|
||||||
get-context [NAME] [flags]
|
get-context CONTEXT_NAME [flags]
|
||||||
|
|
||||||
Aliases:
|
Aliases:
|
||||||
get-context, get-contexts
|
get-context, get-contexts
|
||||||
|
@ -8,7 +8,7 @@ Display information about contexts such as associated manifests, users, and clus
|
|||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
airshipctl config get-context [NAME] [flags]
|
airshipctl config get-context CONTEXT_NAME [flags]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
Loading…
Reference in New Issue
Block a user