Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
eec0e3e9
Commit
eec0e3e9
authored
9 years ago
by
Alex Dadgar
Browse files
Options
Download
Email Patches
Plain Diff
inspect/stop uses prefix search
parent
52347d42
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
command/inspect.go
+26
-28
command/inspect.go
command/stop.go
+25
-28
command/stop.go
with
51 additions
and
56 deletions
+51
-56
command/inspect.go
+
26
-
28
View file @
eec0e3e9
...
...
@@ -50,36 +50,34 @@ func (c *InspectCommand) Run(args []string) int {
}
// Check if the job exists
job
,
_
,
err
:=
client
.
Jobs
()
.
RawJob
(
jobID
,
nil
)
job
s
,
_
,
err
:=
client
.
Jobs
()
.
PrefixList
(
jobID
)
if
err
!=
nil
{
jobs
,
_
,
err
:=
client
.
Jobs
()
.
PrefixList
(
jobID
)
if
err
!=
nil
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"Error inspecting job: %s"
,
err
))
return
1
}
if
len
(
jobs
)
==
0
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"No job(s) with prefix or id %q found"
,
jobID
))
return
1
}
if
len
(
jobs
)
>
1
{
out
:=
make
([]
string
,
len
(
jobs
)
+
1
)
out
[
0
]
=
"ID|Type|Priority|Status"
for
i
,
job
:=
range
jobs
{
out
[
i
+
1
]
=
fmt
.
Sprintf
(
"%s|%s|%d|%s"
,
job
.
ID
,
job
.
Type
,
job
.
Priority
,
job
.
Status
)
}
c
.
Ui
.
Output
(
fmt
.
Sprintf
(
"Prefix matched multiple jobs
\n\n
%s"
,
formatList
(
out
)))
return
0
}
// Prefix lookup matched a single job
job
,
_
,
err
=
client
.
Jobs
()
.
RawJob
(
jobs
[
0
]
.
ID
,
nil
)
if
err
!=
nil
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"Error inspecting job: %s"
,
err
))
return
1
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"Error inspecting job: %s"
,
err
))
return
1
}
if
len
(
jobs
)
==
0
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"No job(s) with prefix or id %q found"
,
jobID
))
return
1
}
if
len
(
jobs
)
>
1
{
out
:=
make
([]
string
,
len
(
jobs
)
+
1
)
out
[
0
]
=
"ID|Type|Priority|Status"
for
i
,
job
:=
range
jobs
{
out
[
i
+
1
]
=
fmt
.
Sprintf
(
"%s|%s|%d|%s"
,
job
.
ID
,
job
.
Type
,
job
.
Priority
,
job
.
Status
)
}
c
.
Ui
.
Output
(
fmt
.
Sprintf
(
"Prefix matched multiple jobs
\n\n
%s"
,
formatList
(
out
)))
return
0
}
// Prefix lookup matched a single job
job
,
_
,
err
:=
client
.
Jobs
()
.
RawJob
(
jobs
[
0
]
.
ID
,
nil
)
if
err
!=
nil
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"Error inspecting job: %s"
,
err
))
return
1
}
// Print the contents of the job
...
...
This diff is collapsed.
Click to expand it.
command/stop.go
+
25
-
28
View file @
eec0e3e9
...
...
@@ -75,36 +75,33 @@ func (c *StopCommand) Run(args []string) int {
}
// Check if the job exists
job
,
_
,
err
:=
client
.
Jobs
()
.
Info
(
jobID
,
nil
)
job
s
,
_
,
err
:=
client
.
Jobs
()
.
PrefixList
(
jobID
)
if
err
!=
nil
{
jobs
,
_
,
err
:=
client
.
Jobs
()
.
PrefixList
(
jobID
)
if
err
!=
nil
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"Error deregistering job: %s"
,
err
))
return
1
}
if
len
(
jobs
)
==
0
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"No job(s) with prefix or id %q found"
,
jobID
))
return
1
}
if
len
(
jobs
)
>
1
{
out
:=
make
([]
string
,
len
(
jobs
)
+
1
)
out
[
0
]
=
"ID|Type|Priority|Status"
for
i
,
job
:=
range
jobs
{
out
[
i
+
1
]
=
fmt
.
Sprintf
(
"%s|%s|%d|%s"
,
job
.
ID
,
job
.
Type
,
job
.
Priority
,
job
.
Status
)
}
c
.
Ui
.
Output
(
fmt
.
Sprintf
(
"Prefix matched multiple jobs
\n\n
%s"
,
formatList
(
out
)))
return
0
}
// Prefix lookup matched a single job
job
,
_
,
err
=
client
.
Jobs
()
.
Info
(
jobs
[
0
]
.
ID
,
nil
)
if
err
!=
nil
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"Error deregistering job: %s"
,
err
))
return
1
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"Error deregistering job: %s"
,
err
))
return
1
}
if
len
(
jobs
)
==
0
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"No job(s) with prefix or id %q found"
,
jobID
))
return
1
}
if
len
(
jobs
)
>
1
{
out
:=
make
([]
string
,
len
(
jobs
)
+
1
)
out
[
0
]
=
"ID|Type|Priority|Status"
for
i
,
job
:=
range
jobs
{
out
[
i
+
1
]
=
fmt
.
Sprintf
(
"%s|%s|%d|%s"
,
job
.
ID
,
job
.
Type
,
job
.
Priority
,
job
.
Status
)
}
c
.
Ui
.
Output
(
fmt
.
Sprintf
(
"Prefix matched multiple jobs
\n\n
%s"
,
formatList
(
out
)))
return
0
}
// Prefix lookup matched a single job
job
,
_
,
err
:=
client
.
Jobs
()
.
Info
(
jobs
[
0
]
.
ID
,
nil
)
if
err
!=
nil
{
c
.
Ui
.
Error
(
fmt
.
Sprintf
(
"Error deregistering job: %s"
,
err
))
return
1
}
// Invoke the stop
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help