Compare commits

..

4 Commits

Author SHA1 Message Date
Buddy
c3efa7d60e Merge branch 'main' of git.buddy.wtf:buddy/dot-files 2025-01-22 11:08:59 -08:00
Buddy
bc9b1b6ab2 Update work config 2025-01-22 11:08:47 -08:00
Buddy
e5db9cbf71 Add modules to make it easier to inspect state of gcloud and k8s 2025-01-22 10:54:05 -08:00
Buddy
38dcb5cf4f Add tmux inspect sessions 2025-01-21 10:46:27 -08:00
6 changed files with 674 additions and 554 deletions

View File

@ -5,6 +5,7 @@ source xdg.nu
use themes.nu
use completions *
use inspect
#{{- if eq .age_key "age1htqslfl4d5uv76j8eg49u9njqjx5udj9jmg3ujf2gxjjm06z0vqqwz6tlm" }}
overlay use work
#{{- end }}

View File

@ -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 } }
}

View File

@ -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
}

View File

@ -0,0 +1,3 @@
export use gcloud.nu
export use k8s.nu
export use tmux.nu

View File

@ -0,0 +1,15 @@
# list of tmux sessions
export def sessions []: [
nothing -> table<record<
name: string
id: string
attached: number
windows: number
attached_list: list<string>
>>
] {
tmux list-sessions -F "#{session_name}\t#{session_id}\t#{session_windows}\t#{session_attached}\t#{session_attached_list}"
| from tsv --noheaders
| rename name id windows attached attached_list
| update attached_list { split row , }
}

File diff suppressed because it is too large Load Diff