mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-08-16 17:00:32 +03:00
parent
f04cb445e4
commit
e8f4d7462a
@ -713,6 +713,39 @@ export def ksdr [
|
||||
}
|
||||
|
||||
|
||||
def "nu-complete kube kind with image" [] {
|
||||
[
|
||||
deployment daemonset statefulset
|
||||
pod replicationcontroller
|
||||
cronjob replicaset
|
||||
]
|
||||
}
|
||||
|
||||
# kubectl set image
|
||||
export def ksi [
|
||||
k: string@"nu-complete kube kind with image"
|
||||
r: string@"nu-complete kube res"
|
||||
--namespace(-n): string@"nu-complete kube ns"
|
||||
act?: any
|
||||
] {
|
||||
let ns = $namespace | with-flag -n
|
||||
let path = match $k {
|
||||
_ => '.spec.template.spec.containers[*]'
|
||||
}
|
||||
let name = kubectl get ...$ns $k $r -o $"jsonpath={($path).name}" | split row ' '
|
||||
let image = kubectl get ...$ns $k $r -o $"jsonpath={($path).image}" | split row ' '
|
||||
let list = $name | zip $image | reduce -f {} {|it,acc| $acc | insert $it.0 $it.1 }
|
||||
if ($act | describe -d).type == 'closure' {
|
||||
let s = do $act $list
|
||||
if ($s | describe -d).type == 'record' {
|
||||
let s = $s | transpose k v | each {|x| $"($x.k)=($x.v)"}
|
||||
kubectl ...$ns set image $"($k)/($r)" ...$s
|
||||
}
|
||||
} else {
|
||||
$list
|
||||
}
|
||||
}
|
||||
|
||||
# kubectl redistribution deployment
|
||||
export def krd [
|
||||
d: string@"nu-complete kube deploys"
|
||||
|
Loading…
Reference in New Issue
Block a user