chezmoi init
This commit is contained in:
commit
530d6d7195
1176 changed files with 111325 additions and 0 deletions
132
dot_oh-my-zsh/plugins/juju/README.md
Normal file
132
dot_oh-my-zsh/plugins/juju/README.md
Normal file
|
@ -0,0 +1,132 @@
|
|||
# juju plugin
|
||||
|
||||
This plugin provides useful aliases and functions for [juju](https://juju.is/) (for TAB completion,
|
||||
refer to the [official repo](https://github.com/juju/juju/blob/develop/etc/bash_completion.d/juju)).
|
||||
|
||||
To use this plugin, add `juju` to the plugins array in your zshrc file.
|
||||
|
||||
```zsh
|
||||
plugins=(... juju)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
Naming convention:
|
||||
|
||||
- `!` suffix: `--force --no-wait -y`.
|
||||
- `ds` suffix: `--destroy-storage`.
|
||||
- `jsh` prefix means `juju show-*`.
|
||||
|
||||
### General
|
||||
|
||||
| Alias | Command | Description |
|
||||
|---------|---------------------------------------------|--------------------------------------------------------|
|
||||
| `j` | `juju` | The juju command |
|
||||
| `jcld` | `juju clouds` | Lists all clouds with registered credentials |
|
||||
| `jclda` | `juju clouds --all` | Lists all clouds available to Juju |
|
||||
| `jdl` | `juju debug-log --ms` | Display log, with millisecond resolution |
|
||||
| `jdlr` | `juju debug-log --ms --replay` | Replay entire log |
|
||||
| `jh` | `juju help` | Show help on a command or other topic |
|
||||
| `jshsl` | `juju show-status-log` | Output past statuses for the specified entity |
|
||||
| `jstj` | `juju status --format=json` | Show status in json format (more detailed) |
|
||||
| `jst` | `juju status --relations --color` | Show status, including relations, in color |
|
||||
| `jsts` | `juju status --relations --storage --color` | Show status, including relations and storage, in color |
|
||||
|
||||
### Bootstrap
|
||||
|
||||
| Alias | Command | Description |
|
||||
|---------|-------------------------------------|-------------------------------------------------------|
|
||||
| `jb` | `juju bootstrap` | Initializing a Juju cloud environment |
|
||||
| `jbng` | `juju bootstrap --no-gui` | Initializing a Juju cloud environment without GUI |
|
||||
| `jbl` | `juju bootstrap localhost` | Initializing an lxd cloud environment |
|
||||
| `jblng` | `juju bootstrap --no-gui localhost` | Initializing an lxd cloud environment without GUI |
|
||||
| `jbm` | `juju bootstrap microk8s` | Initializing a MicroK8s cloud environment |
|
||||
| `jbmng` | `juju bootstrap --no-gui microk8s` | Initializing a MicroK8s cloud environment without GUI |
|
||||
|
||||
### Controller
|
||||
|
||||
| Alias | Command | Description |
|
||||
|----------|---------------------------------------------------------------------------------------|-------------------------------------------------------------------|
|
||||
| `jctl` | `juju controllers` | List all controllers |
|
||||
| `jctlr` | `juju controllers --refresh` | List all controllers (download latest details) |
|
||||
| `jdc` | `juju destroy-controller --destroy-all-models` | Destroy a controller |
|
||||
| `jdc!` | `juju destroy-controller --destroy-all-models --force --no-wait -y` | Destroy a controller |
|
||||
| `jdcds` | `juju destroy-controller --destroy-all-models --destroy-storage` | Destroy a controller and associated storage |
|
||||
| `jdcds!` | `juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y` | Destroy a controller and associated storage |
|
||||
| `jkc` | `juju kill-controller -y -t 0` | Forcibly terminate all associated resources for a Juju controller |
|
||||
| `jshc` | `juju show-controller` | Shows detailed information of a controller |
|
||||
| `jsw` | `juju switch` | Select or identify the current controller and model |
|
||||
|
||||
### Model
|
||||
|
||||
| Alias | Command | Description |
|
||||
|----------|-------------------------------------------------------------|-------------------------------------------------------|
|
||||
| `jam` | `juju add-model` | Add a hosted model |
|
||||
| `jdm` | `juju destroy-model` | Non-recoverable, complete removal of a model |
|
||||
| `jdm!` | `juju destroy-model --force --no-wait -y` | Non-recoverable, complete removal of a model |
|
||||
| `jdmds` | `juju destroy-model --destroy-storage` | Non-recoverable, complete removal of a model |
|
||||
| `jdmds!` | `juju destroy-model --destroy-storage --force --no-wait -y` | Non-recoverable, complete removal of a model |
|
||||
| `jmc` | `juju model-config` | Display or set configuration values on a model |
|
||||
| `jm` | `juju models` | List models a user can access on a controller |
|
||||
| `jshm` | `juju show-model` | Show information about the current or specified model |
|
||||
| `jsw` | `juju switch` | Select or identify the current controller and model |
|
||||
|
||||
### Application / unit
|
||||
|
||||
| Alias | Command | Description |
|
||||
|----------|---------------------------------------------------------------|---------------------------------------------------------------------------|
|
||||
| `jc` | `juju config` | Get, set, or reset configuration for a deployed application |
|
||||
| `jde` | `juju deploy --channel=edge` | Deploy a new application or bundle from the edge channel |
|
||||
| `jd` | `juju deploy` | Deploy a new application or bundle |
|
||||
| `jra` | `juju run-action` | Queue an action for execution |
|
||||
| `jraw` | `juju run-action --wait` | Queue an action for execution and wait for results, with optional timeout |
|
||||
| `jrm` | `juju remove-application` | Remove application |
|
||||
| `jrm!` | `juju remove-application --force --no-wait` | Remove application forcefully |
|
||||
| `jrmds` | `juju remove-application --destroy-storage` | Remove application and destroy attached storage |
|
||||
| `jrmds!` | `juju remove-application --destroy-storage --force --no-wait` | Remove application forcefully, destroying attached storage |
|
||||
| `jrp` | `juju refresh --path` | Upgrade charm from local charm file |
|
||||
| `jsa` | `juju scale-application` | Set the desired number of application units |
|
||||
| `jssh` | `juju ssh` | Initiate an SSH session or execute a command on a Juju target |
|
||||
| `jsshc` | `juju ssh --container` | Initiate an SSH session or execute a command on a given container |
|
||||
| `jshu` | `juju show-unit` | Displays information about a unit |
|
||||
|
||||
### Storage
|
||||
|
||||
| Alias | Command | Description |
|
||||
|---------|-------------------------------|-------------------------------------------------|
|
||||
| `jrs` | `juju remove-storage` | Remove storage |
|
||||
| `jrs!` | `juju remove-storage --force` | Remove storage even if it is currently attached |
|
||||
|
||||
### Relation
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-----------|--------------------------------|-------------------------------------------------------------------|
|
||||
| `jrel` | `juju relate` | Relate two applications |
|
||||
| `jrmrel` | `juju remove-relation` | Remove an existing relation between two applications. |
|
||||
| `jrmrel!` | `juju remove-relation --force` | Remove an existing relation between two applications, forcefully. |
|
||||
|
||||
### Cross-model relation (CMR)
|
||||
|
||||
| Alias | Command | Description |
|
||||
|----------|--------------------|----------------------------------------------------------------|
|
||||
| `jex` | `juju expose` | Make an application publicly available over the network |
|
||||
| `jof` | `juju offer` | Offer application endpoints for use in other models |
|
||||
| `jcon` | `juju consume` | Add a remote offer to the model |
|
||||
| `jrmsas` | `juju remove-saas` | Remove consumed applications (SAAS) from the model |
|
||||
| `junex` | `juju unexpose` | Remove public availability over the network for an application |
|
||||
|
||||
### Bundle
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-------|----------------------|-------------------------------------------------------------|
|
||||
| `jeb` | `juju export-bundle` | Export the current model configuration as a reusable bundle |
|
||||
|
||||
## Functions
|
||||
|
||||
- `jaddr <app_name> [unit_num]`: display app or unit IP address.
|
||||
- `jreld <relation_name> <app_name> <unit_num>`: display app and unit relation data.
|
||||
- `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
|
||||
(default: 5s); you may pass additional arguments to `watch`.
|
202
dot_oh-my-zsh/plugins/juju/juju.plugin.zsh
Normal file
202
dot_oh-my-zsh/plugins/juju/juju.plugin.zsh
Normal file
|
@ -0,0 +1,202 @@
|
|||
# ---------------------------------------------------------- #
|
||||
# Aliases and functions for juju (https://juju.is) #
|
||||
# ---------------------------------------------------------- #
|
||||
|
||||
# Load TAB completions
|
||||
# You need juju's bash completion script installed. By default bash-completion's
|
||||
# location will be used (i.e. pkg-config --variable=completionsdir bash-completion).
|
||||
completion_file="$(pkg-config --variable=completionsdir bash-completion 2>/dev/null)/juju" || \
|
||||
completion_file="/usr/share/bash-completion/completions/juju"
|
||||
[[ -f "$completion_file" ]] && source "$completion_file"
|
||||
unset completion_file
|
||||
|
||||
# ---------------------------------------------------------- #
|
||||
# Aliases (in alphabetic order) #
|
||||
# #
|
||||
# Generally, #
|
||||
# - `!` means --force --no-wait -y #
|
||||
# - `ds` suffix means --destroy-storage #
|
||||
# - `jsh` prefix means juju show-* #
|
||||
# ---------------------------------------------------------- #
|
||||
alias j="juju"
|
||||
alias jam="juju add-model --config logging-config=\"<root>=WARNING; unit=DEBUG\"\
|
||||
--config update-status-hook-interval=\"60m\""
|
||||
alias jb='juju bootstrap'
|
||||
alias jbng='juju bootstrap --no-gui'
|
||||
alias jbl='juju bootstrap localhost'
|
||||
alias jblng='juju bootstrap --no-gui localhost'
|
||||
alias jbm='juju bootstrap microk8s'
|
||||
alias jbmng='juju bootstrap --no-gui microk8s'
|
||||
alias jc='juju config'
|
||||
alias jcld='juju clouds'
|
||||
alias jclda='juju clouds --all'
|
||||
alias jctl='juju controllers'
|
||||
alias jctlr='juju controllers --refresh'
|
||||
alias jdc='juju destroy-controller --destroy-all-models'
|
||||
alias 'jdc!'='juju destroy-controller --destroy-all-models --force --no-wait -y'
|
||||
alias jdcds='juju destroy-controller --destroy-all-models --destroy-storage'
|
||||
alias 'jdcds!'='juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y'
|
||||
alias jdm='juju destroy-model'
|
||||
alias 'jdm!'='juju destroy-model --force --no-wait -y'
|
||||
alias jdmds='juju destroy-model --destroy-storage'
|
||||
alias 'jdmds!'='juju destroy-model --destroy-storage --force --no-wait -y'
|
||||
alias jde='juju deploy --channel=edge'
|
||||
alias jd='juju deploy'
|
||||
alias jdl='juju debug-log --ms'
|
||||
alias jdlr='juju debug-log --ms --replay'
|
||||
alias jcon='juju consume'
|
||||
alias jeb='juju export-bundle'
|
||||
alias jex='juju expose'
|
||||
alias jh='juju help'
|
||||
alias jkc='juju kill-controller -y -t 0'
|
||||
alias jm='juju models'
|
||||
alias jmc='juju model-config'
|
||||
alias jof='juju offer'
|
||||
alias jra='juju run-action'
|
||||
alias jraw='juju run-action --wait'
|
||||
alias jrel='juju relate'
|
||||
alias jrm='juju remove-application'
|
||||
alias 'jrm!'='juju remove-application --force --no-wait'
|
||||
alias jrmds='juju remove-application --destroy-storage'
|
||||
alias 'jrmds!'='juju remove-application --destroy-storage --force --no-wait'
|
||||
alias jrmrel='juju remove-relation'
|
||||
alias 'jrmrel!'='juju remove-relation --force'
|
||||
alias jrmsas='juju remove-saas'
|
||||
alias jrp='juju refresh --path'
|
||||
alias jrs='juju remove-storage'
|
||||
alias 'jrs!'='juju remove-storage --force'
|
||||
alias jsa='juju scale-application'
|
||||
alias jsha='juju show-application'
|
||||
alias jshc='juju show-controller'
|
||||
alias jshm='juju show-model'
|
||||
alias jshsl='juju show-status-log'
|
||||
alias jshu='juju show-unit'
|
||||
alias jssh='juju ssh'
|
||||
alias jsshc='juju ssh --container'
|
||||
alias jstj='juju status --format=json'
|
||||
alias jst='juju status --relations --color'
|
||||
alias jsts='juju status --relations --storage --color'
|
||||
alias jsw='juju switch'
|
||||
|
||||
# ---------------------------------------------------------- #
|
||||
# Functions (in alphabetic order) #
|
||||
# ---------------------------------------------------------- #
|
||||
|
||||
# Get app or unit address
|
||||
jaddr() {
|
||||
# $1 = app name
|
||||
# $2 = unit number (optional)
|
||||
if (( ! ${+commands[jq]} )); then
|
||||
echo "jq is required but could not be found." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
# Get app address
|
||||
juju status "$1" --format=json \
|
||||
| jq -r ".applications.\"$1\".address"
|
||||
elif [[ $# -eq 2 ]]; then
|
||||
# Get unit address
|
||||
juju status "$1/$2" --format=json \
|
||||
| jq -r ".applications.\"$1\".units.\"$1/$2\" | .address // .\"public-address\""
|
||||
else
|
||||
echo "Invalid number of arguments."
|
||||
echo "Usage: jaddr <app-name> [<unit-number>]"
|
||||
echo "Example: jaddr karma"
|
||||
echo "Example: jaddr karma 0"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Destroy all controllers
|
||||
jclean() {
|
||||
if (( ! ${+commands[jq]} )); then
|
||||
echo "jq is required but could not be found." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local controllers=$(juju controllers --format=json | jq -r '.controllers | keys[]' 2>/dev/null)
|
||||
if [[ -z "$controllers" ]]; then
|
||||
echo "No controllers registered"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "This will forcefully destroy all storages, models and controllers."
|
||||
echo "Controllers to be destroyed:"
|
||||
echo "$controllers"
|
||||
|
||||
if ! read -q '?Are you sure (y/n)? '; then
|
||||
echo
|
||||
echo "Aborted."
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo
|
||||
for controller in ${=controllers}; do
|
||||
timeout 2m juju destroy-controller --destroy-all-models --destroy-storage --force --no-wait -y $controller
|
||||
timeout 2m juju kill-controller -y -t 0 $controller 2>/dev/null
|
||||
timeout 10s juju unregister $controller 2>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
# Display app and unit relation data
|
||||
jreld() {
|
||||
# $1 = relation name
|
||||
# $2 = app name
|
||||
# $3 = unit number
|
||||
if [[ $# -ne 3 ]]; then
|
||||
echo "Invalid number of arguments."
|
||||
echo "Usage: jreld <relation-name> <app-name> <unit-number>"
|
||||
echo "Example: jreld karma-dashboard alertmanager 0"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local relid="$(juju run "relation-ids $1" --unit $2/$3)"
|
||||
if [[ -z "$relid" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "App data:"
|
||||
juju run "relation-get -r $relid --app - $2" --unit $2/$3
|
||||
echo
|
||||
echo "Unit data:"
|
||||
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 "$@"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue