Skip to content

Commit

Permalink
Fix the issue of kcc cache invalidation.
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
nashvi committed Sep 15, 2024
1 parent 4ecb350 commit f103a78
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/kubernetes/complete.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f103a78

Please sign in to comment.