diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..d67b66e --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +target = "x86_64-unknown-linux-musl" diff --git a/Cargo.lock b/Cargo.lock index f914c26..e3edf39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +dependencies = [ + "memchr", +] + [[package]] name = "atty" version = "0.2.14" @@ -25,11 +34,17 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "clap" -version = "4.0.18" +version = "4.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335867764ed2de42325fafe6d18b8af74ba97ee0c590fa016f157535b42ab04b" +checksum = "2148adefda54e14492fb9bddcc600b4344c5d1a3123bd666dcb939c6f0e0e57e" dependencies = [ "atty", "bitflags", @@ -42,9 +57,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.0.18" +version = "4.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a1b0f6422af32d5da0c58e2703320f379216ee70198241c84173a8c5ac28f3" +checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" dependencies = [ "heck", "proc-macro-error", @@ -62,6 +77,19 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "env_logger" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -83,6 +111,12 @@ dependencies = [ "libc", ] +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "indexmap" version = "1.9.1" @@ -101,9 +135,11 @@ checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "kree" -version = "0.4.0" +version = "0.7.0" dependencies = [ "clap", + "env_logger", + "log", "relative-path", "serde", "serde_json", @@ -116,17 +152,32 @@ version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + [[package]] name = "once_cell" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "os_str_bytes" -version = "6.3.0" +version = "6.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" +checksum = "7b5bf27447411e9ee3ff51186bf7a08e16c341efdde93f4d823e8844429bed7e" [[package]] name = "proc-macro-error" @@ -170,6 +221,23 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "regex" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + [[package]] name = "relative-path" version = "1.7.2" diff --git a/Cargo.toml b/Cargo.toml index 1369f33..4fd0fe3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,14 @@ [package] name = "kree" -version = "0.6.0" +version = "0.7.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] clap = { version = "4.0", features = ["derive"] } +env_logger = "0.9.3" +log = "0.4.17" relative-path = "1.7.2" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.87" diff --git a/src/main.rs b/src/main.rs index b984c3d..af1f5bc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ use std::{ io, path::PathBuf, }; +use log::debug; #[derive(Parser)] @@ -31,10 +32,19 @@ enum Format { } -#[derive(Deserialize, PartialEq, Debug)] +#[derive(Default, Deserialize, PartialEq, Debug)] +#[serde(default, rename_all = "camelCase")] struct Kustomization { - #[serde(default)] resources: Vec, + config_map_generator: Vec, +} + + +#[derive(Clone, Default, Deserialize, PartialEq, Debug)] +#[serde(default)] +struct ConfigMapGenerator { + name: String, + files: Vec, } @@ -91,11 +101,33 @@ fn unsupported(resource: &str) -> bool { } fn run(path: PathBuf, result: &mut Vec) { + debug!("{:#?}", path.display()); + let current_path = normalize(path.clone()); + debug!("{:#?}", current_path.display()); result.push(format!("{}", current_path.display())); - let resources: Vec = deserialize(¤t_path) + let doc = deserialize(¤t_path); + debug!("{:#?}", doc); + + doc + .iter() + .map(|doc| doc.config_map_generator.clone()) + .flatten() + .map(|c| c.files) + .flatten() + .for_each(|f| { + let file = current_path + .parent() + .unwrap() + .join(f); + + result.push(format!("{}", file.display())); + }); + + + let resources: Vec = doc .iter() .map(|doc| doc.resources.clone()) .flatten() @@ -117,6 +149,8 @@ fn run(path: PathBuf, result: &mut Vec) { fn main() { + env_logger::init(); + let args = Args::parse(); let root = current_dir().unwrap(); let mut result = Vec::new();