From 85cc1d46db69112b66bf58fee80867a5a285c5ec Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sun, 28 Jan 2024 16:41:50 +0100 Subject: [PATCH] feat: make sure dir is there as well Signed-off-by: kjuulh --- Cargo.lock | 741 +++++++++--------- ci/src/main.rs | 4 +- cuddle/Cargo.toml | 9 + cuddle/src/actions/mod.rs | 182 ++++- cuddle/src/cli/mod.rs | 63 +- cuddle/src/cli/subcommands/folder.rs | 168 ++++ cuddle/src/cli/subcommands/kustomize.rs | 85 ++ cuddle/src/cli/subcommands/mod.rs | 4 + cuddle/src/cli/subcommands/render.rs | 31 + .../src/cli/subcommands/render_kustomize.rs | 70 ++ cuddle/src/cli/subcommands/render_template.rs | 46 +- cuddle/src/cli/subcommands/x.rs | 1 + cuddle/src/context.rs | 20 +- cuddle/src/model.rs | 165 +++- templates/build_cuddle_image.Dockerfile | 11 +- 15 files changed, 1153 insertions(+), 447 deletions(-) create mode 100644 cuddle/src/cli/subcommands/folder.rs create mode 100644 cuddle/src/cli/subcommands/kustomize.rs create mode 100644 cuddle/src/cli/subcommands/render.rs create mode 100644 cuddle/src/cli/subcommands/render_kustomize.rs diff --git a/Cargo.lock b/Cargo.lock index a67c2a8..86eae17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -52,9 +52,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.7" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" dependencies = [ "anstyle", "anstyle-parse", @@ -66,36 +66,36 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -107,6 +107,18 @@ dependencies = [ "backtrace", ] +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + [[package]] name = "ascii" version = "0.9.3" @@ -121,7 +133,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -143,9 +155,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -162,9 +174,9 @@ version = "0.1.0" [[package]] name = "base64" -version = "0.21.6" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79fed4cdb43e993fcdadc7e58a09fd0e3e649c4436fa11da71c9f1f3ee7feb9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bitflags" @@ -174,9 +186,22 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "blake3" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", +] [[package]] name = "block-buffer" @@ -199,27 +224,27 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" -version = "1.0.80" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f1226cd9da55587234753d1245dd5b132343ea240f26b6a9003d68706141ba" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", "libc", @@ -233,21 +258,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", - "winapi", + "windows-targets 0.52.0", ] [[package]] name = "chrono-tz" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1369bc6b9e9a7dfdae2055f6ec151fe9c554a9d23d357c0237cee2e25eaabb7" +checksum = "91d7b79e99bfaa0d47da0687c43aa3b7381938a62ad3a6498599039321f660b7" dependencies = [ "chrono", "chrono-tz-build", @@ -256,9 +281,9 @@ dependencies = [ [[package]] name = "chrono-tz-build" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2f5ebdc942f57ed96d560a6d1a459bae5851102a25d5bf89dc04ae453e31ecf" +checksum = "433e39f13c9a060046954e0592a8d0a4bcb1040125cbf91cb8ee58964cfb350f" dependencies = [ "parse-zoneinfo", "phf", @@ -337,22 +362,28 @@ dependencies = [ [[package]] name = "console" -version = "0.15.7" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] -name = "core-foundation" -version = "0.9.3" +name = "constant_time_eq" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -360,15 +391,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -382,6 +413,31 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + [[package]] name = "crossterm" version = "0.25.0" @@ -422,15 +478,19 @@ name = "cuddle" version = "0.2.0" dependencies = [ "anyhow", + "blake3", "clap 4.4.18", "dirs", "dotenv", "envconfig", + "fs_extra", + "futures-util", "git2", "inquire", "libz-sys", "log", "openssl", + "reqwest", "rlua", "rlua-searcher", "serde", @@ -438,6 +498,7 @@ dependencies = [ "serde_yaml", "tempfile", "tera", + "tokio", "tracing", "tracing-subscriber", "walkdir", @@ -540,9 +601,9 @@ dependencies = [ [[package]] name = "deunicode" -version = "0.4.4" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95203a6a50906215a502507c0f879a0ce7ff205a6111e2db2a5ef8e4bb92e43" +checksum = "3ae2a35373c5c74340b79ae6780b498b2b183915ec5dacf263aac5a099bf485a" [[package]] name = "digest" @@ -586,9 +647,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.12" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304e6508efa593091e97a9abbc10f90aa7ca635b6d2784feff3c89d41dd12272" +checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" [[package]] name = "either" @@ -604,9 +665,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.32" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ "cfg-if", ] @@ -659,20 +720,20 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "filetime" -version = "0.2.21" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", - "windows-sys 0.48.0", + "redox_syscall", + "windows-sys 0.52.0", ] [[package]] @@ -708,13 +769,19 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" version = "0.3.30" @@ -771,7 +838,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -816,9 +883,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -827,9 +894,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "git2" @@ -837,7 +904,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf97ba92db08df386e10c8ede66a2a0369bd277090afd8710e19e38de9ec0cd" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "libgit2-sys", "log", @@ -847,15 +914,15 @@ dependencies = [ [[package]] name = "globset" -version = "0.4.12" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aca8bbd8e0707c1887a8bbb7e6b40e228f251ff5d62c8220a4a7a53c73aff006" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", "bstr", - "fnv", "log", - "regex", + "regex-automata 0.4.5", + "regex-syntax 0.8.2", ] [[package]] @@ -930,9 +997,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" dependencies = [ "bytes", "fnv", @@ -940,7 +1007,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap", "slab", "tokio", "tokio-util", @@ -949,15 +1016,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heck" @@ -976,9 +1037,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] name = "hex" @@ -994,9 +1055,9 @@ checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] name = "http" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", @@ -1005,9 +1066,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -1022,9 +1083,9 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "humansize" @@ -1037,9 +1098,9 @@ dependencies = [ [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", @@ -1052,7 +1113,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.4.9", + "socket2", "tokio", "tower-service", "tracing", @@ -1061,9 +1122,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", @@ -1075,16 +1136,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -1104,9 +1165,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1114,17 +1175,16 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" dependencies = [ + "crossbeam-deque", "globset", - "lazy_static", "log", "memchr", - "regex", + "regex-automata 0.4.5", "same-file", - "thread_local", "walkdir", "winapi-util", ] @@ -1137,22 +1197,12 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "1.9.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - -[[package]] -name = "indexmap" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown", ] [[package]] @@ -1174,30 +1224,30 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" dependencies = [ "wasm-bindgen", ] @@ -1210,9 +1260,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libgit2-sys" @@ -1230,9 +1280,20 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.2", + "libc", + "redox_syscall", +] [[package]] name = "libssh2-sys" @@ -1262,15 +1323,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -1317,9 +1378,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "log", @@ -1348,9 +1409,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", ] @@ -1361,24 +1422,24 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi 0.3.4", "libc", ] [[package]] name = "object" -version = "0.31.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" @@ -1386,7 +1447,7 @@ version = "0.10.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if", "foreign-types", "libc", @@ -1403,14 +1464,14 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] name = "openssl-src" -version = "300.1.6+3.1.4" +version = "300.2.1+3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439fac53e092cd7442a3660c85dde4643ab3b5bd39040912388dcdabf6b88085" +checksum = "3fe476c29791a5ca0d1273c697e96085bbabbbea2ef7afd5617e78a4b40332d3" dependencies = [ "cc", ] @@ -1452,15 +1513,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall", "smallvec", - "windows-targets 0.48.1", + "windows-targets 0.48.5", ] [[package]] @@ -1474,25 +1535,26 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.2" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1acb4a4365a13f749a93f1a094a7805e5cfa0955373a9de860d962eaa3a5fe5a" +checksum = "1f200d8d83c44a45b21764d1916299752ca035d15ecd46faca3e9a2a2bf6ad06" dependencies = [ + "memchr", "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.7.2" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "666d00490d4ac815001da55838c500eafb0320019bbaa44444137c48b443a853" +checksum = "bcd6ab1236bbdb3a49027e920e693192ebfe8913f6d60e294de57463a493cfde" dependencies = [ "pest", "pest_generator", @@ -1500,22 +1562,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.2" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ca01446f50dbda87c1786af8770d535423fa8a53aec03b8f4e3d7eb10e0929" +checksum = "2a31940305ffc96863a735bef7c7994a00b325a7138fdbc5bda0f1a0476d3275" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] name = "pest_meta" -version = "2.7.2" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56af0a30af74d0445c0bf6d9d051c979b516a1a5af790d251daee76005420a48" +checksum = "a7ff62f5259e53b78d1af898941cdcdccfae7385cf7d793a6e55de5d05bb4b7d" dependencies = [ "once_cell", "pest", @@ -1562,9 +1624,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -1574,9 +1636,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" [[package]] name = "platform-info" @@ -1596,9 +1658,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.74" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -1642,24 +1704,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -1671,25 +1715,25 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom", - "redox_syscall 0.2.16", + "libredox", "thiserror", ] [[package]] name = "regex" -version = "1.9.1" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.4", - "regex-syntax 0.7.4", + "regex-automata 0.4.5", + "regex-syntax 0.8.2", ] [[package]] @@ -1703,13 +1747,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.4", + "regex-syntax 0.8.2", ] [[package]] @@ -1720,9 +1764,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" @@ -1768,17 +1812,16 @@ dependencies = [ [[package]] name = "ring" -version = "0.16.20" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", + "getrandom", "libc", - "once_cell", "spin", "untrusted", - "web-sys", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -1787,7 +1830,7 @@ version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3120d9610f84b17da849f5cc8c089bb74299285515bb4a6114550bbc39ddb1e7" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "bstr", "libc", "num-traits", @@ -1822,11 +1865,11 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "libc", "linux-raw-sys", @@ -1835,9 +1878,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring", @@ -1847,18 +1890,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ "base64", ] [[package]] name = "rustls-webpki" -version = "0.101.2" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "513722fd73ad80a71f72b61009ea1b584bcfa1483ca93949c8f290298837fa59" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ "ring", "untrusted", @@ -1866,9 +1909,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "same-file" @@ -1887,9 +1930,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ "ring", "untrusted", @@ -1912,7 +1955,7 @@ checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -1944,7 +1987,7 @@ version = "0.9.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1bf28c79a99f70ee1f1d83d10c875d2e70618417fda01ad1785e027579d9d38" dependencies = [ - "indexmap 2.0.0", + "indexmap", "itoa", "ryu", "serde", @@ -1964,9 +2007,9 @@ dependencies = [ [[package]] name = "sharded-slab" -version = "0.1.4" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ "lazy_static", ] @@ -2003,43 +2046,34 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "slug" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" +checksum = "3bd94acec9c8da640005f8e135a39fc0372e74535e6b368b7a04b875f784c8c4" dependencies = [ "deunicode", + "wasm-bindgen", ] [[package]] name = "smallvec" -version = "1.11.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" - -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi", -] +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" @@ -2053,9 +2087,9 @@ dependencies = [ [[package]] name = "spin" -version = "0.5.2" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "strsim" @@ -2082,9 +2116,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.46" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -2131,7 +2165,7 @@ checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.4.1", + "redox_syscall", "rustix", "windows-sys 0.52.0", ] @@ -2184,15 +2218,16 @@ checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ + "cfg-if", "once_cell", ] @@ -2225,7 +2260,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.5", + "socket2", "tokio-macros", "windows-sys 0.48.0", ] @@ -2238,7 +2273,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -2253,9 +2288,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.8" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -2291,7 +2326,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -2348,15 +2383,15 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" @@ -2416,15 +2451,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -2443,9 +2478,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unreachable" @@ -2464,15 +2499,15 @@ checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" [[package]] name = "untrusted" -version = "0.7.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -2493,9 +2528,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-bag" -version = "1.4.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d92ccd67fb88503048c01b59152a04effd0782d035a83a6d256ce6085f08f4a3" +checksum = "7cdbaf5e132e593e9fc1de6a15bbec912395b11fb9719e061cf64f804524c503" [[package]] name = "vcpkg" @@ -2548,9 +2583,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2558,24 +2593,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" dependencies = [ "cfg-if", "js-sys", @@ -2585,9 +2620,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2595,22 +2630,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" [[package]] name = "wasm-streams" @@ -2627,9 +2662,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" dependencies = [ "js-sys", "wasm-bindgen", @@ -2637,9 +2672,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.2" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" [[package]] name = "winapi" @@ -2659,9 +2694,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -2673,21 +2708,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.48.1", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", + "windows-targets 0.52.0", ] [[package]] @@ -2696,7 +2722,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.1", + "windows-targets 0.48.5", ] [[package]] @@ -2710,32 +2736,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-targets" -version = "0.48.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -2755,15 +2766,9 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" @@ -2773,15 +2778,9 @@ checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" @@ -2791,15 +2790,9 @@ checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" @@ -2809,15 +2802,9 @@ checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" @@ -2827,15 +2814,9 @@ checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" @@ -2845,15 +2826,9 @@ checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" @@ -2863,15 +2838,9 @@ checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" @@ -2891,9 +2860,11 @@ dependencies = [ [[package]] name = "xattr" -version = "1.0.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4686009f71ff3e5c4dbcf1a282d0a44db3f021ba69350cd42086b3e5f1c6985" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" dependencies = [ "libc", + "linux-raw-sys", + "rustix", ] diff --git a/ci/src/main.rs b/ci/src/main.rs index 7ea505e..781b876 100644 --- a/ci/src/main.rs +++ b/ci/src/main.rs @@ -79,7 +79,7 @@ async fn dind_image( "libz-dev", ]) .with_workdir("/app/cuddle/") - .with_directory(".", src.id().await?) + .with_directory(".", src) .with_exec(vec![ "cargo", "install", @@ -99,7 +99,7 @@ async fn dind_image( .from("docker:dind") .with_directory( "/usr/local/cargo/bin/", - rust_bin.directory("/usr/local/cargo/bin/").id().await?, + rust_bin.directory("/usr/local/cargo/bin/"), ); let path_env = final_image.env_variable("PATH").await?; diff --git a/cuddle/Cargo.toml b/cuddle/Cargo.toml index 95ee2d6..f4759ae 100644 --- a/cuddle/Cargo.toml +++ b/cuddle/Cargo.toml @@ -40,3 +40,12 @@ serde_json = "1.0.112" rlua = "0.19.8" rlua-searcher = "0.1.0" dotenv = { version = "0.15.0", features = ["clap"] } +blake3 = "1.5.0" +tokio = { version = "1.35.1", features = ["full"] } +futures-util = "0.3.30" +fs_extra = "1.3.0" + +[dependencies.reqwest] +version = "0.11" +default-features = false +features = ["rustls-tls", "json"] diff --git a/cuddle/src/actions/mod.rs b/cuddle/src/actions/mod.rs index 6851770..9eb33dd 100644 --- a/cuddle/src/actions/mod.rs +++ b/cuddle/src/actions/mod.rs @@ -78,7 +78,7 @@ impl CuddleAction { log::trace!("preparing to run action"); - return match ShellAction::new( + match ShellAction::new( self.name.clone(), format!( "{}/scripts/{}.sh", @@ -98,7 +98,7 @@ impl CuddleAction { log::error!("{}", e); Err(e) } - }; + } } CuddleScript::Dagger(_d) => Err(anyhow::anyhow!("not implemented yet!")), CuddleScript::Lua(l) => { @@ -183,6 +183,184 @@ impl CuddleAction { Ok(()) } + CuddleScript::Rust(script) => Ok(()), + } + } +} + +pub mod rust_action { + use std::{path::PathBuf, time::Duration}; + + use anyhow::Context; + use futures_util::StreamExt; + use reqwest::Method; + use tokio::{fs::File, io::AsyncWriteExt}; + + use crate::model::{CuddleRustScript, CuddleRustUpstream, CuddleVariable}; + + pub struct RustActionConfig { + pub config_dir: PathBuf, + pub cache_dir: PathBuf, + } + + impl Default for RustActionConfig { + fn default() -> Self { + let config = dirs::config_dir().expect("to be able to find a valid .config dir"); + let cache = dirs::cache_dir().expect("to be able to find a valid .cache dir"); + + Self { + config_dir: config, + cache_dir: cache, + } + } + } + + pub struct RustAction { + pub config: RustActionConfig, + pub plan: String, + pub binary_name: String, + } + + impl RustAction { + pub fn new(plan: String, binary_name: String) -> Self { + Self { + plan, + binary_name, + config: RustActionConfig::default(), + } + } + + pub async fn execute( + &self, + script: CuddleRustScript, + variables: impl IntoIterator, + ) -> anyhow::Result<()> { + let commit_sha = self + .get_commit_sha() + .await + .context("failed to find a valid commit sha on the inferred path: .cuddle/plan")?; + + let binary_hash = self.calculate_hash(commit_sha)?; + + // Get cached binary + // let binary = match self.get_binary(&binary_hash).await? { + // Some(binary) => binary, + // None => self.fetch_binary(&script, &binary_hash).await?, + // }; + + // Execute binary + + Ok(()) + } + + async fn get_binary( + &self, + binary_hash: impl Into, + ) -> anyhow::Result> { + let binary_path = self.get_cached_binary_path(binary_hash); + if !binary_path.exists() { + return Ok(None); + } + + Ok(Some(RustBinary {})) + } + + fn get_cached_binary_path(&self, binary_hash: impl Into) -> PathBuf { + let cached_binary_name = self.get_cached_binary_name(binary_hash); + let binary_path = self + .config + .cache_dir + .join("binaries") + .join(cached_binary_name); + binary_path + } + + #[inline] + fn get_cached_binary_name(&self, binary_hash: impl Into) -> String { + format!("{}-{}", binary_hash.into(), self.binary_name) + } + + async fn get_commit_sha(&self) -> anyhow::Result { + let repo = git2::Repository::open(".cuddle/plan")?; + let head = repo.head()?; + let commit = head.peel_to_commit()?; + + let commit_sha = commit.id(); + + Ok(commit_sha.to_string()) + } + + // async fn fetch_binary( + // &self, + // script: &CuddleRustScript, + // binary_hash: impl Into, + // ) -> anyhow::Result { + //let upstream = &script.upstream; + + //TODO: we should interpret some template variables in the upstream string. Ignore for now though + + // match UpstreamRustBinary::from(upstream) { + // UpstreamRustBinary::HttpBased { url } => { + // let client = reqwest::ClientBuilder::new() + // .user_agent(concat!( + // env!("CARGO_PKG_NAME"), + // "/", + // env!("CARGO_PKG_VERSION") + // )) + // .connect_timeout(Duration::from_secs(5)) + // .build()?; + + // let resp = client.request(Method::GET, url).send().await?; + + // let mut stream = resp.bytes_stream(); + + // let mut file = File::create(self.get_cached_binary_name(binary_hash)).await?; + + // while let Some(item) = stream.next().await { + // let chunk = item?; + + // file.write_all(&chunk).await?; + // } + + // // Make sure the entire file is written before we execute it + // file.flush().await?; + + // todo!() + // } + // } + // } + + fn calculate_hash(&self, commit_sha: impl Into>) -> anyhow::Result { + let mut contents: Vec = Vec::new(); + contents.append(&mut self.plan.clone().into_bytes()); + contents.append(&mut commit_sha.into()); + + let hash = blake3::hash(&contents); + + let hex = hash.to_hex(); + + Ok(hex.to_string()) + } + } + + pub struct RustBinary {} + + pub enum UpstreamRustBinary { + HttpBased { url: String }, + } + + impl From for UpstreamRustBinary { + fn from(value: CuddleRustUpstream) -> Self { + match value { + CuddleRustUpstream::Gitea { url } => Self::HttpBased { url }, + } + } + } + impl From<&CuddleRustUpstream> for UpstreamRustBinary { + fn from(value: &CuddleRustUpstream) -> Self { + match value { + CuddleRustUpstream::Gitea { url } => Self::HttpBased { url: url.clone() }, + } } } } diff --git a/cuddle/src/cli/mod.rs b/cuddle/src/cli/mod.rs index eaff387..ddb1f45 100644 --- a/cuddle/src/cli/mod.rs +++ b/cuddle/src/cli/mod.rs @@ -15,7 +15,10 @@ use crate::{ util::git::GitCommit, }; -use self::subcommands::render_template::RenderTemplateCommand; +use self::subcommands::{ + render::RenderCommand, render_kustomize::RenderKustomizeCommand, + render_template::RenderTemplateCommand, +}; #[derive(Debug, Clone)] pub struct CuddleCli { @@ -73,9 +76,8 @@ impl CuddleCli { if let Ok(context_iter) = self.context.clone().unwrap().lock() { for ctx in context_iter.iter() { if let Some(variables) = ctx.plan.vars.clone() { - for (name, var) in variables { - self.variables.push(CuddleVariable::new(name, var)) - } + let mut variables: Vec = variables.into(); + self.variables.append(&mut variables); } if let CuddleTreeType::Root = ctx.node_type { @@ -83,7 +85,7 @@ impl CuddleCli { temp_path.push(".cuddle/tmp"); self.variables.push(CuddleVariable::new( - "tmp".into(), + "tmp", temp_path.clone().to_string_lossy().to_string(), )); @@ -93,10 +95,9 @@ impl CuddleCli { } match GitCommit::new() { - Ok(commit) => self.variables.push(CuddleVariable::new( - "commit_sha".into(), - commit.commit_sha.clone(), - )), + Ok(commit) => self + .variables + .push(CuddleVariable::new("commit_sha", commit.commit_sha.clone())), Err(e) => { log::debug!("{}", e); } @@ -126,6 +127,7 @@ impl CuddleCli { name, l.description.clone(), )), + CuddleScript::Rust(_) => todo!(), } } } @@ -136,7 +138,7 @@ impl CuddleCli { } fn process_templates(self) -> anyhow::Result { - if let None = self.tmp_dir { + if self.tmp_dir.is_none() { log::debug!("cannot process template as bare bones cli"); return Ok(self); } @@ -147,10 +149,8 @@ impl CuddleCli { .clone() .ok_or(anyhow::anyhow!("tmp_dir does not exist aborting"))?; match self.config.get_fetch_policy()? { - CuddleFetchPolicy::Always => { - if tmp_dir.exists() && tmp_dir.ends_with("tmp") { - std::fs::remove_dir_all(tmp_dir.clone())?; - } + CuddleFetchPolicy::Always if tmp_dir.exists() && tmp_dir.ends_with("tmp") => { + std::fs::remove_dir_all(tmp_dir.clone())?; } _ => {} } @@ -169,12 +169,30 @@ impl CuddleCli { continue; } - for file in std::fs::read_dir(template_path)?.into_iter() { + for file in std::fs::read_dir(&template_path)? { let f = file?; let mut dest_file = tmp_dir.clone(); - dest_file.push(f.file_name()); + dest_file.push(f.path().strip_prefix(&template_path)?.parent().unwrap()); - std::fs::copy(f.path(), dest_file)?; + tracing::trace!( + "moving from: {} to {}", + f.path().display(), + dest_file.display() + ); + + if f.path().is_dir() { + std::fs::create_dir_all(&dest_file)?; + } + + fs_extra::copy_items( + &[f.path()], + &dest_file, + &fs_extra::dir::CopyOptions { + overwrite: true, + skip_exist: false, + ..Default::default() + }, + )?; } } } @@ -194,6 +212,8 @@ impl CuddleCli { root_cmd = subcommands::x::build_command(root_cmd, self.clone()); root_cmd = subcommands::render_template::build_command(root_cmd); + root_cmd = subcommands::render_kustomize::build_command(root_cmd); + root_cmd = subcommands::render::build_command(root_cmd); root_cmd = subcommands::init::build_command(root_cmd, self.clone()); self.command = Some(root_cmd); @@ -223,11 +243,20 @@ impl CuddleCli { let res = match matches.subcommand() { Some(("x", exe_submatch)) => subcommands::x::execute_x(exe_submatch, self.clone()), + Some(("render", sub_matches)) => { + RenderCommand::execute(sub_matches, self.clone())?; + Ok(()) + } Some(("render_template", sub_matches)) => { RenderTemplateCommand::from_matches(sub_matches, self.clone()) .and_then(|cmd| cmd.execute())?; Ok(()) } + Some(("render-kustomize", sub_matches)) => { + RenderKustomizeCommand::from_matches(sub_matches, self.clone()) + .and_then(|cmd| cmd.execute())?; + Ok(()) + } Some(("init", sub_matches)) => { subcommands::init::execute_init(sub_matches, self.clone()) } diff --git a/cuddle/src/cli/subcommands/folder.rs b/cuddle/src/cli/subcommands/folder.rs new file mode 100644 index 0000000..d7cb6fb --- /dev/null +++ b/cuddle/src/cli/subcommands/folder.rs @@ -0,0 +1,168 @@ +use std::{collections::HashMap, path::PathBuf}; + +use anyhow::Context; +use clap::{Arg, ArgAction, ArgMatches, Command}; +use serde_json::from_value; +use tera::Function; + +use crate::{cli::CuddleCli, model::CuddleVariable}; + +pub fn build_command(root_cmd: Command) -> Command { + root_cmd.subcommand( + Command::new("folder") + .about("renders a template folder") + .args(&[ + Arg::new("source") + .long("source") + .required(true) + .value_parser(clap::value_parser!(PathBuf)), + Arg::new("destination") + .long("destination") + .required(true) + .value_parser(clap::value_parser!(PathBuf)), + Arg::new("extra-var") + .long("extra-var") + .action(ArgAction::Append) + .required(false), + ]), + ) +} + +pub struct FolderCommand { + variables: Vec, + source: PathBuf, + destination: PathBuf, +} + +impl FolderCommand { + pub fn from_matches(matches: &ArgMatches, cli: CuddleCli) -> anyhow::Result { + let source = matches + .get_one::("source") + .expect("source") + .clone(); + + let destination = matches + .get_one::("destination") + .expect("destination") + .clone(); + + let mut extra_vars: Vec = + if let Some(extra_vars) = matches.get_many::("extra-var") { + let mut vars = Vec::with_capacity(extra_vars.len()); + for var in extra_vars.into_iter() { + let parts: Vec<&str> = var.split('=').collect(); + if parts.len() != 2 { + return Err(anyhow::anyhow!("extra-var: is not set correctly: {}", var)); + } + + vars.push(CuddleVariable::new(parts[0], parts[1])); + } + vars + } else { + vec![] + }; + + extra_vars.append(&mut cli.variables.clone()); + + Ok(Self { + variables: extra_vars, + source, + destination, + }) + } + + pub fn execute(self) -> anyhow::Result<()> { + std::fs::remove_dir_all(&self.destination)?; + std::fs::create_dir_all(&self.destination)?; + + // Prepare context + let mut context = tera::Context::new(); + for var in &self.variables { + context.insert(var.name.to_lowercase().replace([' ', '-'], "_"), &var.value) + } + + let mut tera = tera::Tera::default(); + + tera.register_function("filter_by_prefix", filter_by_prefix(self.variables.clone())); + + for entry in walkdir::WalkDir::new(&self.source) { + let entry = entry?; + let entry_path = entry.path(); + let rel_path = self + .destination + .join(entry_path.strip_prefix(&self.source)?); + + if entry_path.is_file() { + // Load source template + let source = std::fs::read_to_string(entry_path)?; + + let output = tera.render_str(&source, &context)?; + + if let Some(parent) = rel_path.parent() { + std::fs::create_dir_all(parent)?; + } + + // Put template in final destination + std::fs::write(&rel_path, output).context(format!( + "failed to write to destination: {}", + &rel_path.display() + ))?; + + log::info!("finished writing template to: {}", &rel_path.display()); + } + } + + Ok(()) + } +} + +fn filter_by_prefix(variables: Vec) -> impl Function { + Box::new( + move |args: &HashMap| -> tera::Result { + for var in &variables { + tracing::info!("variable: {} - {}", var.name, var.value); + } + + let prefix = match args.get("prefix") { + Some(value) => match from_value::>(value.clone()) { + Ok(prefix) => prefix, + Err(e) => { + tracing::error!("prefix was not a string: {}", e); + return Err("prefix was not a string".into()); + } + }, + None => return Err("prefix is required".into()), + }; + + let prefix = prefix.join("_"); + + let vars = variables + .iter() + .filter_map(|v| { + if v.name.starts_with(&prefix) { + Some(CuddleVariable::new( + v.name.trim_start_matches(&prefix).trim_start_matches('_'), + v.value.clone(), + )) + } else { + None + } + }) + .collect::>(); + + tracing::info!("was here"); + + let mut structure: HashMap = HashMap::new(); + for var in vars { + tracing::info!("found: {} - {}", &var.name, &var.value); + structure.insert(var.name, var.value); + } + + Ok(serde_json::to_value(structure).unwrap()) + }, + ) +} + +fn filter_by_name(args: &HashMap) -> tera::Result { + Ok(tera::Value::Null) +} diff --git a/cuddle/src/cli/subcommands/kustomize.rs b/cuddle/src/cli/subcommands/kustomize.rs new file mode 100644 index 0000000..014182d --- /dev/null +++ b/cuddle/src/cli/subcommands/kustomize.rs @@ -0,0 +1,85 @@ +use std::{io::Write, path::PathBuf}; + +use clap::{Arg, ArgMatches, Command}; + +use crate::cli::CuddleCli; + +pub fn build_command(root_cmd: Command) -> Command { + root_cmd.subcommand( + Command::new("kustomize") + .about("renders a kustomize folder") + .args(&[ + Arg::new("kustomize-folder") + .long("kustomize-folder") + .value_parser(clap::value_parser!(PathBuf)) + .required(true), + Arg::new("destination") + .long("destination") + .required(true) + .value_parser(clap::value_parser!(PathBuf)), + ]), + ) +} + +pub struct KustomizeCommand { + kustomize_folder: PathBuf, + destination: PathBuf, +} + +impl KustomizeCommand { + pub fn from_matches(matches: &ArgMatches, _cli: CuddleCli) -> anyhow::Result { + let kustomize_folder = matches + .get_one::("kustomize-folder") + .expect("kustomize-folder") + .clone(); + + let destination = matches + .get_one::("destination") + .expect("destination") + .clone(); + + Ok(Self { + kustomize_folder, + destination, + }) + } + + pub fn execute(self) -> anyhow::Result<()> { + let mut cmd = std::process::Command::new("kubectl"); + + std::fs::remove_dir_all(&self.destination)?; + std::fs::create_dir_all(&self.destination)?; + + let cmd = cmd.arg("kustomize").arg(self.kustomize_folder); + let output = cmd.output()?; + + if !output.status.success() { + anyhow::bail!( + "failed to run kustomize: {}", + output.status.code().expect("to find exit code") + ) + } + + let mut cmd = std::process::Command::new("kubectl-slice"); + let cmd = cmd + .arg("-o") + .arg(self.destination) + .stdin(std::process::Stdio::piped()); + + let mut child = cmd.spawn()?; + + if let Some(mut stdin) = child.stdin.take() { + stdin.write_all(&output.stdout)?; + } + + let output = child.wait_with_output()?; + if !output.status.success() { + anyhow::bail!( + "failed to run kustomize: {}", + output.status.code().expect("to find exit code") + ) + } + + Ok(()) + } +} diff --git a/cuddle/src/cli/subcommands/mod.rs b/cuddle/src/cli/subcommands/mod.rs index 3d40181..4572498 100644 --- a/cuddle/src/cli/subcommands/mod.rs +++ b/cuddle/src/cli/subcommands/mod.rs @@ -1,3 +1,7 @@ +pub mod folder; pub mod init; +pub mod kustomize; +pub mod render; +pub mod render_kustomize; pub mod render_template; pub mod x; diff --git a/cuddle/src/cli/subcommands/render.rs b/cuddle/src/cli/subcommands/render.rs new file mode 100644 index 0000000..77a5af7 --- /dev/null +++ b/cuddle/src/cli/subcommands/render.rs @@ -0,0 +1,31 @@ +use clap::{ArgMatches, Command}; + +use crate::cli::CuddleCli; + +use super::{folder::FolderCommand, kustomize::KustomizeCommand}; + +pub fn build_command(root_cmd: Command) -> Command { + let cmd = Command::new("render").about("accesses different render commands"); + + let cmd = super::kustomize::build_command(cmd); + let cmd = super::folder::build_command(cmd); + + root_cmd.subcommand(cmd) +} + +pub struct RenderCommand {} +impl RenderCommand { + pub fn execute(matches: &ArgMatches, cli: CuddleCli) -> anyhow::Result<()> { + match matches.subcommand() { + Some(("kustomize", sub_matches)) => { + KustomizeCommand::from_matches(sub_matches, cli)?.execute()?; + } + Some(("folder", sub_matches)) => { + FolderCommand::from_matches(sub_matches, cli)?.execute()?; + } + _ => anyhow::bail!("failed to find match for render"), + } + + Ok(()) + } +} diff --git a/cuddle/src/cli/subcommands/render_kustomize.rs b/cuddle/src/cli/subcommands/render_kustomize.rs new file mode 100644 index 0000000..49d33c1 --- /dev/null +++ b/cuddle/src/cli/subcommands/render_kustomize.rs @@ -0,0 +1,70 @@ +use std::path::PathBuf; + +use clap::{Arg, ArgMatches, Command}; + +use crate::cli::CuddleCli; + +pub fn build_command(root_cmd: Command) -> Command { + root_cmd.subcommand( + Command::new("render-kustomize") + .about("renders a kustomize folder") + .args(&[ + Arg::new("kustomize-folder") + .long("kustomize-folder") + .value_parser(clap::value_parser!(PathBuf)) + .required(true), + Arg::new("destination") + .long("destination") + .required(true) + .value_parser(clap::value_parser!(PathBuf)), + ]), + ) +} + +pub struct RenderKustomizeCommand { + kustomize_folder: PathBuf, + destination: PathBuf, +} + +impl RenderKustomizeCommand { + pub fn from_matches(matches: &ArgMatches, _cli: CuddleCli) -> anyhow::Result { + let kustomize_folder = matches + .get_one::("kustomize-folder") + .expect("kustomize-folder") + .clone(); + + let destination = matches + .get_one::("destination") + .expect("destination") + .clone(); + + Ok(Self { + kustomize_folder, + destination, + }) + } + + pub fn execute(self) -> anyhow::Result<()> { + let mut cmd = std::process::Command::new("kubectl"); + + std::fs::create_dir_all(&self.destination)?; + + let cmd = cmd + .arg("kustomize") + .arg(self.kustomize_folder) + .arg(format!("--output={}", self.destination.display())); + + let mut process = cmd.spawn()?; + + let exit = process.wait()?; + + if !exit.success() { + anyhow::bail!( + "failed to run kustomize: {}", + exit.code().expect("to find exit code") + ) + } + + Ok(()) + } +} diff --git a/cuddle/src/cli/subcommands/render_template.rs b/cuddle/src/cli/subcommands/render_template.rs index d1699bd..727d537 100644 --- a/cuddle/src/cli/subcommands/render_template.rs +++ b/cuddle/src/cli/subcommands/render_template.rs @@ -1,11 +1,12 @@ use std::{path::PathBuf, str::FromStr}; -use clap::{Arg, ArgGroup, ArgMatches, Command}; +use anyhow::Context; +use clap::{Arg, ArgMatches, Command}; use crate::{cli::CuddleCli, model::CuddleVariable}; -const DESTINATION: &'static str = "destination is the output path of the template once done, but default .tmpl is stripped and the normal file extension is used. this can be overwritten if a file path is entered instead. I.e. (/some/file/name.txt)"; -const TEMPLATE_FILE: &'static str = "template-file is the input file path of the .tmpl file (or inferred) that you would like to render"; +const DESTINATION: &str = "destination is the output path of the template once done, but default .tmpl is stripped and the normal file extension is used. this can be overwritten if a file path is entered instead. I.e. (/some/file/name.txt)"; +const TEMPLATE_FILE: &str = "template-file is the input file path of the .tmpl file (or inferred) that you would like to render"; pub fn build_command(root_cmd: Command) -> Command { root_cmd.subcommand( @@ -51,18 +52,19 @@ impl RenderTemplateCommand { .get_one::("destination") .ok_or(anyhow::anyhow!("destination was not found")) .and_then(get_path_buf_and_check_dir_exists) - .and_then(RenderTemplateCommand::transform_extension)?; + .and_then(RenderTemplateCommand::transform_extension) + .context("failed to access dest directory")?; let mut extra_vars: Vec = if let Some(extra_vars) = matches.get_many::("extra-var") { let mut vars = Vec::with_capacity(extra_vars.len()); for var in extra_vars.into_iter() { - let parts: Vec<&str> = var.split("=").collect(); + let parts: Vec<&str> = var.split('=').collect(); if parts.len() != 2 { return Err(anyhow::anyhow!("extra-var: is not set correctly: {}", var)); } - vars.push(CuddleVariable::new(parts[0].into(), parts[1].into())); + vars.push(CuddleVariable::new(parts[0], parts[1])); } vars } else { @@ -82,10 +84,7 @@ impl RenderTemplateCommand { // Prepare context let mut context = tera::Context::new(); for var in self.variables { - context.insert( - var.name.to_lowercase().replace(" ", "_").replace("-", "_"), - &var.value, - ) + context.insert(var.name.to_lowercase().replace([' ', '-'], "_"), &var.value) } // Load source template @@ -93,8 +92,15 @@ impl RenderTemplateCommand { let output = tera::Tera::one_off(source.as_str(), &context, false)?; + if let Some(parent) = self.destination.parent() { + std::fs::create_dir_all(parent)?; + } + // Put template in final destination - std::fs::write(&self.destination, output)?; + std::fs::write(&self.destination, output).context(format!( + "failed to write to destination: {}", + &self.destination.display(), + ))?; log::info!( "finished writing template to: {}", @@ -123,8 +129,8 @@ impl RenderTemplateCommand { } } -fn get_path_buf_and_check_exists(raw_path: &String) -> anyhow::Result { - match PathBuf::from_str(&raw_path) { +fn get_path_buf_and_check_exists(raw_path: impl Into) -> anyhow::Result { + match PathBuf::from_str(&raw_path.into()) { Ok(pb) => { if pb.exists() { Ok(pb) @@ -139,17 +145,9 @@ fn get_path_buf_and_check_exists(raw_path: &String) -> anyhow::Result { } } -fn get_path_buf_and_check_dir_exists(raw_path: &String) -> anyhow::Result { - match PathBuf::from_str(&raw_path) { - Ok(pb) => { - if pb.is_dir() && pb.exists() { - Ok(pb) - } else if pb.is_file() { - Ok(pb) - } else { - Ok(pb) - } - } +fn get_path_buf_and_check_dir_exists(raw_path: impl Into) -> anyhow::Result { + match PathBuf::from_str(&raw_path.into()) { + Ok(pb) => Ok(pb), Err(e) => Err(anyhow::anyhow!(e)), } } diff --git a/cuddle/src/cli/subcommands/x.rs b/cuddle/src/cli/subcommands/x.rs index 7f38a07..6b00291 100644 --- a/cuddle/src/cli/subcommands/x.rs +++ b/cuddle/src/cli/subcommands/x.rs @@ -61,6 +61,7 @@ pub fn build_scripts(cli: CuddleCli) -> Vec { } crate::model::CuddleScript::Dagger(_) => todo!(), crate::model::CuddleScript::Lua(l) => {} + crate::model::CuddleScript::Rust(_) => todo!(), } cmds.push(cmd) diff --git a/cuddle/src/context.rs b/cuddle/src/context.rs index 589a154..6bd6d2f 100644 --- a/cuddle/src/context.rs +++ b/cuddle/src/context.rs @@ -1,12 +1,10 @@ use std::{ env::{self, current_dir}, ffi::OsStr, - io::Write, path::{Path, PathBuf}, sync::{Arc, Mutex}, }; -use anyhow::Context; use git2::{ build::{CheckoutBuilder, RepoBuilder}, FetchOptions, RemoteCallbacks, @@ -46,7 +44,7 @@ pub fn extract_cuddle( // Load main cuddle file. let cuddle_yaml = find_root_cuddle()?; - if let None = cuddle_yaml { + if cuddle_yaml.is_none() { return Ok(None); } let cuddle_yaml = cuddle_yaml.unwrap(); @@ -122,7 +120,7 @@ fn pull_parent_cuddle_into_local( ) -> anyhow::Result<()> { let mut rc = RemoteCallbacks::new(); rc.credentials(|_url, username_from_url, _allowed_types| { - if "true".to_string() == std::env::var("CUDDLE_SSH_AGENT").ok().unwrap_or("".into()) { + if *"true" == std::env::var("CUDDLE_SSH_AGENT").ok().unwrap_or("".into()) { git2::Cred::ssh_key_from_agent(username_from_url.unwrap()) } else { git2::Cred::ssh_key( @@ -155,7 +153,7 @@ fn recurse_parent( context: Arc>>, ) -> anyhow::Result> { let cuddle_contents = find_cuddle(path.clone())?; - if let None = cuddle_contents { + if cuddle_contents.is_none() { return Ok(None); } let cuddle_plan = serde_yaml::from_str::(&cuddle_contents.unwrap())?; @@ -172,14 +170,12 @@ fn recurse_parent( } match cuddle_plan.base { - CuddleBase::Bool(true) => { - return Err(anyhow::anyhow!( - "plan cannot be enabled without specifying a plan" - )) - } + CuddleBase::Bool(true) => Err(anyhow::anyhow!( + "plan cannot be enabled without specifying a plan" + )), CuddleBase::Bool(false) => { log::debug!("plan is root: finishing up"); - return Ok(Some(())); + Ok(Some(())) } CuddleBase::String(parent_plan) => { let destination_path = create_cuddle(path.clone())?; @@ -189,7 +185,7 @@ fn recurse_parent( if !cuddle_dest.exists() { pull_parent_cuddle_into_local(parent_plan, cuddle_dest.clone())?; } - return recurse_parent(cuddle_dest, context.clone()); + recurse_parent(cuddle_dest, context.clone()) } } } diff --git a/cuddle/src/model.rs b/cuddle/src/model.rs index 2760b79..a27d5e6 100644 --- a/cuddle/src/model.rs +++ b/cuddle/src/model.rs @@ -47,6 +47,18 @@ pub struct CuddleLuaScript { pub description: Option, } +#[derive(Debug, Clone, PartialEq, Deserialize)] +pub enum CuddleRustUpstream { + #[serde(alias = "gitea")] + Gitea { url: String }, +} + +#[derive(Debug, Clone, PartialEq, Deserialize)] +pub struct CuddleRustScript { + pub description: Option, + pub upstream: CuddleRustUpstream, +} + #[derive(Debug, Clone, PartialEq, Deserialize)] #[serde(tag = "type")] pub enum CuddleScript { @@ -56,16 +68,66 @@ pub enum CuddleScript { Dagger(CuddleDaggerScript), #[serde(alias = "lua")] Lua(CuddleLuaScript), + #[serde(alias = "rust")] + Rust(CuddleRustScript), } #[derive(Debug, Clone, PartialEq, Deserialize)] pub struct CuddlePlan { pub base: CuddleBase, - pub vars: Option>, + pub vars: Option, pub scripts: Option>, } -#[derive(Debug, Clone)] +#[derive(Deserialize, Debug, Clone, PartialEq)] +pub struct CuddlePlanVariables(HashMap); + +impl From for Vec { + fn from(value: CuddlePlanVariables) -> Self { + let variables: CuddleVariables = value.0.into(); + + let mut vars = variables.0; + vars.sort_by(|a, b| a.name.partial_cmp(&b.name).unwrap()); + + vars + } +} + +#[derive(Deserialize, Debug, Clone, PartialEq)] +#[serde(untagged)] +pub enum CuddlePlanVar { + Str(String), + Nested(HashMap), +} + +#[derive(Clone, Debug, PartialEq)] +struct CuddleVariables(Vec); + +impl From> for CuddleVariables { + fn from(value: HashMap) -> Self { + let mut variables = Vec::new(); + for (k, v) in value { + match v { + CuddlePlanVar::Str(value) => variables.push(CuddleVariable::new(k, value)), + CuddlePlanVar::Nested(nested) => { + let nested_variables: CuddleVariables = nested.into(); + + let mut combined_variables: Vec<_> = nested_variables + .0 + .into_iter() + .map(|v| CuddleVariable::new(format!("{}_{}", k, v.name), v.value)) + .collect(); + + variables.append(&mut combined_variables); + } + } + } + + CuddleVariables(variables) + } +} + +#[derive(Debug, Clone, PartialEq, Deserialize, serde::Serialize)] #[allow(dead_code)] pub struct CuddleVariable { pub name: String, @@ -73,7 +135,102 @@ pub struct CuddleVariable { } impl CuddleVariable { - pub fn new(name: String, value: String) -> Self { - Self { name, value } + pub fn new(name: impl Into, value: impl Into) -> Self { + Self { + name: name.into(), + value: value.into(), + } + } +} + +impl From> for CuddlePlanVar { + fn from(value: HashMap) -> Self { + CuddlePlanVar::Nested(value) + } +} + +impl From> for CuddlePlanVar { + fn from(value: HashMap<&str, CuddlePlanVar>) -> Self { + CuddlePlanVar::Nested(value.into_iter().map(|(k, v)| (k.to_string(), v)).collect()) + } +} + +impl From for CuddlePlanVar { + fn from(value: String) -> Self { + CuddlePlanVar::Str(value) + } +} + +impl From<&str> for CuddlePlanVar { + fn from(value: &str) -> Self { + CuddlePlanVar::Str(value.to_string()) + } +} + +#[cfg(test)] +mod test { + use std::collections::HashMap; + + use super::{CuddlePlanVariables, CuddleVariable}; + + #[test] + pub fn parse_cuddle_variables() { + let cuddle = r#" +someKey: someValue +someNestedKey: + someNestedNestedKey: + someKey: key + someKey: key + "#; + + let cuddle_var: CuddlePlanVariables = serde_yaml::from_str(cuddle).unwrap(); + + let mut expected = HashMap::new(); + expected.insert("someKey", "someValue".into()); + + let mut nested_key = HashMap::new(); + nested_key.insert("someKey", "key".into()); + + let mut nested_nested_key = HashMap::new(); + nested_nested_key.insert("someKey", "key".into()); + + nested_key.insert("someNestedNestedKey", nested_nested_key.into()); + + expected.insert("someNestedKey", nested_key.into()); + + assert_eq!( + CuddlePlanVariables( + expected + .into_iter() + .map(|(k, v)| (k.to_string(), v)) + .collect() + ), + cuddle_var + ); + } + + #[test] + pub fn to_cuddle_variables() { + let cuddle = r#" +someKey: someValue +someNestedKey: + someNestedNestedKey: + someKey: key + someKey: key + "#; + + let cuddle_var: CuddlePlanVariables = serde_yaml::from_str(cuddle).unwrap(); + + let variables: Vec = cuddle_var.into(); + + let mut expected: Vec = vec![ + CuddleVariable::new("someKey", "someValue"), + CuddleVariable::new("someNestedKey_someKey", "key"), + CuddleVariable::new("someNestedKey_someNestedNestedKey_someKey", "key"), + ]; + + expected.sort_by(|a, b| a.name.partial_cmp(&b.name).unwrap()); + + assert_eq!(expected, variables); } } diff --git a/templates/build_cuddle_image.Dockerfile b/templates/build_cuddle_image.Dockerfile index 45a1f17..2c55862 100644 --- a/templates/build_cuddle_image.Dockerfile +++ b/templates/build_cuddle_image.Dockerfile @@ -20,7 +20,16 @@ RUN cargo install --target x86_64-unknown-linux-musl --path cuddle FROM docker:dind -RUN apk add bash git +RUN apk add bash git kubectl + +ENV SLICE_VERSION=v1.2.7 +RUN wget -O kubectl-slice_linux_x86_64.tar.gz \ + "https://github.com/patrickdappollonio/kubectl-slice/releases/download/$SLICE_VERSION/kubectl-slice_linux_x86_64.tar.gz" && \ + tar -xf kubectl-slice_linux_x86_64.tar.gz && \ + chmod +x ./kubectl-slice && \ + mv ./kubectl-slice /usr/local/bin/kubectl-slice && \ + rm kubectl-slice_linux_x86_64.tar.gz + RUN eval `ssh-agent` COPY --from=1password/op:2 /usr/local/bin/op /usr/local/bin/op