From 769bfcc56be7fbd4aa49756cfaef75c00114ed6c Mon Sep 17 00:00:00 2001 From: tahahawa Date: Thu, 15 May 2025 00:34:37 -0400 Subject: [PATCH] Still WIP but pretty much done --- Cargo.lock | 242 +++++++----------- harmony/src/modules/cert_manager/helm.rs | 8 +- harmony/src/modules/helm/chart.rs | 53 ++-- harmony/src/modules/helm/command.rs | 53 ++-- harmony/src/modules/lamp.rs | 7 +- .../src/modules/monitoring/kube_prometheus.rs | 16 +- 6 files changed, 173 insertions(+), 206 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2fc47d9..f0558a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,15 +54,15 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", "const-random", "once_cell", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -248,9 +248,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" dependencies = [ "serde", ] @@ -350,9 +350,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.21" +version = "1.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8691782945451c1c383942c4874dbe63814f61cb57ef773cda2972682b7bb3c0" +checksum = "32db95edf998450acc7881c932f94cd9b05c87b4b2599e8bab064753da4acfd1" dependencies = [ "shlex", ] @@ -407,9 +407,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.37" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" +checksum = "ed93b9805f8ba930df42c2590f05453d5ec36cbb85d018868a5b24d31f6ac000" dependencies = [ "clap_builder", "clap_derive", @@ -417,9 +417,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.37" +version = "4.5.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" +checksum = "379026ff283facf611b0ea629334361c4211d1b12ee01024eec1591133b04120" dependencies = [ "anstream", "anstyle", @@ -608,7 +608,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "crossterm_winapi", "futures-core", "mio 1.0.3", @@ -1315,9 +1315,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ "cfg-if", "libc", @@ -1837,21 +1837,22 @@ dependencies = [ [[package]] name = "icu_collections" -version = "1.5.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" dependencies = [ "displaydoc", + "potential_utf", "yoke", "zerofrom", "zerovec", ] [[package]] -name = "icu_locid" -version = "1.5.0" +name = "icu_locale_core" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" dependencies = [ "displaydoc", "litemap", @@ -1860,31 +1861,11 @@ dependencies = [ "zerovec", ] -[[package]] -name = "icu_locid_transform" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_locid_transform_data" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" - [[package]] name = "icu_normalizer" -version = "1.5.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" dependencies = [ "displaydoc", "icu_collections", @@ -1892,67 +1873,54 @@ dependencies = [ "icu_properties", "icu_provider", "smallvec", - "utf16_iter", - "utf8_iter", - "write16", "zerovec", ] [[package]] name = "icu_normalizer_data" -version = "1.5.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" +checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" [[package]] name = "icu_properties" -version = "1.5.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +checksum = "2549ca8c7241c82f59c80ba2a6f415d931c5b58d24fb8412caa1a1f02c49139a" dependencies = [ "displaydoc", "icu_collections", - "icu_locid_transform", + "icu_locale_core", "icu_properties_data", "icu_provider", - "tinystr", + "potential_utf", + "zerotrie", "zerovec", ] [[package]] name = "icu_properties_data" -version = "1.5.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" +checksum = "8197e866e47b68f8f7d95249e172903bec06004b18b2937f1095d40a0c57de04" [[package]] name = "icu_provider" -version = "1.5.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" dependencies = [ "displaydoc", - "icu_locid", - "icu_provider_macros", + "icu_locale_core", "stable_deref_trait", "tinystr", "writeable", "yoke", "zerofrom", + "zerotrie", "zerovec", ] -[[package]] -name = "icu_provider_macros" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -1972,9 +1940,9 @@ dependencies = [ [[package]] name = "idna_adapter" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" dependencies = [ "icu_normalizer", "icu_properties", @@ -2018,7 +1986,7 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fddf93031af70e75410a2511ec04d49e758ed2f26dad3404a934e0fb45cc12a" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "crossterm 0.25.0", "dyn-clone", "fuzzy-matcher", @@ -2278,7 +2246,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "libc", ] @@ -2296,9 +2264,9 @@ checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] name = "litemap" -version = "0.7.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" +checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" [[package]] name = "lock_api" @@ -2561,7 +2529,7 @@ version = "0.10.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "cfg-if", "foreign-types", "libc", @@ -2943,6 +2911,15 @@ dependencies = [ "portable-atomic", ] +[[package]] +name = "potential_utf" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +dependencies = [ + "zerovec", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -2955,7 +2932,7 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ - "zerocopy 0.8.25", + "zerocopy", ] [[package]] @@ -3096,7 +3073,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.2", + "getrandom 0.3.3", ] [[package]] @@ -3105,7 +3082,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "cassowary", "compact_str", "crossterm 0.28.1", @@ -3126,7 +3103,7 @@ version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] [[package]] @@ -3309,7 +3286,7 @@ dependencies = [ "aes", "aes-gcm", "async-trait", - "bitflags 2.9.0", + "bitflags 2.9.1", "byteorder", "cbc", "chacha20", @@ -3410,7 +3387,7 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3bb94393cafad0530145b8f626d8687f1ee1dedb93d7ba7740d6ae81868b13b5" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "bytes", "chrono", "flurry", @@ -3457,7 +3434,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "errno", "libc", "linux-raw-sys 0.4.15", @@ -3470,7 +3447,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "errno", "libc", "linux-raw-sys 0.9.4", @@ -3546,9 +3523,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.2" +version = "0.103.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7149975849f1abb3832b246010ef62ccc80d3a76169517ada7188252b9cfb437" +checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" dependencies = [ "ring", "rustls-pki-types", @@ -3631,7 +3608,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -3644,7 +3621,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "core-foundation 0.10.0", "core-foundation-sys", "libc", @@ -3801,9 +3778,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" +checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" dependencies = [ "libc", "signal-hook-registry", @@ -4065,7 +4042,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "core-foundation 0.9.4", "system-configuration-sys 0.6.0", ] @@ -4110,12 +4087,12 @@ checksum = "b5ff282c3f91797f0acb021f3af7fffa8a78601f0f2fd0a9f79ee7dcf9a9af9e" [[package]] name = "tempfile" -version = "3.19.1" +version = "3.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" dependencies = [ "fastrand", - "getrandom 0.3.2", + "getrandom 0.3.3", "once_cell", "rustix 1.0.7", "windows-sys 0.59.0", @@ -4219,9 +4196,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.7.6" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" dependencies = [ "displaydoc", "zerovec", @@ -4318,12 +4295,12 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1cfca9ae570b2a6efc764a88e914c29b3dfaa1fafe5f495812ae97ec9bc4d53" +checksum = "0fdb0c213ca27a9f57ab69ddb290fd80d970922355b83ae380b395d3986b8a2e" dependencies = [ "base64 0.22.1", - "bitflags 2.9.0", + "bitflags 2.9.1", "bytes", "futures-util", "http 1.3.1", @@ -4505,12 +4482,6 @@ dependencies = [ "serde", ] -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - [[package]] name = "utf8_iter" version = "1.0.4" @@ -4529,7 +4500,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" dependencies = [ - "getrandom 0.3.2", + "getrandom 0.3.3", "rand 0.9.1", "uuid-macro-internal", ] @@ -5030,20 +5001,14 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - [[package]] name = "writeable" -version = "0.5.5" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" [[package]] name = "wyz" @@ -5092,9 +5057,9 @@ dependencies = [ [[package]] name = "yoke" -version = "0.7.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" dependencies = [ "serde", "stable_deref_trait", @@ -5104,9 +5069,9 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", @@ -5114,33 +5079,13 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive 0.7.35", -] - [[package]] name = "zerocopy" version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" dependencies = [ - "zerocopy-derive 0.8.25", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "zerocopy-derive", ] [[package]] @@ -5182,10 +5127,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" [[package]] -name = "zerovec" -version = "0.10.4" +name = "zerotrie" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" dependencies = [ "yoke", "zerofrom", @@ -5194,9 +5150,9 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.10.3" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", diff --git a/harmony/src/modules/cert_manager/helm.rs b/harmony/src/modules/cert_manager/helm.rs index 9a2521c..db97028 100644 --- a/harmony/src/modules/cert_manager/helm.rs +++ b/harmony/src/modules/cert_manager/helm.rs @@ -25,17 +25,13 @@ impl Score for CertManagerHelmScore { HelmChartScore { namespace: Some(NonBlankString::from_str("cert-manager").unwrap()), release_name: NonBlankString::from_str("cert-manager").unwrap(), - chart_name: NonBlankString::from_str("jetstack/cert-manager").unwrap(), + chart_name: NonBlankString::from_str("cert-manager").unwrap(), chart_version: None, values_overrides, values_yaml: None, create_namespace: true, install_only: true, - repository: Some(HelmRepository::new( - "jetstack".to_string(), - Url::parse("https://charts.jetstack.io").unwrap(), - true, - )), + repo_url: Some(NonBlankString::from_str("https://charts.jetstack.io").unwrap()), } .create_interpret() } diff --git a/harmony/src/modules/helm/chart.rs b/harmony/src/modules/helm/chart.rs index 76c2b45..d8e2231 100644 --- a/harmony/src/modules/helm/chart.rs +++ b/harmony/src/modules/helm/chart.rs @@ -2,7 +2,7 @@ use crate::data::{Id, Version}; use crate::interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome}; use crate::inventory::Inventory; use crate::score::Score; -use crate::topology::{HelmCommand, Topology}; +use crate::topology::{HelmCommand, K8sAnywhereTopology, K8sclient, Topology}; use async_trait::async_trait; use helm_wrapper_rs; use helm_wrapper_rs::blocking::{DefaultHelmExecutor, HelmExecutor}; @@ -10,12 +10,14 @@ use log::{debug, info, warn}; pub use non_blank_string_rs::NonBlankString; use serde::Serialize; use std::collections::HashMap; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::process::{Command, Output, Stdio}; use std::str::FromStr; use temp_file::TempFile; use url::Url; +use super::command::{self, HelmChart, HelmGlobals}; + #[derive(Debug, Clone, Serialize)] pub struct HelmRepository { name: String, @@ -44,7 +46,7 @@ pub struct HelmChartScore { /// Whether to run `helm upgrade --install` under the hood or only install when not present pub install_only: bool, - pub repository: Option, + pub repo_url: Option, } impl Score for HelmChartScore { @@ -104,7 +106,6 @@ impl HelmChartInterpret { fn run_helm_command(args: &[&str]) -> Result { let command_str = format!("helm {}", args.join(" ")); - debug!("Got KUBECONFIG: `{}`", std::env::var("KUBECONFIG").unwrap()); debug!("Running Helm command: `{}`", command_str); let output = Command::new("helm") @@ -141,7 +142,7 @@ impl Interpret for HelmChartInterpret { async fn execute( &self, _inventory: &Inventory, - _topology: &T, + topology: &T, ) -> Result { let ns = self .score @@ -150,23 +151,17 @@ impl Interpret for HelmChartInterpret { .unwrap_or_else(|| todo!("Get namespace from active kubernetes cluster")); let tf: TempFile; - let yaml_path: Option<&Path> = match self.score.values_yaml.as_ref() { + let yaml_path: Option = match self.score.values_yaml.as_ref() { Some(yaml_str) => { tf = temp_file::with_contents(yaml_str.as_bytes()); - Some(tf.path()) + Some(PathBuf::from(tf.path())) } None => None, }; self.add_repo()?; - let helm_executor = DefaultHelmExecutor::new_with_opts( - &NonBlankString::from_str("helm").unwrap(), - None, - 900, - false, - false, - ); + let helm_executor = DefaultHelmExecutor::new(); let mut helm_options = Vec::new(); if self.score.create_namespace { @@ -218,29 +213,21 @@ impl Interpret for HelmChartInterpret { Some(&helm_options), ); - let status = match res { - Ok(status) => status, + let output = match res { + Ok(output) => output, Err(err) => return Err(InterpretError::new(err.to_string())), }; - match status { - helm_wrapper_rs::HelmDeployStatus::Deployed => Ok(Outcome::new( - InterpretStatus::SUCCESS, - "Helm Chart deployed".to_string(), - )), - helm_wrapper_rs::HelmDeployStatus::PendingInstall => Ok(Outcome::new( - InterpretStatus::RUNNING, - "Helm Chart Pending install".to_string(), - )), - helm_wrapper_rs::HelmDeployStatus::PendingUpgrade => Ok(Outcome::new( - InterpretStatus::RUNNING, - "Helm Chart pending upgrade".to_string(), - )), - helm_wrapper_rs::HelmDeployStatus::Failed => Err(InterpretError::new( - "Failed to install helm chart".to_string(), - )), - } + // TODO: Get k8s client and execute YAML from Helm using it + // let client = topology.get_k8s_client(); + // match client.apply_yaml(output) { + // Ok(_) => return Ok(Outcome::success("Helm chart deployed".to_string())), + // Err(e) => return Err(InterpretError::new(e)), + // } + + Ok(Outcome::success("Helm chart deployed".to_string())) } + fn get_name(&self) -> InterpretName { todo!() } diff --git a/harmony/src/modules/helm/command.rs b/harmony/src/modules/helm/command.rs index 4978b7a..eb50816 100644 --- a/harmony/src/modules/helm/command.rs +++ b/harmony/src/modules/helm/command.rs @@ -1,3 +1,5 @@ +use log::debug; +use non_blank_string_rs::NonBlankString; use std::collections::HashMap; use std::env::temp_dir; use std::ffi::OsStr; @@ -27,13 +29,13 @@ pub struct HelmGlobals { #[derive(Clone)] pub struct HelmChart { pub name: String, - pub version: Option, - pub repo: Option, - pub release_name: Option, - pub namespace: Option, + pub version: Option, + pub repo: Option, + pub release_name: Option, + pub namespace: Option, pub additional_values_files: Vec, pub values_file: Option, - pub values_inline: HashMap, + pub values_inline: Option, pub include_crds: Option, pub skip_hooks: Option, pub api_versions: Option>, @@ -44,7 +46,7 @@ pub struct HelmChart { } impl HelmCommandExecutor { - pub fn generate(mut self) -> Result { + pub fn generate(mut self) -> Result { if self.globals.chart_home.is_none() { self.globals.chart_home = Some(PathBuf::from("charts")); } @@ -69,19 +71,38 @@ impl HelmCommandExecutor { )?; } - self.clone().run_command( + let out = match self.clone().run_command( self.chart .clone() .helm_args(self.globals.chart_home.clone().unwrap()), - ) + ) { + Ok(out) => out, + Err(e) => return Err(e), + }; + + // TODO: don't use unwrap here + let s = String::from_utf8(out.stdout).unwrap(); + debug!("helm stderr: {}", String::from_utf8(out.stderr).unwrap()); + debug!("helm status: {}", out.status); + debug!("helm output: {s}"); + + let clean = s.split_once("---").unwrap().1; + + Ok(clean.to_string()) } - pub fn version(self) -> Result { - self.run_command(vec![ + pub fn version(self) -> Result { + let out = match self.run_command(vec![ "version".to_string(), "-c".to_string(), "--short".to_string(), - ]) + ]) { + Ok(out) => out, + Err(e) => return Err(e), + }; + + // TODO: don't use unwrap + Ok(String::from_utf8(out.stdout).unwrap()) } pub fn run_command(mut self, mut args: Vec) -> Result { @@ -147,7 +168,7 @@ impl HelmChart { )); } else { args.push("--repo".to_string()); - args.push(r); + args.push(r.to_string()); args.push(self.name); } @@ -158,7 +179,7 @@ impl HelmChart { match self.version { Some(v) => { args.push("--version".to_string()); - args.push(v); + args.push(v.to_string()); } None => (), } @@ -167,10 +188,10 @@ impl HelmChart { } pub fn helm_args(self, chart_home: PathBuf) -> Vec { - let mut args = vec![]; + let mut args: Vec = vec!["template".to_string()]; match self.release_name { - Some(rn) => args.push(rn), + Some(rn) => args.push(rn.to_string()), None => args.push("--generate-name".to_string()), } @@ -183,7 +204,7 @@ impl HelmChart { if let Some(n) = self.namespace { args.push("--namespace".to_string()); - args.push(n); + args.push(n.to_string()); } if let Some(f) = self.values_file { diff --git a/harmony/src/modules/lamp.rs b/harmony/src/modules/lamp.rs index 3c5c439..5439ea3 100644 --- a/harmony/src/modules/lamp.rs +++ b/harmony/src/modules/lamp.rs @@ -135,6 +135,7 @@ impl Interpret for LAMPInterpret { info!("LAMP deployment_score {deployment_score:?}"); +<<<<<<< HEAD let lamp_ingress = K8sIngressScore { name: fqdn!("lamp-ingress"), host: fqdn!("test"), @@ -158,6 +159,10 @@ impl Interpret for LAMPInterpret { info!("LAMP lamp_ingress {lamp_ingress:?}"); +||||||| parent of f7f32d4 (Still WIP but pretty much done) + Ok(Outcome::success("Successfully deployed LAMP Stack!".to_string())) +======= +>>>>>>> f7f32d4 (Still WIP but pretty much done) Ok(Outcome::success( "Successfully deployed LAMP Stack!".to_string(), )) @@ -210,7 +215,7 @@ impl LAMPInterpret { create_namespace: true, install_only: false, values_yaml: None, - repository: None, + repo_url: None, }; score.create_interpret().execute(inventory, topology).await diff --git a/harmony/src/modules/monitoring/kube_prometheus.rs b/harmony/src/modules/monitoring/kube_prometheus.rs index c729c96..5b28a3a 100644 --- a/harmony/src/modules/monitoring/kube_prometheus.rs +++ b/harmony/src/modules/monitoring/kube_prometheus.rs @@ -16,14 +16,14 @@ additionalPrometheusRulesMap: - alert: 'PVC Fill Over 95 Percent In 2 Days' expr: | ( - kubelet_volume_stats_used_bytes - / + kubelet_volume_stats_used_bytes + / kubelet_volume_stats_capacity_bytes ) > 0.95 AND predict_linear(kubelet_volume_stats_used_bytes[2d], 2 * 24 * 60 * 60) - / - kubelet_volume_stats_capacity_bytes + / + kubelet_volume_stats_capacity_bytes > 0.95 for: 1m labels: @@ -36,8 +36,8 @@ additionalPrometheusRulesMap: namespace: Some(NonBlankString::from_str(ns).unwrap()), release_name: NonBlankString::from_str("kube-prometheus").unwrap(), chart_name: NonBlankString::from_str( - "oci://ghcr.io/prometheus-community/charts/kube-prometheus-stack", //use kube prometheus chart which includes grafana, prometheus, alert - //manager, etc + "kube-prometheus-stack", //use kube prometheus chart which includes grafana, prometheus, alert + //manager, etc ) .unwrap(), chart_version: None, @@ -45,6 +45,8 @@ additionalPrometheusRulesMap: values_yaml: Some(values.to_string()), create_namespace: true, install_only: true, - repository: None, + repo_url: Some( + NonBlankString::from_str("oci://ghcr.io/prometheus-community/charts/").unwrap(), + ), } }