You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
980 B
Plaintext

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
}