1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

kubernetes: normalize-column-names (#518)

The column names are uppercase and spaces by default, which is inconvenient for subsequent operations and converted to lowercase and underscores

Co-authored-by: agent <agent@nuc>
This commit is contained in:
fj0r 2023-05-31 19:28:25 +08:00 committed by GitHub
parent 4a1b4c73c2
commit ab881a61d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,16 @@ export def ensure-cache-by-lines [cache path action] {
(open $cache).payload
}
export def normalize-column-names [ ] {
let i = $in
let cols = ($i | columns)
mut t = $i
for c in $cols {
$t = ($t | rename -c [$c ($c | str downcase | str replace ' ' '_')])
}
$t
}
def sprb [flag, args] {
if $flag {
$args
@ -443,10 +453,11 @@ export def kg [
spec: $x.spec
}
}
| normalize-column-names
} else if $watch {
kubectl get $n $k $r $l $wide --watch
} else {
kubectl get $n $k $r $l $wide | from ssv -a
kubectl get $n $k $r $l $wide | from ssv -a | normalize-column-names
}
} else {
kubectl get $n $k $r $"--output=jsonpath={($jsonpath)}" | from json