mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Provide a consistent user experience with prefix based lookups.
* Require at least two characters for identifier * Automatically strip off the last character in case of uneven length
This commit is contained in:
@@ -110,10 +110,15 @@ func (c *NodeStatusCommand) Run(args []string) int {
|
||||
nodeID := args[0]
|
||||
node, _, err := client.Nodes().Info(nodeID, nil)
|
||||
if err != nil {
|
||||
if len(nodeID)%2 != 0 {
|
||||
c.Ui.Error(fmt.Sprintf("Identifier (without hyphens) must be of even length."))
|
||||
if len(nodeID) == 1 {
|
||||
c.Ui.Error(fmt.Sprintf("Identifier must contain at least two characters."))
|
||||
return 1
|
||||
}
|
||||
if len(nodeID)%2 == 1 {
|
||||
// Identifiers must be of even length, so we strip off the last byte
|
||||
// to provide a consistent user experience.
|
||||
nodeID = nodeID[:len(nodeID)-1]
|
||||
}
|
||||
|
||||
// Exact lookup failed, try with prefix based search
|
||||
nodes, _, err := client.Nodes().PrefixList(nodeID)
|
||||
|
||||
Reference in New Issue
Block a user