mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
Multiple matched objects now treated as an error condition.
This commit is contained in:
@@ -81,8 +81,8 @@ func (c *DeploymentFailCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
if len(possible) != 0 {
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple deployments\n\n%s", formatDeployments(possible, length)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple deployments\n\n%s", formatDeployments(possible, length)))
|
||||
return 1
|
||||
}
|
||||
|
||||
u, _, err := client.Deployments().Fail(deploy.ID, nil)
|
||||
|
||||
@@ -73,8 +73,8 @@ func (c *DeploymentPauseCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
if len(possible) != 0 {
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple deployments\n\n%s", formatDeployments(possible, length)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple deployments\n\n%s", formatDeployments(possible, length)))
|
||||
return 1
|
||||
}
|
||||
|
||||
if _, _, err := client.Deployments().Pause(deploy.ID, true, nil); err != nil {
|
||||
|
||||
@@ -92,8 +92,8 @@ func (c *DeploymentPromoteCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
if len(possible) != 0 {
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple deployments\n\n%s", formatDeployments(possible, length)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple deployments\n\n%s", formatDeployments(possible, length)))
|
||||
return 1
|
||||
}
|
||||
|
||||
var u *api.DeploymentUpdateResponse
|
||||
|
||||
@@ -79,8 +79,8 @@ func (c *DeploymentResumeCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
if len(possible) != 0 {
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple deployments\n\n%s", formatDeployments(possible, length)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple deployments\n\n%s", formatDeployments(possible, length)))
|
||||
return 1
|
||||
}
|
||||
|
||||
u, _, err := client.Deployments().Pause(deploy.ID, false, nil)
|
||||
|
||||
@@ -84,8 +84,8 @@ func (c *DeploymentStatusCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
if len(possible) != 0 {
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple deployments\n\n%s", formatDeployments(possible, length)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple deployments\n\n%s", formatDeployments(possible, length)))
|
||||
return 1
|
||||
}
|
||||
|
||||
if json || len(tmpl) > 0 {
|
||||
|
||||
@@ -137,8 +137,8 @@ func (c *EvalStatusCommand) Run(args []string) int {
|
||||
failures,
|
||||
)
|
||||
}
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple evaluations\n\n%s", formatList(out)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple evaluations\n\n%s", formatList(out)))
|
||||
return 1
|
||||
}
|
||||
|
||||
// If we are in monitor mode, monitor and exit
|
||||
|
||||
@@ -160,8 +160,8 @@ func (f *FSCommand) Run(args []string) int {
|
||||
if len(allocs) > 1 {
|
||||
// Format the allocs
|
||||
out := formatAllocListStubs(allocs, verbose, length)
|
||||
f.Ui.Output(fmt.Sprintf("Prefix matched multiple allocations\n\n%s", out))
|
||||
return 0
|
||||
f.Ui.Error(fmt.Sprintf("Prefix matched multiple allocations\n\n%s", out))
|
||||
return 1
|
||||
}
|
||||
// Prefix lookup matched a single allocation
|
||||
alloc, _, err := client.Allocations().Info(allocs[0].ID, nil)
|
||||
|
||||
@@ -97,8 +97,8 @@ func (c *InspectCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
if len(jobs) > 1 && strings.TrimSpace(jobID) != jobs[0].ID {
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 1
|
||||
}
|
||||
|
||||
var version *uint64
|
||||
|
||||
@@ -82,8 +82,8 @@ func (c *JobDeploymentsCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
if len(jobs) > 1 && strings.TrimSpace(jobID) != jobs[0].ID {
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 1
|
||||
}
|
||||
jobID = jobs[0].ID
|
||||
|
||||
|
||||
@@ -100,8 +100,8 @@ func (c *JobHistoryCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
if len(jobs) > 1 && strings.TrimSpace(jobID) != jobs[0].ID {
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 1
|
||||
}
|
||||
|
||||
// Prefix lookup matched a single job
|
||||
|
||||
@@ -96,8 +96,8 @@ func (c *JobPromoteCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
if len(jobs) > 1 && strings.TrimSpace(jobID) != jobs[0].ID {
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 1
|
||||
}
|
||||
jobID = jobs[0].ID
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ func (c *JobRevertCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
if len(jobs) > 1 && strings.TrimSpace(jobID) != jobs[0].ID {
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 1
|
||||
}
|
||||
|
||||
// Prefix lookup matched a single job
|
||||
|
||||
@@ -136,8 +136,8 @@ func (l *LogsCommand) Run(args []string) int {
|
||||
if len(allocs) > 1 {
|
||||
// Format the allocs
|
||||
out := formatAllocListStubs(allocs, verbose, length)
|
||||
l.Ui.Output(fmt.Sprintf("Prefix matched multiple allocations\n\n%s", out))
|
||||
return 0
|
||||
l.Ui.Error(fmt.Sprintf("Prefix matched multiple allocations\n\n%s", out))
|
||||
return 1
|
||||
}
|
||||
// Prefix lookup matched a single allocation
|
||||
alloc, _, err := client.Allocations().Info(allocs[0].ID, nil)
|
||||
|
||||
@@ -124,8 +124,8 @@ func (c *NodeDrainCommand) Run(args []string) int {
|
||||
node.Status)
|
||||
}
|
||||
// Dump the output
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple nodes\n\n%s", formatList(out)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple nodes\n\n%s", formatList(out)))
|
||||
return 1
|
||||
}
|
||||
|
||||
// Prefix lookup matched a single node
|
||||
|
||||
@@ -231,8 +231,8 @@ func (c *NodeStatusCommand) Run(args []string) int {
|
||||
node.Status)
|
||||
}
|
||||
// Dump the output
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple nodes\n\n%s", formatList(out)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple nodes\n\n%s", formatList(out)))
|
||||
return 1
|
||||
}
|
||||
// Prefix lookup matched a single node
|
||||
node, _, err := client.Nodes().Info(nodes[0].ID, nil)
|
||||
|
||||
@@ -121,8 +121,8 @@ func (c *StatusCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
if len(jobs) > 1 && strings.TrimSpace(jobID) != jobs[0].ID {
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 1
|
||||
}
|
||||
// Prefix lookup matched a single job
|
||||
job, _, err := client.Jobs().Info(jobs[0].ID, nil)
|
||||
|
||||
@@ -94,8 +94,8 @@ func (c *StopCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
if len(jobs) > 1 && strings.TrimSpace(jobID) != jobs[0].ID {
|
||||
c.Ui.Output(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 0
|
||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs)))
|
||||
return 1
|
||||
}
|
||||
// Prefix lookup matched a single job
|
||||
job, _, err := client.Jobs().Info(jobs[0].ID, nil)
|
||||
|
||||
Reference in New Issue
Block a user