Add modules to make it easier to inspect state of gcloud and k8s
parent
38dcb5cf4f
commit
e5db9cbf71
@ -0,0 +1,8 @@
|
||||
export def configurations []: [
|
||||
nothing -> table<record<name: string active: bool account: string zone: string region: string>>
|
||||
] {
|
||||
gcloud config configurations list
|
||||
| detect columns
|
||||
| rename name active account project zone region
|
||||
| each { update active { $in == True } }
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
export def namespaces [] {
|
||||
# nothing -> table<record<name: string namespace: string active: string age: string>>
|
||||
#] {
|
||||
kubectl get namespaces | detect columns | rename name status age
|
||||
}
|
||||
|
||||
export def services [
|
||||
--namespace: string@"complete namespaces"
|
||||
--service: string@"complete services"
|
||||
] {
|
||||
let args = [
|
||||
( if $namespace != null {
|
||||
[ $"--namespace=($namespace)" ]
|
||||
} else {
|
||||
[ $"--all-namespaces" ]
|
||||
} )
|
||||
] | flatten
|
||||
|
||||
kubectl get services ...$args -o yaml
|
||||
| from yaml
|
||||
| get items
|
||||
| each { {
|
||||
name: $in.metadata.name
|
||||
namespace: $in.metadata.namespace
|
||||
ports: $in.spec.ports
|
||||
selector: $in.spec.selector?
|
||||
} }
|
||||
| where selector != null
|
||||
| where name == $service or $service == null
|
||||
}
|
||||
|
||||
export def "complete namespaces" []: nothing -> list<string> {
|
||||
namespaces | get name
|
||||
}
|
||||
|
||||
export def "complete services" []: nothing -> list<string> {
|
||||
services | get name
|
||||
}
|
@ -1 +1,3 @@
|
||||
export use gcloud.nu
|
||||
export use k8s.nu
|
||||
export use tmux.nu
|
||||
|
Loading…
Reference in New Issue