diff --git a/.github/README.md b/.github/README.md index 5450a97..5133d8d 100755 --- a/.github/README.md +++ b/.github/README.md @@ -96,7 +96,7 @@ Probably most of the speed gains are because I am bypassing kubectl and just edi #### Binary Download and extract the binary. ```zsh -KUBESESS_VERSION=1.2.11 && \ +KUBESESS_VERSION=2.0.0 && \ KUBESESS_OS=x86_64-unknown-linux-gnu && \ wget "https://github.com/Ramilito/kubesess/releases/download/${KUBESESS_VERSION}/kubesess_${KUBESESS_VERSION}_${KUBESESS_OS}.tar.gz" && \ mkdir -p $HOME/.kube/kubesess && tar zxpf kubesess_${KUBESESS_VERSION}_${KUBESESS_OS}.tar.gz -C $HOME/.kube/kubesess && \ @@ -159,7 +159,7 @@ export KUBECONFIG=$HOME/.kube/config:$HOME/.kube/config-demo:$HOME/.kube/config- > :Note: **The order is important*: the first file will be the master config! -The second way is to let Kubesess handle it by adding one or more .yaml files under the $HOME/.kube folder and it will be automatically merged. +The second way is to let Kubesess handle it by adding one or more config files under the $HOME/.kube folder and it will be automatically merged. #### Add information to prompt (there are other good tools for this, kube-ps1 and p10k) ``` @@ -202,8 +202,8 @@ RPROMPT='$(prompt_context)' - [x] Add tab completion - https://github.com/clap-rs/clap/issues/1232 - [x] Add to brew - [x] Add support for multiple .kube/config files -- [ ] Add support for multiple namespace per session -- [ ] Add error handling +- [x] Add support for multiple namespace per session +- [x] Add error handling ## Troubleshooting @@ -224,14 +224,21 @@ This is how the ```$KUBECONFIG``` should look like (replace ```${USER}``` with y This is how the generated file should look like: ```yaml -kind: Config -apiVersion: v1 -current-context: docker-desktop +clusters: +- name: docker-desktop + cluster: + server: https://kubernetes.docker.internal:6443 + certificate-authority-data: REDACTED +users: +- name: docker-desktop + user: + client-certificate-data: REDACTED + client-key-data: REDACTED contexts: -- context: - namespace: default +- name: docker-desktop + context: cluster: docker-desktop user: docker-desktop - name: docker-desktop + namespace: default +current-context: docker-desktop ``` - diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index 3b826a2..9cdbe58 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -13,13 +13,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - uses: tale/kubectl-action@v1 - with: - base64-kube-config: ${{ inputs.KUBECONFIG }} - name: Test run: | cargo check cargo test --all - env: - KUBECONFIG: "/home/runner/.kube/config" diff --git a/Cargo.lock b/Cargo.lock index d7f944a..16324f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,15 +2,36 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "aho-corasick" -version = "0.7.19" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -55,16 +76,31 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "backtrace" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets", +] [[package]] name = "base-x" @@ -72,6 +108,18 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "beef" version = "0.5.2" @@ -84,6 +132,21 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "bstr" version = "0.2.17" @@ -92,26 +155,29 @@ checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ "lazy_static", "memchr", - "regex-automata", + "regex-automata 0.1.10", ] [[package]] name = "bumpalo" -version = "3.11.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] -name = "cc" -version = "1.0.73" +name = "bytes" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] -name = "cfg-if" -version = "0.1.10" +name = "cc" +version = "1.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" +dependencies = [ + "shlex 1.3.0", +] [[package]] name = "cfg-if" @@ -121,17 +187,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.22" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", - "time 0.1.44", + "serde", "wasm-bindgen", - "winapi", + "windows-targets", ] [[package]] @@ -142,7 +208,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim 0.8.0", "textwrap 0.11.0", "unicode-width", @@ -151,32 +217,32 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.16" +version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3dbbb6653e7c55cc8595ad3e1f7be8f32aba4eb7ff7f0fd1163d4f3d137c0a9" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", - "bitflags", + "bitflags 1.3.2", "clap_derive", "clap_lex", - "indexmap", + "indexmap 1.9.3", "once_cell", "strsim 0.10.0", "termcolor", - "textwrap 0.15.0", + "textwrap 0.16.1", ] [[package]] name = "clap_derive" -version = "3.2.15" +version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba52acd3b0a5c33aeada5cdaa3267cdc7c594a98731d4268cdc1532f4264cb4" +checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" dependencies = [ "heck", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.98", + "syn 1.0.109", ] [[package]] @@ -190,104 +256,99 @@ dependencies = [ [[package]] name = "const_fn" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" +checksum = "373e9fafaa20882876db20562275ff58d50e0caa2590077fe7ce7bef90211d0d" + +[[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", +] [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] -name = "crossbeam" -version = "0.8.2" +name = "cpufeatures" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ - "cfg-if 1.0.0", - "crossbeam-channel 0.5.6", - "crossbeam-deque", - "crossbeam-epoch", - "crossbeam-queue", - "crossbeam-utils 0.8.11", + "libc", ] [[package]] -name = "crossbeam-channel" -version = "0.4.4" +name = "crossbeam" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" +checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8" dependencies = [ - "crossbeam-utils 0.7.2", - "maybe-uninit", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", ] [[package]] name = "crossbeam-channel" -version = "0.5.6" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils 0.8.11", + "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if 1.0.0", "crossbeam-epoch", - "crossbeam-utils 0.8.11", + "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.10" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if 1.0.0", - "crossbeam-utils 0.8.11", - "memoffset", - "once_cell", - "scopeguard", + "crossbeam-utils", ] [[package]] name = "crossbeam-queue" -version = "0.3.6" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils 0.8.11", + "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.7.2" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", -] +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] -name = "crossbeam-utils" -version = "0.8.11" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "cfg-if 1.0.0", - "once_cell", + "generic-array", + "typenum", ] [[package]] @@ -311,7 +372,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.9.3", - "syn 1.0.98", + "syn 1.0.109", ] [[package]] @@ -322,16 +383,16 @@ checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" dependencies = [ "darling_core", "quote", - "syn 1.0.98", + "syn 1.0.109", ] [[package]] name = "defer-drop" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "828aca0e5e4341b0320a319209cbc6255b8b06254849ce8a5f33d33f7f2fa0f0" +checksum = "f613ec9fa66a6b28cdb1842b27f9adf24f39f9afc4dcdd9fdecee4aca7945c57" dependencies = [ - "crossbeam-channel 0.4.4", + "crossbeam-channel", "once_cell", ] @@ -345,7 +406,7 @@ dependencies = [ "derive_builder_core", "proc-macro2", "quote", - "syn 1.0.98", + "syn 1.0.109", ] [[package]] @@ -357,7 +418,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 1.0.98", + "syn 1.0.109", ] [[package]] @@ -366,6 +427,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "dirs" version = "4.0.0" @@ -381,7 +452,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "dirs-sys-next", ] @@ -439,274 +510,839 @@ dependencies = [ ] [[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "fuzzy-matcher" -version = "0.3.7" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54614a3312934d066701a80f20f15fa3b56d67ac7722b39eea5b4c9dd1d66c94" -dependencies = [ - "thread_local", -] +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] -name = "getrandom" -version = "0.2.7" +name = "errno" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ - "cfg-if 1.0.0", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.52.0", ] [[package]] -name = "hashbrown" -version = "0.12.3" +name = "fastrand" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] -name = "heck" -version = "0.4.0" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] -name = "hermit-abi" -version = "0.1.19" +name = "form_urlencoded" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ - "libc", + "percent-encoding", ] [[package]] -name = "humantime" -version = "2.1.0" +name = "futures" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] [[package]] -name = "iana-time-zone" -version = "0.1.46" +name = "futures-channel" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad2bfd338099682614d3ee3fe0cd72e0b6a41ca6a87f6a74a3bd593c91650501" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ - "android_system_properties", - "core-foundation-sys", - "js-sys", - "wasm-bindgen", - "winapi", + "futures-core", + "futures-sink", ] [[package]] -name = "ident_case" -version = "1.0.1" +name = "futures-core" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] -name = "indexmap" -version = "1.9.1" +name = "futures-io" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" -dependencies = [ - "autocfg", - "hashbrown", -] +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] -name = "itertools" -version = "0.10.3" +name = "futures-sink" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ - "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", ] [[package]] -name = "itoa" -version = "1.0.2" +name = "fuzzy-matcher" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" +checksum = "54614a3312934d066701a80f20f15fa3b56d67ac7722b39eea5b4c9dd1d66c94" +dependencies = [ + "thread_local", +] [[package]] -name = "js-sys" -version = "0.3.60" +name = "generic-array" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ - "wasm-bindgen", + "typenum", + "version_check", ] [[package]] -name = "kubesess" -version = "1.2.11" +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ - "assert_cmd", - "clap 3.2.16", - "dirs", - "lazy_static", - "serde", - "serde_yaml", - "skim", - "thiserror", + "cfg-if", + "libc", + "wasi", ] [[package]] -name = "lazy_static" -version = "1.4.0" +name = "gimli" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] -name = "libc" -version = "0.2.132" +name = "hashbrown" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] -name = "log" -version = "0.4.17" +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + +[[package]] +name = "headers" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +checksum = "322106e6bd0cba2d5ead589ddb8150a13d7c4217cf80d7c4f682ca994ccc6aa9" dependencies = [ - "cfg-if 1.0.0", + "base64 0.21.7", + "bytes", + "headers-core", + "http", + "httpdate", + "mime", + "sha1 0.10.6", ] [[package]] -name = "maybe-uninit" -version = "2.0.0" +name = "headers-core" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" +checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" +dependencies = [ + "http", +] [[package]] -name = "memchr" -version = "2.5.0" +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] -name = "memoffset" -version = "0.6.5" +name = "hermit-abi" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ - "autocfg", + "libc", ] [[package]] -name = "nix" -version = "0.19.1" +name = "hermit-abi" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2" -dependencies = [ - "bitflags", - "cc", - "cfg-if 1.0.0", - "libc", -] +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] -name = "nix" -version = "0.24.2" +name = "home" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "libc", - "memoffset", + "windows-sys 0.52.0", ] [[package]] -name = "num-integer" -version = "0.1.45" +name = "http" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ - "autocfg", - "num-traits", + "bytes", + "fnv", + "itoa", ] [[package]] -name = "num-traits" -version = "0.2.15" +name = "http-body" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ - "autocfg", + "bytes", + "http", ] [[package]] -name = "num_cpus" -version = "1.13.1" +name = "http-body-util" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ - "hermit-abi", - "libc", + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", ] [[package]] -name = "once_cell" -version = "1.13.0" +name = "httparse" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] -name = "os_str_bytes" -version = "6.2.0" +name = "httpdate" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] -name = "predicates" -version = "2.1.1" +name = "humantime" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5aab5be6e4732b473071984b3164dbbfb7a3674d30ea5ff44410b6bcd960c3c" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "hyper" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ - "difflib", - "itertools", - "predicates-core", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", ] [[package]] -name = "predicates-core" -version = "1.0.3" +name = "hyper-http-proxy" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da1c2388b1513e1b605fcec39a95e0a9e8ef088f71443ef37099fa9ae6673fcb" +checksum = "5d06dbdfbacf34d996c6fb540a71a684a7aae9056c71951163af8a8a4c07b9a4" +dependencies = [ + "bytes", + "futures-util", + "headers", + "http", + "hyper", + "hyper-rustls", + "hyper-util", + "pin-project-lite", + "rustls-native-certs 0.7.3", + "tokio", + "tokio-rustls", + "tower-service", +] [[package]] -name = "predicates-tree" -version = "1.0.5" +name = "hyper-rustls" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d86de6de25020a36c6d3643a86d9a6a9f552107c0559c60ea03551b5e16c032" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ - "predicates-core", - "termtree", + "futures-util", + "http", + "hyper", + "hyper-util", + "log", + "rustls", + "rustls-native-certs 0.8.0", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", ] [[package]] -name = "proc-macro-error" -version = "1.0.4" +name = "hyper-timeout" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.98", - "version_check", + "hyper", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", ] [[package]] -name = "proc-macro-error-attr" +name = "hyper-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown 0.15.0", +] + +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "jsonpath-rust" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d8fe85bd70ff715f31ce8c739194b423d79811a19602115d611a3ec85d6200" +dependencies = [ + "lazy_static", + "once_cell", + "pest", + "pest_derive", + "regex", + "serde_json", + "thiserror", +] + +[[package]] +name = "k8s-openapi" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8847402328d8301354c94d605481f25a6bdc1ed65471fd96af8eca71141b13" +dependencies = [ + "base64 0.22.1", + "chrono", + "serde", + "serde-value", + "serde_json", +] + +[[package]] +name = "kube" +version = "0.96.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efffeb3df0bd4ef3e5d65044573499c0e4889b988070b08c50b25b1329289a1f" +dependencies = [ + "k8s-openapi", + "kube-client", + "kube-core", +] + +[[package]] +name = "kube-client" +version = "0.96.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf471ece8ff8d24735ce78dac4d091e9fcb8d74811aeb6b75de4d1c3f5de0f1" +dependencies = [ + "base64 0.22.1", + "bytes", + "chrono", + "either", + "futures", + "home", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-http-proxy", + "hyper-rustls", + "hyper-timeout", + "hyper-util", + "jsonpath-rust", + "k8s-openapi", + "kube-core", + "pem", + "rustls", + "rustls-pemfile", + "secrecy", + "serde", + "serde_json", + "serde_yaml", + "thiserror", + "tokio", + "tokio-util", + "tower", + "tower-http", + "tracing", +] + +[[package]] +name = "kube-core" +version = "0.96.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f42346d30bb34d1d7adc5c549b691bce7aa3a1e60254e68fab7e2d7b26fe3d77" +dependencies = [ + "chrono", + "form_urlencoded", + "http", + "k8s-openapi", + "serde", + "serde-value", + "serde_json", + "thiserror", +] + +[[package]] +name = "kubesess" +version = "1.2.11" +dependencies = [ + "assert_cmd", + "clap 3.2.25", + "dirs", + "k8s-openapi", + "kube", + "lazy_static", + "serde", + "serde_yaml", + "serial_test", + "skim", + "tempfile", + "thiserror", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.161" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" + +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "wasi", + "windows-sys 0.52.0", +] + +[[package]] +name = "nix" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2" +dependencies = [ + "bitflags 1.3.2", + "cc", + "cfg-if", + "libc", +] + +[[package]] +name = "nix" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "ordered-float" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] + +[[package]] +name = "os_str_bytes" +version = "6.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "pem" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +dependencies = [ + "base64 0.22.1", + "serde", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pest" +version = "2.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d214365f632b123a47fd913301e14c946c61d1c183ee245fa76eb752e59a02dd" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb55586734301717aea2ac313f50b2eb8f60d2fc3dc01d190eefa2e625f60c4e" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "pest_meta" +version = "2.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b75da2a70cf4d9cb76833c990ac9cd3923c9a8905a8929789ce347c84564d03d" +dependencies = [ + "once_cell", + "pest", + "sha2", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "predicates" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5aab5be6e4732b473071984b3164dbbfb7a3674d30ea5ff44410b6bcd960c3c" +dependencies = [ + "difflib", + "itertools", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da1c2388b1513e1b605fcec39a95e0a9e8ef088f71443ef37099fa9ae6673fcb" + +[[package]] +name = "predicates-tree" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d86de6de25020a36c6d3643a86d9a6a9f552107c0559c60ea03551b5e16c032" +dependencies = [ + "predicates-core", + "termtree", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" @@ -718,121 +1354,271 @@ dependencies = [ [[package]] name = "proc-macro-hack" -version = "0.5.19" +version = "0.5.20+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" +checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] [[package]] name = "rayon" -version = "1.5.3" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.3" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ - "crossbeam-channel 0.5.6", "crossbeam-deque", - "crossbeam-utils 0.8.11", - "num_cpus", + "crossbeam-utils", +] + +[[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_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.3.7", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + +[[package]] +name = "regex-automata" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.23.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", ] [[package]] -name = "redox_syscall" -version = "0.2.15" +name = "rustls-pemfile" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534cfe58d6a18cc17120fbf4635d53d14691c1fe4d951064df9bd326178d7d5a" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "bitflags", + "rustls-pki-types", ] [[package]] -name = "redox_users" -version = "0.4.3" +name = "rustls-pki-types" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom", - "redox_syscall", - "thiserror", -] +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" [[package]] -name = "regex" -version = "1.6.0" +name = "rustls-webpki" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] -name = "regex-automata" -version = "0.1.10" +name = "rustversion" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] -name = "regex-syntax" -version = "0.6.27" +name = "ryu" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] -name = "rustc_version" -version = "0.2.3" +name = "schannel" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ - "semver", + "windows-sys 0.59.0", ] [[package]] -name = "rustversion" -version = "1.0.9" +name = "scopeguard" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] -name = "ryu" -version = "1.0.10" +name = "secrecy" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +checksum = "e891af845473308773346dc847b2c23ee78fe442e0472ac50e22a18a93d3ae5a" +dependencies = [ + "zeroize", +] [[package]] -name = "scopeguard" -version = "1.1.0" +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +dependencies = [ + "core-foundation-sys", + "libc", +] [[package]] name = "semver" @@ -851,48 +1637,81 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.141" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7af873f2c95b99fcb0bd0fe622a43e29514658873c8ceba88c4cb88833a22500" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde", +] + [[package]] name = "serde_derive" -version = "1.0.141" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75743a150d003dd863b51dc809bcad0d73f2102c53632f1e954e738192a3413f" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 1.0.98", + "syn 2.0.79", ] [[package]] name = "serde_json" -version = "1.0.85" +version = "1.0.131" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" +checksum = "67d42a0bd4ac281beff598909bb56a86acaf979b84483e1c79c10dcaf98f8cf3" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] [[package]] name = "serde_yaml" -version = "0.9.3" +version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27000a1af761b5fe3d1a1d659a9d3fe4b435352d3ad09301545f696932b35d78" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap", + "indexmap 2.6.0", "itoa", "ryu", "serde", "unsafe-libyaml", ] +[[package]] +name = "serial_test" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0bccbcf40c8938196944a3da0e133e031a33f4d6b72db3bda3cc556e361905d" +dependencies = [ + "lazy_static", + "parking_lot", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "sha1" version = "0.6.1" @@ -902,11 +1721,33 @@ dependencies = [ "sha1_smol", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha1_smol" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" +checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] [[package]] name = "shlex" @@ -914,6 +1755,21 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + [[package]] name = "skim" version = "0.9.4" @@ -922,7 +1778,7 @@ checksum = "4b9d19f904221fab15163486d2ce116cb86e60296470bb4e956d6687f04ebbb4" dependencies = [ "atty", "beef", - "bitflags", + "bitflags 1.3.2", "chrono", "clap 2.34.0", "crossbeam", @@ -935,14 +1791,45 @@ dependencies = [ "nix 0.19.1", "rayon", "regex", - "shlex", - "time 0.2.27", + "shlex 0.1.1", + "time", "timer", "tuikit", "unicode-width", "vte", ] +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "standback" version = "0.2.17" @@ -976,7 +1863,7 @@ dependencies = [ "quote", "serde", "serde_derive", - "syn 1.0.98", + "syn 1.0.109", ] [[package]] @@ -991,8 +1878,8 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha1", - "syn 1.0.98", + "sha1 0.6.1", + "syn 1.0.109", ] [[package]] @@ -1019,11 +1906,17 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" -version = "1.0.98" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -1032,15 +1925,34 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "tempfile" +version = "3.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +dependencies = [ + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + [[package]] name = "term" version = "0.7.0" @@ -1054,9 +1966,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.3" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -1078,50 +1990,40 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.15.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.79", ] [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ + "cfg-if", "once_cell", ] -[[package]] -name = "time" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - [[package]] name = "time" version = "0.2.27" @@ -1157,7 +2059,7 @@ dependencies = [ "proc-macro2", "quote", "standback", - "syn 1.0.98", + "syn 1.0.109", ] [[package]] @@ -1169,43 +2071,186 @@ dependencies = [ "chrono", ] +[[package]] +name = "tokio" +version = "1.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8437150ab6bbc8c5f0f519e3d5ed4aa883a83dd4cdd3d1b21f9482936046cb97" +dependencies = [ + "base64 0.22.1", + "bitflags 2.6.0", + "bytes", + "http", + "http-body", + "mime", + "pin-project-lite", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "tuikit" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "667c8e002675e76d98358d8869021793a472d28e3a50fbd750284a1d211abd09" dependencies = [ - "bitflags", + "bitflags 1.3.2", "lazy_static", "log", - "nix 0.24.2", + "nix 0.24.3", "term", "unicode-width", ] +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + [[package]] name = "unicode-ident" -version = "1.0.2" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unsafe-libyaml" -version = "0.2.1" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + +[[package]] +name = "untrusted" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dc1c637311091be28e5d462c07db78081e5828da80ba22605c81c4ad6f7f813" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "utf8parse" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "vec_map" @@ -1215,9 +2260,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vte" @@ -1232,9 +2277,9 @@ dependencies = [ [[package]] name = "vte_generate_state_changes" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff" +checksum = "2e369bee1b05d510a7b4ed645f5faa90619e05437111783ea5848f28d97d3c2e" dependencies = [ "proc-macro2", "quote", @@ -1250,10 +2295,13 @@ dependencies = [ ] [[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +name = "want" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] [[package]] name = "wasi" @@ -1263,34 +2311,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.98", + "syn 2.0.79", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1298,22 +2347,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 1.0.98", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "winapi" @@ -1333,11 +2382,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -1345,3 +2394,100 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/Cargo.toml b/Cargo.toml index c7ab169..5a26c26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kubesess" -version = "1.2.11" +version = "2.0.0" authors = ["https://github.com/ramilito"] edition = "2021" @@ -12,6 +12,10 @@ serde = { version = "1.0.141", features = ["derive"] } lazy_static = "1.4.0" skim = "0.9.4" thiserror = "1.0.56" +kube = { version = "0.96.0", features = ["config"] } +k8s-openapi = { version = "0.23.0", features = ["latest"] } [dev-dependencies] +tempfile = "3.3" assert_cmd = "2.0" +serial_test = "0.5" diff --git a/scripts/fish/functions/knd.fish b/scripts/fish/functions/knd.fish index d1094ad..975f380 100644 --- a/scripts/fish/functions/knd.fish +++ b/scripts/fish/functions/knd.fish @@ -3,5 +3,6 @@ function knd --argument-names context --description "Switch global kubernetes na if test -n "$argv" set -a cmd -v $context end - command $cmd + set -l config (command $cmd) || return $status + set -gx KUBECONFIG $config end diff --git a/scripts/sh/kubesess.sh b/scripts/sh/kubesess.sh index 333f9dd..894d89f 100644 --- a/scripts/sh/kubesess.sh +++ b/scripts/sh/kubesess.sh @@ -19,5 +19,5 @@ kn() { } knd() { - kubesess ${1:+"-v "$1} default-namespace; + __kubesess_export ${1:+"-v "$1} default-namespace } diff --git a/src/commands.rs b/src/commands.rs index 8d961f2..d11af40 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,20 +1,19 @@ -use crate::{error::SetContextError, model::KubeConfig}; use crate::config; +use crate::error::SetContextError; use std::{ io::Cursor, + path::Path, process::{Command, Stdio}, }; extern crate skim; +use kube::config::Kubeconfig; use skim::prelude::*; -pub fn set_default_namespace(ns: &str, ctx: &str) { +pub fn set_default_namespace(ns: &str, ctx: &str, target: &Path) { Command::new("kubectl") .arg("config") - .arg(format!( - "--kubeconfig={}/.kube/config", - dirs::home_dir().unwrap().display() - )) + .arg(format!("--kubeconfig={}", target.to_string_lossy())) .arg("set-context") .arg(ctx) .arg(format!("--namespace={}", ns)) @@ -25,13 +24,10 @@ pub fn set_default_namespace(ns: &str, ctx: &str) { .unwrap(); } -pub fn set_default_context(ctx: &str) { +pub fn set_default_context(ctx: &str, target: &Path) { Command::new("kubectl") .arg("config") - .arg(format!( - "--kubeconfig={}/.kube/config", - dirs::home_dir().unwrap().display() - )) + .arg(format!("--kubeconfig={}", target.to_string_lossy())) .arg("use-context") .arg(ctx) .stdout(Stdio::null()) @@ -51,19 +47,6 @@ pub fn get_namespaces() -> Vec { string.lines().skip(1).map(ToOwned::to_owned).collect() } -pub fn get_current_context() -> String { - let output = Command::new("kubectl") - .args(["config", "current-context"]) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .spawn() - .unwrap() - .wait_with_output() - .unwrap(); - - String::from_utf8(output.stdout).unwrap().trim().to_owned() -} - /// Prompts the user to select an item from a list. /// Returns the selected item or `None` if no item was selected pub fn selectable_list(input: Vec) -> Option { @@ -81,16 +64,22 @@ pub fn selectable_list(input: Vec) -> Option { .map(|selected_items| selected_items[0].output().to_string()) } -pub fn set_namespace(ctx: &str, selection: &str, temp_dir: &str, config: &KubeConfig) { +pub fn set_namespace(ctx: &str, selection: &str, temp_dir: &str, config: &Kubeconfig) -> String { let choice = config.contexts.iter().find(|x| x.name == ctx); - config::write(choice.unwrap(), Some(selection), temp_dir) + config::write(choice.unwrap(), Some(selection), temp_dir, config) } -pub fn set_context(ctx: &str, temp_dir: &str, config: &KubeConfig) -> Result<(), SetContextError> { +pub fn set_context( + ctx: &str, + temp_dir: &str, + config: &Kubeconfig, +) -> Result { if let Some(choice) = config.contexts.iter().find(|x| x.name == ctx) { - config::write(choice, None, temp_dir); - Ok(()) + let filename = config::write(choice, None, temp_dir, config); + Ok(filename) } else { - Err(SetContextError::KubeContextNotFound{ctx: ctx.to_owned()}) + Err(SetContextError::KubeContextNotFound { + ctx: ctx.to_owned(), + }) } } diff --git a/src/config.rs b/src/config.rs index 6285b40..74b0007 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,38 +1,117 @@ -use crate::model::{KubeConfig, Context, Contexts}; use crate::{KUBECONFIG, KUBESESSCONFIG}; +use kube::config::Kubeconfig; +use kube::config::NamedContext; use std::fs::{self, File}; -use std::io::{BufReader, BufWriter, Read}; +use std::io::BufWriter; use std::path::Path; +use std::path::PathBuf; -fn build(ctx: &Contexts, ns: Option<&str>, strbuf: &str) -> KubeConfig { - let mut config: KubeConfig = serde_yaml::from_str(strbuf).unwrap(); - config.api_version = "v1".to_string(); - config.kind = "Config".to_string(); - config.current_context = ctx.name.to_string(); +pub struct KubeConfigs { + pub config: Kubeconfig, + pub configs: Vec<(Kubeconfig, PathBuf)>, +} - let ns = match ns { - Some(namespace) => namespace.to_string(), - None => { - if !config.contexts.is_empty() && !config.contexts[0].context.namespace.is_empty() { - config.contexts[0].context.namespace.to_string() - } else if !ctx.context.namespace.is_empty() { - ctx.context.namespace.to_string() - } else { - "default".to_string() +pub fn get(current_session: Option<&str>) -> KubeConfigs { + use std::collections::HashSet; + use std::path::PathBuf; + + let config_paths_str = match current_session { + Some(path) if !path.is_empty() => format!("{}:{}", path, KUBECONFIG.clone()), + Some(_) | None => KUBECONFIG.clone(), + }; + + let mut paths_set = HashSet::new(); + let config_paths: Vec = config_paths_str + .split(':') + .filter(|path| !path.is_empty() && paths_set.insert(path.to_string())) + .map(PathBuf::from) + .collect(); + + let mut conifg = Kubeconfig::default(); + let mut configs = Vec::new(); + + for path in config_paths { + match Kubeconfig::read_from(&path) { + Ok(kubeconfig) => { + configs.push((kubeconfig.clone(), path.clone())); + + conifg.contexts.extend(kubeconfig.contexts.into_iter()); + conifg.clusters.extend(kubeconfig.clusters.into_iter()); + conifg.auth_infos.extend(kubeconfig.auth_infos.into_iter()); + + if conifg.current_context.is_none() { + conifg.current_context = kubeconfig.current_context.clone(); + } } + Err(err) => { + eprintln!( + "Failed to load Kubeconfig from '{}': {}", + path.display(), + err + ); + } + } + } + + KubeConfigs { + config: conifg, + configs, + } +} + +pub fn build( + selected_context: &NamedContext, + namespace: Option<&str>, + kubeconfig: &Kubeconfig, +) -> Kubeconfig { + let context_name = &selected_context.name; + + // Handle the case where the context is None + let context = match &selected_context.context { + Some(ctx) => ctx, + None => { + eprintln!("Error: The selected context has no associated context data."); + return Kubeconfig::default(); } }; - config.contexts = vec![Contexts { - context: Context { - namespace: ns, - cluster: ctx.context.cluster.to_string(), - user: ctx.context.user.to_string(), - }, - name: ctx.name.to_string(), - }]; + // Find the corresponding cluster based on the context's cluster reference + let cluster_name = &context.cluster; + let selected_cluster = kubeconfig + .clusters + .iter() + .find(|cluster| &cluster.name == cluster_name) + .expect("Cluster for the selected context not found"); + + // Find the corresponding auth_info (user) based on the context's user reference + let user_name = &context.user; + let selected_auth_info = kubeconfig + .auth_infos + .iter() + .find(|auth_info| &auth_info.name == user_name) + .expect("Auth info for the selected context not found"); + + // Determine the namespace: use the provided one or fallback to the context's namespace + let final_namespace = match namespace { + Some(ns) => ns.to_string(), + None => context + .namespace + .clone() + .unwrap_or_else(|| "default".to_string()), + }; - config + let mut minimal_context = selected_context.clone(); + if let Some(ref mut ctx) = minimal_context.context { + ctx.namespace = Some(final_namespace); + } + + Kubeconfig { + current_context: Some(context_name.clone()), + contexts: vec![minimal_context], + clusters: vec![selected_cluster.clone()], + auth_infos: vec![selected_auth_info.clone()], + ..Kubeconfig::default() + } } fn get_file(path: &String) -> File { @@ -46,8 +125,8 @@ fn get_file(path: &String) -> File { f } -fn get_path(ctx: &Contexts, dest: &str) -> String { - let path = Path::new(ctx.name.as_str()); +fn get_path(filename: &str, dest: &str) -> String { + let path = Path::new(&filename); let parent = path.parent().unwrap(); let dirname = str::replace(&parent.display().to_string(), ":", "_"); @@ -59,81 +138,38 @@ fn get_path(ctx: &Contexts, dest: &str) -> String { path.display().to_string() } -pub fn write(ctx: &Contexts, namespace: Option<&str>, dest: &str) { - let path = get_path(ctx, dest); - - let strbuf = match fs::read_to_string(&path) { - Ok(file) => file, - Err(_error) => "".to_string(), - }; +pub fn write( + ctx: &NamedContext, + namespace: Option<&str>, + dest: &str, + config: &Kubeconfig, +) -> String { + let minimal_config = build(ctx, namespace, config); + let selected_context = minimal_config.current_context.clone().unwrap_or_default(); + let selected_ns = minimal_config + .contexts + .first() + .and_then(|ctx| ctx.context.as_ref().and_then(|c| c.namespace.clone())) + .unwrap_or_else(|| "default".to_string()); + + let filename = selected_context.to_owned() + "_" + &selected_ns.to_owned(); + let path = get_path(&filename, dest); let options = get_file(&path); let writer = BufWriter::new(&options); - let config = build(ctx, namespace, &strbuf); - serde_yaml::to_writer(writer, &config).unwrap(); + serde_yaml::to_writer(writer, &minimal_config).unwrap(); + filename } -pub fn get() -> KubeConfig { - let mut configs = KubeConfig::default(); - - for s in KUBECONFIG.rsplit(':') { - if s.contains("/kubesess/cache") { - continue; - } - let config: KubeConfig = get_config(s); - - configs.current_context = config.current_context; - configs.api_version = config.api_version; - configs.kind = config.kind; - configs.contexts.extend(config.contexts); - } - - let dir = format!("{}/.kube", dirs::home_dir().unwrap().display()); - for entry in fs::read_dir(dir).unwrap() { - let path = entry.unwrap().path(); - if let Some(extension) = path.extension() { - if extension == "yaml" { - let config: KubeConfig = get_config(path.to_str().unwrap()); - - configs.contexts.extend(config.contexts); - } - } - } - - configs -} - -fn get_config(path: &str) -> KubeConfig { - let f = File::open(path).unwrap(); - - let mut reader = BufReader::new(f); - let mut tmp = String::new(); - reader - .read_to_string(&mut tmp) - .expect("Unable to read file"); - - let config: KubeConfig = serde_yaml::from_str(tmp.trim()).unwrap(); - - config -} - -pub fn get_current_session() -> KubeConfig { - let current= if KUBESESSCONFIG.is_empty() { +pub fn get_current_session() -> Kubeconfig { + let current = if KUBESESSCONFIG.is_empty() { KUBECONFIG.split(':').next().unwrap() } else { KUBESESSCONFIG.as_str() }; - let f = File::open(current).unwrap(); - - let mut reader = BufReader::new(f); - let mut tmp = String::new(); - reader - .read_to_string(&mut tmp) - .expect("Unable to read file"); - - let config = serde_yaml::from_str(tmp.trim()).unwrap(); + let configs = get(Some(current)); - config + configs.config } diff --git a/src/error.rs b/src/error.rs index 53c430d..85f0714 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,15 +5,11 @@ pub enum Error { #[error("failed to set context: {0}")] SetContext(#[source] SetContextError), #[error("no item selected when prompted to select {prompt}")] - NoItemSelected { - prompt: &'static str - }, + NoItemSelected { prompt: &'static str }, } #[derive(Error, Debug)] pub enum SetContextError { #[error("no context exists with the name {ctx}")] - KubeContextNotFound { - ctx: String - }, + KubeContextNotFound { ctx: String }, } diff --git a/src/main.rs b/src/main.rs index a516cc2..06dc43b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,13 +1,15 @@ mod commands; mod config; -mod model; -mod modes; mod error; +mod modes; use crate::error::Error; use clap::Parser; +use std::collections::HashSet; use std::env; +use std::fs; use std::io; +use std::path; use std::process; #[macro_use] @@ -15,19 +17,35 @@ extern crate lazy_static; lazy_static! { static ref KUBECONFIG: String = { - match env::var("KUBECONFIG") { - Ok(val) => { - let mut paths: String = String::new(); - for s in val.split_inclusive(':') { - if s.contains("/kubesess/cache") { - continue; - } - paths.push_str(s); + + let mut paths_set = HashSet::new(); + let mut all_paths = Vec::new(); + + // Get paths from KUBECONFIG environment variable, preserving order + if let Ok(val) = env::var("KUBECONFIG") { + all_paths.extend(val.split(':').filter(|s| !s.contains("/kubesess/cache")).filter_map(|s| { + if paths_set.insert(s.to_string()) { + Some(s.to_string()) + } else { + None } - paths + })); + } + + // Collect paths from ~/.kube directory + if let Some(home_dir) = dirs::home_dir() { + let kube_dir = home_dir.join(".kube"); + if let Ok(entries) = fs::read_dir(&kube_dir) { + let kube_paths: Vec<_> = entries.filter_map(Result::ok).filter_map(|entry| { + let path = entry.path(); + path.to_str().map(|p| p.to_string()) + }).filter(|p| path::Path::new(p).is_file() && paths_set.insert(p.clone())).collect(); + + all_paths.extend(kube_paths); } - Err(_e) => format!("{}/.kube/config", dirs::home_dir().unwrap().display()), } + + all_paths.join(":") }; static ref KUBESESSCONFIG: String = { match env::var("KUBECONFIG") { @@ -71,7 +89,7 @@ enum Mode { } impl Mode { - fn invoke(&self) -> Result <(), Error> { + fn invoke(&self) -> Result<(), Error> { let args = Cli::parse(); match self { Mode::Namespace => modes::namespace(args), @@ -81,7 +99,7 @@ impl Mode { Mode::CompletionContext => { modes::completion_context(args); Ok(()) - }, + } Mode::CompletionNamespace => { modes::completion_namespace(args); Ok(()) diff --git a/src/model.rs b/src/model.rs deleted file mode 100644 index ed75048..0000000 --- a/src/model.rs +++ /dev/null @@ -1,31 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Default, PartialEq, Debug, Serialize, Deserialize)] -pub struct Contexts { - #[serde(default)] - pub context: Context, - #[serde(default)] - pub name: String, -} - -#[derive(Default, PartialEq, Debug, Serialize, Deserialize)] -pub struct Context { - #[serde(skip_serializing_if = "String::is_empty", default)] - pub namespace: String, - pub cluster: String, - pub user: String, -} - -#[derive(Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct KubeConfig { - #[serde(skip_serializing_if = "String::is_empty", default)] - pub kind: String, - #[serde(rename = "apiVersion")] - #[serde(skip_serializing_if = "String::is_empty", default)] - pub api_version: String, - #[serde(skip_serializing_if = "String::is_empty", default)] - #[serde(rename = "current-context")] - pub current_context: String, - #[serde(default)] - pub contexts: Vec, -} diff --git a/src/modes.rs b/src/modes.rs index eca8aaf..dd7874f 100644 --- a/src/modes.rs +++ b/src/modes.rs @@ -1,173 +1,236 @@ -use crate::{commands::{self}, config, error::Error, Cli, DEST, KUBECONFIG}; +use crate::{commands, config, error::Error, Cli, DEST, KUBECONFIG}; pub fn default_context(args: Cli) -> Result<(), Error> { - let config = config::get(); + let config = config::get(None); if args.current { - println!("{}", config.current_context); + println!( + "{}", + config + .config + .current_context + .as_deref() + .unwrap_or("No current context set") + ); return Ok(()); } let ctx = match args.value { None => { - let options : Vec = config.contexts.iter() + let options: Vec = config + .config + .contexts + .iter() .map(|context| context.name.to_string()) .collect(); - commands::selectable_list(options) - .ok_or(Error::NoItemSelected{prompt: "context" })? + commands::selectable_list(options).ok_or(Error::NoItemSelected { prompt: "context" })? } Some(x) => x.trim().to_string(), }; - commands::set_default_context(&ctx); - - let set_context_result = commands::set_context(&ctx, &DEST, &config) - .map_err(Error::SetContext); - - if set_context_result.is_ok() { - println!("{}", KUBECONFIG.as_str()); + if let Some(target) = config + .configs + .iter() + .find(|(kubeconfig, _)| { + kubeconfig + .contexts + .iter() + .any(|context| context.name == ctx) + }) + .map(|(_, path)| path.clone()) + { + commands::set_default_context(&ctx, &target); + // TODO: We should move the target to the front of the line instead of inserting a + // duplicate + println!("{}:{}", target.to_string_lossy(), KUBECONFIG.as_str()); } - set_context_result + Ok(()) } pub fn context(args: Cli) -> Result<(), Error> { + let current_session = config::get_current_session(); if args.current { - let config = config::get_current_session(); - println!("{}", config.current_context); + println!( + "{}", + current_session + .current_context + .as_deref() + .unwrap_or("No current context set") + ); return Ok(()); } - let config = config::get(); + let config = config::get(None); let ctx = match args.value { None => { - let options : Vec = config.contexts.iter() + let options: Vec = config + .config + .contexts + .iter() .map(|context| context.name.to_string()) .collect(); - commands::selectable_list(options) - .ok_or(Error::NoItemSelected{prompt: "context"})? + commands::selectable_list(options).ok_or(Error::NoItemSelected { prompt: "context" })? } Some(x) => x.trim().to_string(), }; - let set_context_result = commands::set_context(&ctx, &DEST, &config) - .map_err(Error::SetContext); + let set_context_result = + commands::set_context(&ctx, &DEST, ¤t_session).map_err(Error::SetContext); if set_context_result.is_ok() { println!( "{}/{}:{}", &DEST.as_str(), - str::replace(&ctx, ":", "_"), + str::replace(&set_context_result.unwrap(), ":", "_"), *KUBECONFIG ); } - set_context_result + Ok(()) } pub fn namespace(args: Cli) -> Result<(), Error> { let config = config::get_current_session(); + let current_ctx = &config + .current_context + .as_deref() + .unwrap_or("No current context set"); if args.current { - let ctx = config - .contexts - .iter() - .find(|x| x.name == config.current_context); - - match ctx { - Some(x) => { - if x.context.namespace.is_empty() { - println!("default"); - } else { - println!("{}", x.context.namespace); - } - } - None => println!("default"), + if let Some(ctx) = config.contexts.iter().find(|x| { + x.name + == config + .current_context + .as_deref() + .unwrap_or("No current context set") + }) { + let namespace = ctx + .context + .as_ref() + .and_then(|c| c.namespace.as_deref()) + .unwrap_or("default"); + + println!("{}", namespace); + } else { + println!("default"); } return Ok(()); } let ns = match args.value { None => { - let namespaces : Vec = commands::get_namespaces(); - commands::selectable_list(namespaces) - .ok_or(Error::NoItemSelected{prompt: "namespace"})? + let namespaces: Vec = commands::get_namespaces(); + commands::selectable_list(namespaces).ok_or(Error::NoItemSelected { + prompt: "namespace", + })? } Some(x) => x.trim().to_string(), }; - commands::set_namespace(&config.current_context, &ns, &DEST, &config); + let result = commands::set_namespace(current_ctx, &ns, &DEST, &config); println!( "{}/{}:{}", &DEST.as_str(), - str::replace(&config.current_context, ":", "_"), + str::replace(&result, ":", "_"), *KUBECONFIG ); Ok(()) } pub fn default_namespace(args: Cli) -> Result<(), Error> { - let config = config::get(); - let ctx = commands::get_current_context(); + let current_session = config::get_current_session(); + let config = config::get(None); + let ctx = ¤t_session + .current_context + .as_deref() + .unwrap_or("No current context set"); if args.current { - let ctx = config - .contexts - .iter() - .find(|x| x.name == config.current_context); - - match ctx { - Some(x) => { - if x.context.namespace.is_empty() { - println!("default"); - } else { - println!("{}", x.context.namespace); - } - } - None => println!("default"), + if let Some(ctx) = current_session.contexts.iter().find(|x| { + x.name + == current_session + .current_context + .as_deref() + .unwrap_or("No current context set") + }) { + let namespace = ctx + .context + .as_ref() + .and_then(|c| c.namespace.as_deref()) + .unwrap_or("default"); + + println!("{}", namespace); + } else { + println!("default"); } - return Ok(()); } let ns = match args.value { None => { - let namespaces : Vec = commands::get_namespaces(); - commands::selectable_list(namespaces) - .ok_or(Error::NoItemSelected{prompt: "namespace"})? + let namespaces: Vec = commands::get_namespaces(); + commands::selectable_list(namespaces).ok_or(Error::NoItemSelected { + prompt: "namespace", + })? } Some(x) => x.trim().to_string(), }; - commands::set_default_namespace(&ns, &ctx); - commands::set_namespace(&ctx, &ns, &DEST, &config); + if let Some(target) = config + .configs + .iter() + .find(|(kubeconfig, _)| { + kubeconfig + .contexts + .iter() + .any(|context| context.name == *ctx) + }) + .map(|(_, path)| path.clone()) + { + commands::set_default_namespace(&ns, ctx, &target); + } + + let result = commands::set_namespace(ctx, &ns, &DEST, ¤t_session); + println!( + "{}/{}:{}", + &DEST.as_str(), + str::replace(&result, ":", "_"), + *KUBECONFIG + ); + Ok(()) } pub fn completion_context(args: Cli) { - let config = config::get(); + let config = config::get(None); + + let search_value = args.value.as_deref().unwrap_or(""); + + let options: Vec = config + .config + .contexts + .iter() + .filter(|context| context.name.starts_with(search_value)) + .map(|context| context.name.clone()) + .collect(); - let mut options = Vec::new(); - for context in &config.contexts { - if context - .name - .starts_with(&args.value.as_ref().unwrap().to_string()) - { - options.push(context.name.to_string()); - } - } println!("{}", options.join(" ")); } pub fn completion_namespace(args: Cli) { let namespaces = commands::get_namespaces(); let mut options = Vec::new(); + + let search_value = args.value.as_deref().unwrap_or(""); + for ns in &namespaces { - if ns.starts_with(&args.value.as_ref().unwrap().to_string()) { + if ns.starts_with(search_value) { options.push(ns.to_string()); } } + println!("{}", options.join(" ")); } diff --git a/tests/cli.rs b/tests/cli.rs index 98a95d0..0332b26 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -1,62 +1,122 @@ use assert_cmd::prelude::*; -use std::{env, process::Command}; +use serial_test::serial; +use std::{env, fs::File, io::Write, process::Command}; +use tempfile::TempDir; + +fn setup_environment() -> (TempDir, String, String) { + // Create a temporary directory + let temp_dir = TempDir::new().expect("Failed to create temp directory"); + + // Set the HOME environment variable + env::set_var("HOME", temp_dir.path()); + + // Create a file named `config` inside the temporary directory + let kubeconfig_path = temp_dir.path().join("config"); + let mut kubeconfig_file = + File::create(&kubeconfig_path).expect("Failed to create kubeconfig file"); + + // Write the Kubernetes configuration content to the file + let kubeconfig_content = r#" +apiVersion: v1 +clusters: +- cluster: + server: https://kubernetes.docker.internal:6443 + name: docker-desktop +contexts: +- context: + cluster: docker-desktop + namespace: default + user: docker-desktop + name: docker-desktop +current-context: docker-desktop +kind: Config +preferences: {} +users: +- name: docker-desktop +"#; + kubeconfig_file + .write_all(kubeconfig_content.as_bytes()) + .expect("Failed to write kubeconfig content"); + + // Set the KUBECONFIG environment variable to point to the new file + env::set_var("KUBECONFIG", kubeconfig_path.to_str().unwrap()); + + // Return the temporary directory and paths for use in tests + let home_dir = temp_dir.path().to_str().unwrap().to_owned(); + let kubeconfig = kubeconfig_path.to_str().unwrap().to_owned(); + + (temp_dir, home_dir, kubeconfig) +} + +fn reset_environment() { + env::remove_var("HOME"); + env::remove_var("KUBECONFIG"); +} #[test] +#[serial] fn set_context() -> Result<(), Box> { - let expected: String = format!( - "{}/.kube/kubesess/cache/docker-desktop:{}", - dirs::home_dir().unwrap().display(), - env::var("KUBECONFIG").unwrap() - ); + let (_temp_dir, _home_dir, kubeconfig) = setup_environment(); + + let expected: String = format!("{}", kubeconfig); let mut cmd = Command::cargo_bin("kubesess")?; let output = cmd.arg("-v docker-desktop").arg("context").unwrap(); let output_string = String::from_utf8(output.stdout).unwrap().trim().to_owned(); - assert_eq!(output_string, expected); + + assert!(output_string.contains(&expected)); + reset_environment(); Ok(()) } #[test] +#[serial] fn set_default_context() -> Result<(), Box> { - let expected: String = env::var("KUBECONFIG").unwrap(); + let (_temp_dir, _home_dir, kubeconfig) = setup_environment(); + + let expected: String = format!("{}", kubeconfig); let mut cmd = Command::cargo_bin("kubesess")?; let output = cmd.arg("-v docker-desktop").arg("default-context").unwrap(); let output_string = String::from_utf8(output.stdout).unwrap().trim().to_owned(); - assert_eq!(output_string, expected); + assert!(output_string.contains(&expected)); + reset_environment(); Ok(()) } #[test] +#[serial] fn set_namespace() -> Result<(), Box> { - let expected: String = format!( - "{}/.kube/kubesess/cache/docker-desktop:{}", - dirs::home_dir().unwrap().display(), - env::var("KUBECONFIG").unwrap() - ); + let (_temp_dir, _home_dir, kubeconfig) = setup_environment(); + let expected: String = format!("{}", kubeconfig); let mut cmd = Command::cargo_bin("kubesess")?; let output = cmd.arg("-v default").arg("namespace").unwrap(); let output_string = String::from_utf8(output.stdout).unwrap().trim().to_owned(); - assert_eq!(output_string, expected); + assert!(output_string.contains(&expected)); Ok(()) } #[test] +#[serial] fn set_default_namespace() -> Result<(), Box> { + reset_environment(); + let (_temp_dir, _home_dir, kubeconfig) = setup_environment(); + let expected: String = format!("{}", kubeconfig); + let mut cmd = Command::cargo_bin("kubesess")?; let output = cmd.arg("-v default").arg("default-namespace").unwrap(); let output_string = String::from_utf8(output.stdout).unwrap().trim().to_owned(); - assert_eq!(output_string, format!("")); + assert!(output_string.contains(&expected)); Ok(()) }