Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
David Kosztka
Pod
Commits
498c5b03
Commit
498c5b03
authored
4 years ago
by
Bijun Li
Browse files
Options
Download
Email Patches
Plain Diff
Update run_service args
parent
6f206049
action-api
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/error.rs
+20
-0
src/error.rs
src/services_api.rs
+8
-18
src/services_api.rs
with
28 additions
and
18 deletions
+28
-18
src/error.rs
+
20
-
0
View file @
498c5b03
...
...
@@ -87,3 +87,23 @@ impl<T> From<std::sync::PoisonError<T>> for Error {
}
}
}
impl
From
<
std
::
io
::
Error
>
for
Error
{
fn
from
(
err
:
std
::
io
::
Error
)
->
Error
{
let
msg
=
format!
(
"IO error {}"
,
err
);
Error
{
code
:
StatusCode
::
BAD_REQUEST
,
msg
,
}
}
}
impl
From
<
std
::
string
::
FromUtf8Error
>
for
Error
{
fn
from
(
err
:
std
::
string
::
FromUtf8Error
)
->
Error
{
let
msg
=
format!
(
"From Utf8 error {}"
,
err
);
Error
{
code
:
StatusCode
::
BAD_REQUEST
,
msg
,
}
}
}
This diff is collapsed.
Click to expand it.
src/services_api.rs
+
8
-
18
View file @
498c5b03
...
...
@@ -139,13 +139,12 @@ pub fn run_indexers(
pub
fn
run_services
(
conn
:
&
Connection
,
payload
:
RunService
)
->
Result
<
String
>
{
info!
(
"Trying to run service on item {}"
,
payload
.uid
);
let
result
=
internal_api
::
get_item
(
conn
.deref
(),
payload
.uid
)
?
;
if
result
.first
()
.is_none
()
{
return
Err
(
Error
{
code
:
StatusCode
::
BAD_REQUEST
,
msg
:
format!
(
"Failed to get item {}"
,
payload
.uid
),
});
};
let
item
=
internal_api
::
get_item
(
conn
.deref
(),
payload
.uid
)
?
;
let
item
=
item
.into_iter
()
.next
()
.ok_or_else
(||
Error
{
code
:
StatusCode
::
BAD_REQUEST
,
msg
:
format!
(
"Failed to get item {}"
,
payload
.uid
),
})
?
;
let
item
:
RunIntegratorItem
=
serde_json
::
from_value
(
item
)
?
;
let
mut
args
:
Vec
<
String
>
=
Vec
::
new
();
args
.push
(
"run"
.to_string
());
args
.push
(
"--rm"
.to_string
());
...
...
@@ -153,18 +152,9 @@ pub fn run_services(conn: &Connection, payload: RunService) -> Result<String> {
"--env=POD_SERVICE_PAYLOAD={}"
,
payload
.service_payload
.to_string
()
));
let
service
=
result
.first
()
.expect
(
"Failed to get value"
)
.as_object
()
.expect
(
"Failed to get map"
)
.get
(
"repository"
)
.expect
(
"Failed to get service"
)
.as_str
()
.expect
(
"Failed to get string"
);
args
.push
(
format!
(
"--name={}_1"
,
service
));
args
.push
(
"--name=memri_service_1"
.to_string
());
args
.push
(
"--network=host"
.to_string
());
args
.push
(
format!
(
"{}:latest"
,
service
)
);
args
.push
(
item
.repository
);
log
::
debug!
(
"Starting service docker command {:?}"
,
args
);
let
output
=
Command
::
new
(
"docker"
)
.args
(
&
args
)
.output
()
?
;
if
output
.status
.success
()
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Explore
Projects
Groups
Snippets