export def namespaces [] { # nothing -> table> #] { 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 { namespaces | get name } export def "complete services" []: nothing -> list { services | get name }