From f103a78048a9c6b85655a9866c77bcdc4ec304de Mon Sep 17 00:00:00 2001 From: nash Date: Sun, 15 Sep 2024 16:17:30 +0800 Subject: [PATCH] Fix the issue of kcc cache invalidation. In previous versions, the column name generated by `select cluster.server` was `cluster_server`, which was later changed to `cluster.server`. To avoid such issues, rename `cluster.server` to `server`. --- modules/kubernetes/complete.nu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/kubernetes/complete.nu b/modules/kubernetes/complete.nu index 35ccb5c92..cdce4b510 100644 --- a/modules/kubernetes/complete.nu +++ b/modules/kubernetes/complete.nu @@ -5,13 +5,13 @@ export def "nu-complete kube ctx" [] { let k = (kube-config) let cache = ([$nu.data-dir 'cache' 'k8s'] | path join $'($k.path | path basename).json') let data = ensure-cache-by-lines $cache $k.path { || - let clusters = $k.data | get clusters | select name cluster.server + let clusters = $k.data | get clusters | select name cluster.server | rename name server let data = $k.data | get contexts | reduce -f {completion:[], mx_ns: 0, mx_cl: 0} {|x, a| let ns = if ($x.context.namespace? | is-empty) { '' } else { $x.context.namespace } let max_ns = $ns | str length - let cluster = $"($x.context.user)@($clusters | where name == $x.context.cluster | get cluster_server.0)" + let cluster = $"($x.context.user)@($clusters | where name == $x.context.cluster | first | get server)" let max_cl = $cluster | str length $a | upsert mx_ns (if $max_ns > $a.mx_ns { $max_ns } else $a.mx_ns)