mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
debug: ignore invalid target flags (#7860)
This commit is contained in:
committed by
Brian Kassouf
parent
0e7604ca50
commit
fcf30cc328
@@ -389,6 +389,13 @@ func (c *DebugCommand) preflight(rawArgs []string) (string, error) {
|
|||||||
|
|
||||||
if len(c.flagTargets) == 0 {
|
if len(c.flagTargets) == 0 {
|
||||||
c.flagTargets = c.defaultTargets()
|
c.flagTargets = c.defaultTargets()
|
||||||
|
} else {
|
||||||
|
// Check for any invalid targets and ignore them if found
|
||||||
|
invalidTargets := strutil.Difference(c.flagTargets, c.defaultTargets(), true)
|
||||||
|
if len(invalidTargets) != 0 {
|
||||||
|
c.UI.Info(fmt.Sprintf("Ignoring invalid targets: %s", strings.Join(invalidTargets, ", ")))
|
||||||
|
c.flagTargets = strutil.Difference(c.flagTargets, invalidTargets, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we can talk to the server
|
// Make sure we can talk to the server
|
||||||
|
|||||||
@@ -61,6 +61,16 @@ func TestDebugCommand_Run(t *testing.T) {
|
|||||||
"Too many arguments",
|
"Too many arguments",
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"invalid_target",
|
||||||
|
[]string{
|
||||||
|
"-duration=1s",
|
||||||
|
fmt.Sprintf("-output=%s/too_many_args", testDir),
|
||||||
|
"-target=foo",
|
||||||
|
},
|
||||||
|
"Ignoring invalid targets: foo",
|
||||||
|
0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
|||||||
Reference in New Issue
Block a user