Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
orchestra
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
9
Issues
9
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PERE Alexandre
orchestra
Commits
4b839330
Commit
4b839330
authored
Dec 17, 2019
by
PERE Alexandre
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '33-parametric-profiles-2' into 'develop'
Resolve "Parametric profiles" See merge request
!22
parents
c78b6b2d
bb772754
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
12 deletions
+28
-12
liborchestra/src/lib/hosts/mod.rs
liborchestra/src/lib/hosts/mod.rs
+11
-6
runaway-cli/src/misc.rs
runaway-cli/src/misc.rs
+5
-3
runaway-cli/src/subcommands/batch.rs
runaway-cli/src/subcommands/batch.rs
+1
-1
runaway-cli/src/subcommands/exec.rs
runaway-cli/src/subcommands/exec.rs
+10
-1
runaway-cli/src/subcommands/sched.rs
runaway-cli/src/subcommands/sched.rs
+1
-1
No files found.
liborchestra/src/lib/hosts/mod.rs
View file @
4b839330
...
@@ -338,7 +338,7 @@ struct Host {
...
@@ -338,7 +338,7 @@ struct Host {
impl
Host
{
impl
Host
{
// Builds a host from a configuration.
// Builds a host from a configuration.
#[instrument(name=
"Host::from_conf"
)]
#[instrument(name=
"Host::from_conf"
)]
fn
from_conf
(
conf
:
HostConf
)
->
Result
<
Host
,
Error
>
{
fn
from_conf
(
conf
:
HostConf
,
context
:
FrontendContext
)
->
Result
<
Host
,
Error
>
{
trace!
(
"Loading from conf"
);
trace!
(
"Loading from conf"
);
// We retrieve the ssh profile from the configuration
// We retrieve the ssh profile from the configuration
let
profile
=
ssh
::
config
::
get_profile
(
let
profile
=
ssh
::
config
::
get_profile
(
...
@@ -351,7 +351,7 @@ impl Host {
...
@@ -351,7 +351,7 @@ impl Host {
trace!
(
?
conn
,
"Connection to frontend acquired"
);
trace!
(
?
conn
,
"Connection to frontend acquired"
);
// We generate the host
// We generate the host
let
mut
context
=
FrontendContext
(
TerminalContext
::
default
())
;
let
mut
context
=
context
;
context
.0
.envs
.insert
(
EnvironmentKey
(
"RUNAWAY_PATH"
.into
()),
context
.0
.envs
.insert
(
EnvironmentKey
(
"RUNAWAY_PATH"
.into
()),
EnvironmentValue
(
conf
.directory
.to_str
()
.unwrap
()
.into
()));
EnvironmentValue
(
conf
.directory
.to_str
()
.unwrap
()
.into
()));
Ok
(
Host
{
Ok
(
Host
{
...
@@ -542,8 +542,8 @@ pub struct HostHandle {
...
@@ -542,8 +542,8 @@ pub struct HostHandle {
impl
HostHandle
{
impl
HostHandle
{
/// This function spawns the thread that will handle all the repository operations using the
/// This function spawns the thread that will handle all the repository operations using the
/// CampaignResource, and returns a handle to it.
/// CampaignResource, and returns a handle to it.
pub
fn
spawn
(
host_conf
:
HostConf
)
->
Result
<
HostHandle
,
Error
>
{
pub
fn
spawn
(
host_conf
:
HostConf
,
context
:
TerminalContext
<
PathBuf
>
)
->
Result
<
HostHandle
,
Error
>
{
let
host
=
Host
::
from_conf
(
host_conf
.clone
())
?
;
let
host
=
Host
::
from_conf
(
host_conf
.clone
()
,
FrontendContext
(
context
)
)
?
;
let
conn
=
host
.conn
.clone
();
let
conn
=
host
.conn
.clone
();
let
(
sender
,
receiver
)
=
mpsc
::
unbounded
();
let
(
sender
,
receiver
)
=
mpsc
::
unbounded
();
let
handle
=
thread
::
Builder
::
new
()
.name
(
"host"
.into
())
let
handle
=
thread
::
Builder
::
new
()
.name
(
"host"
.into
())
...
@@ -990,8 +990,10 @@ mod test {
...
@@ -990,8 +990,10 @@ mod test {
execution
:
vec!
[
"$RUNAWAY_COMMAND"
.to_owned
()],
execution
:
vec!
[
"$RUNAWAY_COMMAND"
.to_owned
()],
directory
:
path
::
PathBuf
::
from
(
"/projets/flowers/alex/executions"
),
directory
:
path
::
PathBuf
::
from
(
"/projets/flowers/alex/executions"
),
};
};
let
res_handle
=
HostHandle
::
spawn
(
conf
)
.unwrap
();
let
context
=
TerminalContext
::
default
();
let
res_handle
=
HostHandle
::
spawn
(
conf
,
context
)
.unwrap
();
// We test environment of first connection
// We test environment of first connection
let
conn1
=
{
let
conn1
=
{
...
@@ -1080,7 +1082,10 @@ mod test {
...
@@ -1080,7 +1082,10 @@ mod test {
directory
:
path
::
PathBuf
::
from
(
"/projets/flowers/alex/executions"
),
directory
:
path
::
PathBuf
::
from
(
"/projets/flowers/alex/executions"
),
};
};
let
res_handle
=
HostHandle
::
spawn
(
conf
)
.unwrap
();
let
context
=
TerminalContext
::
default
();
let
res_handle
=
HostHandle
::
spawn
(
conf
,
context
)
.unwrap
();
async
fn
test
(
res
:
HostHandle
)
{
async
fn
test
(
res
:
HostHandle
)
{
let
conn
=
res
.async_acquire
()
.await
.unwrap
();
let
conn
=
res
.async_acquire
()
.await
.unwrap
();
...
...
runaway-cli/src/misc.rs
View file @
4b839330
...
@@ -18,7 +18,7 @@ use clap;
...
@@ -18,7 +18,7 @@ use clap;
use
crate
::
exit
::
Exit
;
use
crate
::
exit
::
Exit
;
use
crate
::
logger
::
EchoSubscriber
;
use
crate
::
logger
::
EchoSubscriber
;
use
liborchestra
::
primitives
::{
read_globs_from_file
,
list_local_folder
,
Glob
};
use
liborchestra
::
primitives
::{
read_globs_from_file
,
list_local_folder
,
Glob
};
use
liborchestra
::
commons
::{
EnvironmentStore
,
EnvironmentKey
,
EnvironmentValue
};
use
liborchestra
::
commons
::{
EnvironmentStore
,
EnvironmentKey
,
EnvironmentValue
,
TerminalContext
};
use
liborchestra
::
scheduler
::
SchedulerHandle
;
use
liborchestra
::
scheduler
::
SchedulerHandle
;
use
itertools
::
Itertools
;
use
itertools
::
Itertools
;
use
tracing
::{
self
,
info
,
error
};
use
tracing
::{
self
,
info
,
error
};
...
@@ -96,10 +96,12 @@ macro_rules! try_return_err {
...
@@ -96,10 +96,12 @@ macro_rules! try_return_err {
/// Allows to load host from a host path configuration
/// Allows to load host from a host path configuration
pub
fn
get_host
(
host_name
:
&
str
)
->
Result
<
HostHandle
,
Exit
>
{
pub
fn
get_host
(
host_name
:
&
str
,
envs
:
EnvironmentStore
)
->
Result
<
HostHandle
,
Exit
>
{
let
host_path
=
get_host_path
(
host_name
);
let
host_path
=
get_host_path
(
host_name
);
let
mut
context
=
TerminalContext
::
default
();
context
.envs
=
envs
;
let
config
=
to_exit!
(
HostConf
::
from_file
(
&
host_path
),
Exit
::
LoadHostConfiguration
)
?
;
let
config
=
to_exit!
(
HostConf
::
from_file
(
&
host_path
),
Exit
::
LoadHostConfiguration
)
?
;
to_exit!
(
HostHandle
::
spawn
(
config
),
Exit
::
SpawnHost
)
to_exit!
(
HostHandle
::
spawn
(
config
,
context
),
Exit
::
SpawnHost
)
}
}
/// Allows to generate globs from send and fetch ignore file.
/// Allows to generate globs from send and fetch ignore file.
...
...
runaway-cli/src/subcommands/batch.rs
View file @
4b839330
...
@@ -58,7 +58,7 @@ pub fn batch(matches: clap::ArgMatches<'static>) -> Result<Exit, Exit>{
...
@@ -58,7 +58,7 @@ pub fn batch(matches: clap::ArgMatches<'static>) -> Result<Exit, Exit>{
// We load the host
// We load the host
info!
(
"Loading host"
);
info!
(
"Loading host"
);
let
host
=
misc
::
get_host
(
matches
.value_of
(
"REMOTE"
)
.unwrap
())
?
;
let
host
=
misc
::
get_host
(
matches
.value_of
(
"REMOTE"
)
.unwrap
()
,
store
.clone
()
)
?
;
push_env
(
&
mut
store
,
"RUNAWAY_REMOTE"
,
host
.get_name
());
push_env
(
&
mut
store
,
"RUNAWAY_REMOTE"
,
host
.get_name
());
debug!
(
"Host {} loaded"
,
host
);
debug!
(
"Host {} loaded"
,
host
);
...
...
runaway-cli/src/subcommands/exec.rs
View file @
4b839330
...
@@ -38,9 +38,18 @@ pub fn exec(matches: clap::ArgMatches) -> Result<Exit, Exit>{
...
@@ -38,9 +38,18 @@ pub fn exec(matches: clap::ArgMatches) -> Result<Exit, Exit>{
// We create the store that will keep env vars
// We create the store that will keep env vars
let
mut
store
=
EnvironmentStore
::
new
();
let
mut
store
=
EnvironmentStore
::
new
();
// We read the envs to the store.
if
!
matches
.is_present
(
"no-env-read"
){
let
envs
=
misc
::
read_local_runaway_envs
();
debug!
(
"Local environment variables captured: {}"
,
envs
.iter
()
.fold
(
String
::
new
(),
|
mut
acc
,
(
k
,
v
)|
{
acc
.push_str
(
&
format!
(
"
\n
{:?}={:?}"
,
k
,
v
));
acc
}));
envs
.into_iter
()
.for_each
(|(
k
,
v
)|
{
push_env
(
&
mut
store
,
k
.0
,
v
.0
);});
}
// We load the host
// We load the host
info!
(
"Loading host"
);
info!
(
"Loading host"
);
let
host
=
misc
::
get_host
(
matches
.value_of
(
"REMOTE"
)
.unwrap
())
?
;
let
host
=
misc
::
get_host
(
matches
.value_of
(
"REMOTE"
)
.unwrap
()
,
store
.clone
()
)
?
;
push_env
(
&
mut
store
,
"RUNAWAY_REMOTE"
,
host
.get_name
());
push_env
(
&
mut
store
,
"RUNAWAY_REMOTE"
,
host
.get_name
());
debug!
(
"Host {:?} loaded"
,
host
);
debug!
(
"Host {:?} loaded"
,
host
);
...
...
runaway-cli/src/subcommands/sched.rs
View file @
4b839330
...
@@ -58,7 +58,7 @@ pub fn sched(matches: clap::ArgMatches<'static>) -> Result<Exit, Exit>{
...
@@ -58,7 +58,7 @@ pub fn sched(matches: clap::ArgMatches<'static>) -> Result<Exit, Exit>{
// We load the host
// We load the host
info!
(
"Loading host"
);
info!
(
"Loading host"
);
let
host
=
misc
::
get_host
(
matches
.value_of
(
"REMOTE"
)
.unwrap
())
?
;
let
host
=
misc
::
get_host
(
matches
.value_of
(
"REMOTE"
)
.unwrap
()
,
store
.clone
()
)
?
;
push_env
(
&
mut
store
,
"RUNAWAY_REMOTE"
,
host
.get_name
());
push_env
(
&
mut
store
,
"RUNAWAY_REMOTE"
,
host
.get_name
());
debug!
(
"Host {} loaded"
,
host
);
debug!
(
"Host {} loaded"
,
host
);
...
...
Write
Preview
Markdown
is supported
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