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

status commands handle uuid prefixes with hyphens #3122

Merged
merged 3 commits into from
Aug 29, 2017
Merged
Show file tree
Hide file tree
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: 1 addition & 1 deletion command/alloc_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (c *AllocStatusCommand) Run(args []string) int {
c.Ui.Error(fmt.Sprintf("Identifier must contain at least two characters."))
return 1
}
if len(allocID)%2 == 1 {
if hyphens := strings.Count(allocID, "-"); (len(allocID)-hyphens)%2 == 1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is a good candidate for helpers.go?

// Identifiers must be of even length, so we strip off the last byte
// to provide a consistent user experience.
allocID = allocID[:len(allocID)-1]
Expand Down
2 changes: 1 addition & 1 deletion command/eval_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (c *EvalStatusCommand) Run(args []string) int {
c.Ui.Error(fmt.Sprintf("Identifier must contain at least two characters."))
return 1
}
if len(evalID)%2 == 1 {
if hyphens := strings.Count(evalID, "-"); (len(evalID)-hyphens)%2 == 1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to write a test to validate this behavior/bug fix

// Identifiers must be of even length, so we strip off the last byte
// to provide a consistent user experience.
evalID = evalID[:len(evalID)-1]
Expand Down
2 changes: 1 addition & 1 deletion command/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (f *FSCommand) Run(args []string) int {
f.Ui.Error(fmt.Sprintf("Alloc ID must contain at least two characters."))
return 1
}
if len(allocID)%2 == 1 {
if hyphens := strings.Count(allocID, "-"); (len(allocID)-hyphens)%2 == 1 {
// Identifiers must be of even length, so we strip off the last byte
// to provide a consistent user experience.
allocID = allocID[:len(allocID)-1]
Expand Down
2 changes: 1 addition & 1 deletion command/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (l *LogsCommand) Run(args []string) int {
l.Ui.Error(fmt.Sprintf("Alloc ID must contain at least two characters."))
return 1
}
if len(allocID)%2 == 1 {
if hyphens := strings.Count(allocID, "-"); (len(allocID)-hyphens)%2 == 1 {
// Identifiers must be of even length, so we strip off the last byte
// to provide a consistent user experience.
allocID = allocID[:len(allocID)-1]
Expand Down
2 changes: 1 addition & 1 deletion command/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (m *monitor) monitor(evalID string, allowPrefix bool) int {
m.ui.Error(fmt.Sprintf("Identifier must contain at least two characters."))
return 1
}
if len(evalID)%2 == 1 {
if hyphens := strings.Count(evalID, "-"); (len(evalID)-hyphens)%2 == 1 {
// Identifiers must be of even length, so we strip off the last byte
// to provide a consistent user experience.
evalID = evalID[:len(evalID)-1]
Expand Down
2 changes: 1 addition & 1 deletion command/node_drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (c *NodeDrainCommand) Run(args []string) int {
c.Ui.Error(fmt.Sprintf("Identifier must contain at least two characters."))
return 1
}
if len(nodeID)%2 == 1 {
if hyphens := strings.Count(nodeID, "-"); (len(nodeID)-hyphens)%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]
Expand Down
2 changes: 1 addition & 1 deletion command/node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (c *NodeStatusCommand) Run(args []string) int {
c.Ui.Error(fmt.Sprintf("Identifier must contain at least two characters."))
return 1
}
if len(nodeID)%2 == 1 {
if hyphens := strings.Count(nodeID, "-"); (len(nodeID)-hyphens)%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]
Expand Down