parent
50ab1a5b14
commit
4888aa9ecf
|
@ -139,11 +139,11 @@ will be executed in the order that they are defined.
|
|||
.simple.zplan
|
||||
[source]
|
||||
----
|
||||
task 'tasks/echo.ztask' {
|
||||
task 'tasks/echo' {
|
||||
msg = 'Hello from the wonderful world of zplans!'
|
||||
}
|
||||
|
||||
task 'tasks/echo.ztask' {
|
||||
task 'tasks/echo' {
|
||||
msg = 'This is nice'
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ use std::path::PathBuf;
|
|||
|
||||
use zap_model::inventory::Inventory;
|
||||
use zap_model::transport::ssh::Ssh;
|
||||
use zap_model::{Plan, Task, Transport};
|
||||
use zap_model::ExecutableTask;
|
||||
use zap_model::{Plan, Task, Transport};
|
||||
|
||||
fn main() {
|
||||
pretty_env_logger::init();
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
* It is expected to be run from the root of the project tree.
|
||||
*/
|
||||
|
||||
task 'tasks/echo.ztask' {
|
||||
task 'tasks/echo' {
|
||||
msg = 'Hello from the wonderful world of zplans!'
|
||||
}
|
||||
|
||||
task 'tasks/echo.ztask' {
|
||||
task 'tasks/echo' {
|
||||
msg = 'This is nice'
|
||||
}
|
||||
|
||||
task 'tasks/shell/bash.ztask' {
|
||||
task 'tasks/shell/bash' {
|
||||
script = '''
|
||||
ls -lah
|
||||
ls
|
||||
touch foo
|
||||
'''
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ pub mod task;
|
|||
pub mod tasks;
|
||||
pub mod transport;
|
||||
|
||||
pub use crate::transport::Transport;
|
||||
pub use crate::plan::Plan;
|
||||
pub use crate::task::Task;
|
||||
pub use crate::transport::Transport;
|
||||
|
||||
/**
|
||||
* An ExecutableTask is a light container over a Task execpt with user-provided information and is
|
||||
|
|
|
@ -35,7 +35,9 @@ impl Plan {
|
|||
for pair in parsed.into_inner() {
|
||||
match pair.as_rule() {
|
||||
Rule::string => {
|
||||
let path = PathBuf::from(parse_str(&mut pair.into_inner())?);
|
||||
let name = parse_str(&mut pair.into_inner())?;
|
||||
// The .ztask extension is to be omitted in task declarations
|
||||
let path = PathBuf::from(format!("{}.ztask", name));
|
||||
|
||||
match crate::task::Task::from_path(&path) {
|
||||
Ok(task) => raw_task = Some(task),
|
||||
|
@ -164,11 +166,11 @@ mod tests {
|
|||
* It is expected to be run from the root of the project tree.
|
||||
*/
|
||||
|
||||
task '../tasks/echo.ztask' {
|
||||
task '../tasks/echo' {
|
||||
msg = 'Hello from the wonderful world of zplans!'
|
||||
}
|
||||
|
||||
task '../tasks/echo.ztask' {
|
||||
task '../tasks/echo' {
|
||||
msg = 'This can actually take inline shells too: $(date)'
|
||||
}"#;
|
||||
let _plan = PlanParser::parse(Rule::planfile, buf)
|
||||
|
@ -179,11 +181,11 @@ task '../tasks/echo.ztask' {
|
|||
|
||||
#[test]
|
||||
fn parse_plan_fn() {
|
||||
let buf = r#"task '../tasks/echo.ztask' {
|
||||
let buf = r#"task '../tasks/echo' {
|
||||
msg = 'Hello from the wonderful world of zplans!'
|
||||
}
|
||||
|
||||
task '../tasks/echo.ztask' {
|
||||
task '../tasks/echo' {
|
||||
msg = 'This can actually take inline shells too: $(date)'
|
||||
}"#;
|
||||
let plan = Plan::from_str(buf).expect("Failed to parse the plan");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::ExecutableTask;
|
||||
use crate::inventory::{Group, Inventory, Target};
|
||||
use crate::ExecutableTask;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
|
|
Loading…
Reference in New Issue