Compare commits
3 Commits
64fef7a55e
...
f7c845e374
Author | SHA1 | Date |
---|---|---|
R Tyler Croy | f7c845e374 | |
R Tyler Croy | 8404b6fca2 | |
R Tyler Croy | 025dac1673 |
|
@ -251,16 +251,16 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "async-std"
|
||||
version = "1.6.5"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9fa76751505e8df1c7a77762f60486f60c71bbd9b8557f4da6ad47d083732ed"
|
||||
checksum = "a7e82538bc65a25dbdff70e4c5439d52f068048ab97cdea0acd73f131594caa1"
|
||||
dependencies = [
|
||||
"async-attributes",
|
||||
"async-global-executor",
|
||||
"async-io",
|
||||
"async-mutex",
|
||||
"blocking",
|
||||
"crossbeam-utils",
|
||||
"crossbeam-utils 0.8.0",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
|
@ -592,7 +592,7 @@ version = "0.4.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
"crossbeam-utils 0.7.2",
|
||||
"maybe-uninit",
|
||||
]
|
||||
|
||||
|
@ -603,7 +603,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"crossbeam-utils",
|
||||
"crossbeam-utils 0.7.2",
|
||||
"maybe-uninit",
|
||||
]
|
||||
|
||||
|
@ -618,6 +618,18 @@ dependencies = [
|
|||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if 1.0.0",
|
||||
"const_fn",
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-mac"
|
||||
version = "0.8.0"
|
||||
|
@ -1118,7 +1130,7 @@ checksum = "ac245314704d62c121785203fb4d6f41f137167fcc91beec0b55bd6c4bb8c800"
|
|||
dependencies = [
|
||||
"bytes",
|
||||
"crossbeam-channel",
|
||||
"crossbeam-utils",
|
||||
"crossbeam-utils 0.7.2",
|
||||
"curl",
|
||||
"curl-sys",
|
||||
"futures-channel",
|
||||
|
@ -1493,12 +1505,14 @@ dependencies = [
|
|||
name = "otto-parser"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"log",
|
||||
"otto-models",
|
||||
"pest",
|
||||
"pest_derive",
|
||||
"pretty_env_logger 0.4.0",
|
||||
"serde_yaml",
|
||||
"tide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -4,11 +4,11 @@ members = [
|
|||
"agent",
|
||||
"models",
|
||||
"osp",
|
||||
"parser",
|
||||
|
||||
"services/auctioneer",
|
||||
"services/eventbus",
|
||||
"services/object-store",
|
||||
"services/parser",
|
||||
|
||||
"stdlib/archive",
|
||||
"stdlib/dir",
|
||||
|
|
|
@ -13,7 +13,7 @@ name = "otto-agent"
|
|||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
async-std = { version = "1.6.5", features = ["attributes"]}
|
||||
async-std = { version = "~1.7", features = ["attributes"]}
|
||||
log = "~0.4.8"
|
||||
otto-models = { path = "../models" }
|
||||
osp = { path = "../osp" }
|
||||
|
|
|
@ -2,7 +2,6 @@ use async_std::sync::Receiver;
|
|||
use log::*;
|
||||
use otto_models::*;
|
||||
use serde::Serialize;
|
||||
use serde_yaml::Value;
|
||||
use std::collections::HashMap;
|
||||
use std::fs::File;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
|
|
@ -39,7 +39,7 @@ async fn main() -> std::io::Result<()> {
|
|||
control::run(sender).await.expect("Failed to bind control?");
|
||||
});
|
||||
|
||||
run(&steps_dir, &invoke, Some(receiver));
|
||||
run(&steps_dir, &invoke, Some(receiver)).expect("Failed to run pipeline");
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
|
|
|
@ -19,5 +19,9 @@ This document captures some details around developing these Otto services.
|
|||
| Object Store
|
||||
| Service to put objects such as logs and artifacts
|
||||
|
||||
| 7672
|
||||
| Parser
|
||||
| Service which parses .otto files and spits out the Otto intermediate execution format.
|
||||
|
||||
|===
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ impl Manifest {
|
|||
false => &include.name,
|
||||
}
|
||||
);
|
||||
tar.append_file(archive_path, &mut f);
|
||||
tar.append_file(&archive_path, &mut f)
|
||||
.expect(&format!("Failed to append file: {}", &archive_path));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -9,6 +9,4 @@ fn main() {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
}
|
||||
mod tests {}
|
||||
|
|
|
@ -159,6 +159,4 @@ pub mod server {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
}
|
||||
mod tests {}
|
||||
|
|
|
@ -14,7 +14,7 @@ path = "src/main.rs"
|
|||
|
||||
|
||||
[dependencies]
|
||||
async-std = { version = "~1.6.5", features = ["attributes"]}
|
||||
async-std = { version = "~1.7", features = ["attributes"]}
|
||||
log = "~0.4.11"
|
||||
pretty_env_logger = "~0.4.0"
|
||||
tide = "~0.14.0"
|
||||
|
|
|
@ -4,10 +4,20 @@ version = "0.1.0"
|
|||
authors = ["R. Tyler Croy <rtyler@brokenco.de>"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
name = "otto_parser"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "otto-parser"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
async-std = { version = "1.6.5", features = ["attributes"]}
|
||||
log = "~0.4.11"
|
||||
otto-models = { path = "../models" }
|
||||
otto-models = { path = "../../models" }
|
||||
pest = "~2.1.3"
|
||||
pest_derive = "~2.1.0"
|
||||
pretty_env_logger = "~0.4.0"
|
||||
serde_yaml = "~0.8.13"
|
||||
tide = "~0.14.0"
|
|
@ -11,6 +11,36 @@ use pest::Parser;
|
|||
#[grammar = "pipeline.pest"]
|
||||
struct PipelineParser;
|
||||
|
||||
/**
|
||||
* This function will attempt to fully parse the buffer as if it were a complete
|
||||
* pipeline file.
|
||||
*/
|
||||
pub fn parse_pipeline_string(buffer: &str) -> Result<Pipeline, pest::error::Error<Rule>> {
|
||||
let mut parser = PipelineParser::parse(Rule::pipeline, buffer)?;
|
||||
let mut pipeline = Pipeline::default();
|
||||
|
||||
while let Some(parsed) = parser.next() {
|
||||
match parsed.as_rule() {
|
||||
Rule::stages => {
|
||||
let mut stages = parsed.into_inner();
|
||||
while let Some(parsed) = stages.next() {
|
||||
match parsed.as_rule() {
|
||||
Rule::stage => {
|
||||
let (ctx, mut steps) = parse_stage(&mut parsed.into_inner());
|
||||
pipeline.contexts.push(ctx);
|
||||
pipeline.steps.append(&mut steps);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(pipeline)
|
||||
}
|
||||
|
||||
fn parse_str(parser: &mut pest::iterators::Pair<Rule>) -> String {
|
||||
// TODO: There's got to be a better way than cloning
|
||||
let mut parser = parser.clone().into_inner();
|
||||
|
@ -80,39 +110,13 @@ fn parse_stage(parser: &mut Pairs<Rule>) -> (Context, Vec<Step>) {
|
|||
(stage, steps)
|
||||
}
|
||||
|
||||
pub fn parse_pipeline_string(buffer: &str) -> Result<Pipeline, pest::error::Error<Rule>> {
|
||||
let mut parser = PipelineParser::parse(Rule::pipeline, buffer)?;
|
||||
let mut pipeline = Pipeline::default();
|
||||
|
||||
while let Some(parsed) = parser.next() {
|
||||
match parsed.as_rule() {
|
||||
Rule::stages => {
|
||||
let mut stages = parsed.into_inner();
|
||||
while let Some(parsed) = stages.next() {
|
||||
match parsed.as_rule() {
|
||||
Rule::stage => {
|
||||
let (ctx, mut steps) = parse_stage(&mut parsed.into_inner());
|
||||
pipeline.contexts.push(ctx);
|
||||
pipeline.steps.append(&mut steps);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(pipeline)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn parse_steps() {
|
||||
let steps = PipelineParser::parse(
|
||||
let _steps = PipelineParser::parse(
|
||||
Rule::steps,
|
||||
r#"steps {
|
||||
sh 'ls'
|
||||
|
@ -126,7 +130,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn parse_steps_positional_args() {
|
||||
let steps = PipelineParser::parse(
|
||||
let _steps = PipelineParser::parse(
|
||||
Rule::steps,
|
||||
r#"steps {
|
||||
sh 'ls', 'utf-8', 'lolwut'
|
||||
|
@ -140,7 +144,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn parse_steps_keyword_arg() {
|
||||
let steps = PipelineParser::parse(
|
||||
let _steps = PipelineParser::parse(
|
||||
Rule::steps,
|
||||
r#"steps {
|
||||
sh script: 'ls'
|
||||
|
@ -154,7 +158,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn parse_steps_keyword_args() {
|
||||
let steps = PipelineParser::parse(
|
||||
let _steps = PipelineParser::parse(
|
||||
Rule::steps,
|
||||
r#"steps {
|
||||
sh script: 'ls', label: 'lolwut'
|
||||
|
@ -168,7 +172,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let pipeline = PipelineParser::parse(
|
||||
let _pipeline = PipelineParser::parse(
|
||||
Rule::pipeline,
|
||||
r#"
|
||||
pipeline {
|
||||
|
@ -219,7 +223,6 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn parse_more_pipeline() {
|
||||
use otto_models::*;
|
||||
let buf = r#"
|
||||
pipeline {
|
||||
stages {
|
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* THe parser web service basically just takes in pipeline syntax and spits out the machine
|
||||
* readable (YAML) structures which other components in Otto can use.
|
||||
*/
|
||||
|
||||
#[async_std::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Ok(())
|
||||
}
|
|
@ -5,7 +5,7 @@ authors = ["R. Tyler Croy <rtyler@brokenco.de>"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
async-std = { version = "~1.6.5", features = ["attributes"] }
|
||||
async-std = { version = "~1.7", features = ["attributes"] }
|
||||
flate2 = "~1.0.18"
|
||||
glob = "~0.3.0"
|
||||
otto-agent = { path = "../../agent" }
|
||||
|
|
|
@ -145,7 +145,8 @@ async fn main() -> std::io::Result<()> {
|
|||
}
|
||||
|
||||
if file.is_dir() {
|
||||
create_tarball(&name, &artifacts);
|
||||
create_tarball(&name, &artifacts)
|
||||
.expect("Failed to create tarball for artifact(s)");
|
||||
} else {
|
||||
archive(file, &endpoint).await?;
|
||||
}
|
||||
|
@ -157,8 +158,8 @@ async fn main() -> std::io::Result<()> {
|
|||
};
|
||||
|
||||
match create_tarball(&name, &artifacts) {
|
||||
Err(_e) => {
|
||||
// TODO handle
|
||||
Err(e) => {
|
||||
panic!("Failed to create tarball for artifacts! {:#?}", e);
|
||||
}
|
||||
Ok(file) => {
|
||||
archive(&file, &endpoint).await?;
|
||||
|
|
|
@ -5,7 +5,7 @@ authors = ["R. Tyler Croy <rtyler@brokenco.de>"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
async-std = { version = "~1.6.5", features = ["attributes"] }
|
||||
async-std = { version = "~1.7", features = ["attributes"] }
|
||||
otto-agent = { path = "../../agent" }
|
||||
serde = {version = "~1.0.117", features = ["derive"]}
|
||||
surf = { version = "~2.1.0", features = ["h1-client"]}
|
||||
|
|
Loading…
Reference in New Issue