diff --git a/Cargo.lock b/Cargo.lock index 28d915c7..839957e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -668,6 +668,15 @@ dependencies = [ "webbrowser", ] +[[package]] +name = "coco_container" +version = "0.1.0" +dependencies = [ + "core_model", + "dockerfile-parser", + "plugin_interface", +] + [[package]] name = "coco_coverage" version = "0.1.0" @@ -1060,6 +1069,20 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "dockerfile-parser" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "035af81ab6049105146852b76e753e80325e6e7699ad34deb678e3ddd011ddce" +dependencies = [ + "enquote", + "lazy_static", + "pest", + "pest_derive", + "regex", + "snafu", +] + [[package]] name = "dtoa" version = "0.4.7" @@ -1103,6 +1126,12 @@ dependencies = [ "encoding_rs", ] +[[package]] +name = "enquote" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ec878a5d2f3b6e9eaee72373dd23414cfc7d353104741471bec712ef241a66e" + [[package]] name = "enum-as-inner" version = "0.3.3" @@ -2931,6 +2960,27 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +[[package]] +name = "snafu" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eab12d3c261b2308b0d80c26fffb58d17eba81a4be97890101f416b478c79ca7" +dependencies = [ + "doc-comment", + "snafu-derive", +] + +[[package]] +name = "snafu-derive" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1508efa03c362e23817f96cde18abed596a25219a8b2c66e8db33c03543d315b" +dependencies = [ + "proc-macro2 1.0.24", + "quote 1.0.8", + "syn 1.0.58", +] + [[package]] name = "socket2" version = "0.3.19" diff --git a/Cargo.toml b/Cargo.toml index 4a2dedab..69948770 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,6 +106,7 @@ members = [ 'plugins/coco_struct_analysis', 'plugins/coco_coverage', 'plugins/coco_pipeline', + 'plugins/coco_container', 'psa', ] diff --git a/plugins/coco_container/Cargo.toml b/plugins/coco_container/Cargo.toml new file mode 100644 index 00000000..7a7e0ae8 --- /dev/null +++ b/plugins/coco_container/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "coco_container" +version = "0.1.0" +authors = ["Phodal Huang "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +dockerfile-parser = "0.7.1" + +[dependencies.core_model] +path = "../../core_model" + +[dependencies.plugin_interface] +path = "../../plugin_interface" + +[lib] +name = "coco_container" +crate-type = ["cdylib"] diff --git a/plugins/coco_container/src/lib.rs b/plugins/coco_container/src/lib.rs new file mode 100644 index 00000000..f1f94206 --- /dev/null +++ b/plugins/coco_container/src/lib.rs @@ -0,0 +1,29 @@ +fn main() { + println!("Hello, world!"); +} + +#[cfg(test)] +mod tests { + use dockerfile_parser::Dockerfile; + + #[test] + pub fn demo() { + let dockerfile = Dockerfile::parse( + r#" + FROM alpine:3.11 as builder + RUN echo "hello world" > /hello-world + + FROM scratch + COPY --from=builder /hello-world /hello-world +"#, + ) + .unwrap(); + + for stage in dockerfile.iter_stages() { + println!("stage #{}", stage.index); + for ins in stage.instructions { + println!(" {:?}", ins); + } + } + } +}