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:
parent
4a1b4c73c2
commit
ab881a61d5
1 changed files with 12 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue