summaryrefslogtreecommitdiff
path: root/plugins/juju/juju.plugin.zsh
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2023-11-04 18:38:46 -0700
committerTuowen Zhao <ztuowen@gmail.com>2023-11-04 18:38:46 -0700
commit4d908094fdc2a0c0e9a0a072eba213fab7adef43 (patch)
tree7c17e70bcdeebbe96c84d849bdf17882007480d8 /plugins/juju/juju.plugin.zsh
parent4b0bbc0b263a150eb9a9b59f196914629be06a9b (diff)
parent632ed413a9ce62747ded83d7736491b081be4b49 (diff)
downloadzsh-master.tar.gz
zsh-master.tar.bz2
zsh-master.zip
Merge remote-tracking branch 'github/master'HEADmaster
Diffstat (limited to 'plugins/juju/juju.plugin.zsh')
-rw-r--r--plugins/juju/juju.plugin.zsh32
1 files changed, 31 insertions, 1 deletions
diff --git a/plugins/juju/juju.plugin.zsh b/plugins/juju/juju.plugin.zsh
index be8a2c7ae..0c60e35ce 100644
--- a/plugins/juju/juju.plugin.zsh
+++ b/plugins/juju/juju.plugin.zsh
@@ -163,10 +163,40 @@ jreld() {
juju run "relation-get -r $relid - $2" --unit $2/$3
}
+# Return Juju current controller
+jcontroller() {
+ local controller="$(awk '/current-controller/ {print $2}' ~/.local/share/juju/controllers.yaml)"
+ if [[ -z "$controller" ]]; then
+ return 1
+ fi
+
+ echo $controller
+ return 0
+}
+
+# Return Juju current model
+jmodel() {
+ local yqbin="$(whereis yq | awk '{print $2}')"
+
+ if [[ -z "$yqbin" ]]; then
+ echo "--"
+ return 1
+ fi
+
+ local model="$(yq e ".controllers.$(jcontroller).current-model" < ~/.local/share/juju/models.yaml | cut -d/ -f2)"
+
+ if [[ -z "$model" ]]; then
+ echo "--"
+ return 1
+ fi
+
+ echo $model
+ return 0
+}
+
# Watch juju status, with optional interval (default: 5 sec)
wjst() {
local interval="${1:-5}"
shift $(( $# > 0 ))
watch -n "$interval" --color juju status --relations --color "$@"
}
-