Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
5efcfc39
Unverified
Commit
5efcfc39
authored
Mar 23, 2023
by
Jose C. Massón
Committed by
GitHub
Mar 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(juju): add functions to get current controller and model (#11572)
parent
f9f01e48
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
README.md
plugins/juju/README.md
+2
-0
juju.plugin.zsh
plugins/juju/juju.plugin.zsh
+31
-1
No files found.
plugins/juju/README.md
View file @
5efcfc39
...
@@ -126,5 +126,7 @@ Naming convention:
...
@@ -126,5 +126,7 @@ Naming convention:
-
`jaddr <app_name> [unit_num]`
: display app or unit IP address.
-
`jaddr <app_name> [unit_num]`
: display app or unit IP address.
-
`jreld <relation_name> <app_name> <unit_num>`
: display app and unit relation data.
-
`jreld <relation_name> <app_name> <unit_num>`
: display app and unit relation data.
-
`jclean`
: destroy all controllers
-
`jclean`
: destroy all controllers
-
`jcontroller`
: display the controller your are connected to.
-
`jmodel`
: display the model your are connected to.
-
`wjst [interval_secs] [args_for_watch]`
: watch juju status, with optional interval
-
`wjst [interval_secs] [args_for_watch]`
: watch juju status, with optional interval
(default: 5s); you may pass additional arguments to
`watch`
.
(default: 5s); you may pass additional arguments to
`watch`
.
plugins/juju/juju.plugin.zsh
View file @
5efcfc39
...
@@ -163,10 +163,40 @@ jreld() {
...
@@ -163,10 +163,40 @@ jreld() {
juju run
"relation-get -r
$relid
-
$2
"
--unit
$2
/
$3
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)
# Watch juju status, with optional interval (default: 5 sec)
wjst
()
{
wjst
()
{
local
interval
=
"
${
1
:-
5
}
"
local
interval
=
"
${
1
:-
5
}
"
shift
$((
$#
>
0
))
shift
$((
$#
>
0
))
watch
-n
"
$interval
"
--color
juju status
--relations
--color
"
$@
"
watch
-n
"
$interval
"
--color
juju status
--relations
--color
"
$@
"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment