diff --git a/dot_config/nushell/lib/inspect/gcloud.nu b/dot_config/nushell/lib/inspect/gcloud.nu new file mode 100644 index 0000000..ae7ccec --- /dev/null +++ b/dot_config/nushell/lib/inspect/gcloud.nu @@ -0,0 +1,8 @@ +export def configurations []: [ + nothing -> table> +] { + gcloud config configurations list + | detect columns + | rename name active account project zone region + | each { update active { $in == True } } +} diff --git a/dot_config/nushell/lib/inspect/k8s.nu b/dot_config/nushell/lib/inspect/k8s.nu new file mode 100644 index 0000000..80b9867 --- /dev/null +++ b/dot_config/nushell/lib/inspect/k8s.nu @@ -0,0 +1,38 @@ +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 +} diff --git a/dot_config/nushell/lib/inspect/mod.nu b/dot_config/nushell/lib/inspect/mod.nu index d3f3d44..0e96baa 100644 --- a/dot_config/nushell/lib/inspect/mod.nu +++ b/dot_config/nushell/lib/inspect/mod.nu @@ -1 +1,3 @@ +export use gcloud.nu +export use k8s.nu export use tmux.nu