Merge pull request #2619 from dokku/2356-ssh-keys-report
Refactor ssh-keys:default
This commit is contained in:
@@ -1,29 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
[[ " help ssh-keys:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
[[ " help ssh-keys:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/ssh-keys/internal-functions"
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
help | ssh-keys:help)
|
help | ssh-keys:help)
|
||||||
help_content_func () {
|
ssh_keys_help_cmd "$@"
|
||||||
declare desc="return ssh-keys plugin help content"
|
|
||||||
cat<<help_content
|
|
||||||
ssh-keys, Manage public ssh keys that are allowed to connect to Dokku
|
|
||||||
ssh-keys:list, List of all authorized dokku public ssh keys
|
|
||||||
ssh-keys:add <name> [/path/to/key], Add a new public key by pipe or path
|
|
||||||
ssh-keys:remove <name>, Remove SSH public key by name
|
|
||||||
help_content
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ $1 = "ssh-keys:help" ]] ; then
|
|
||||||
echo -e 'Usage: dokku ssh-keys[:COMMAND]'
|
|
||||||
echo ''
|
|
||||||
echo 'Manage public ssh keys that are allowed to connect to Dokku'
|
|
||||||
echo ''
|
|
||||||
echo 'Additional commands:'
|
|
||||||
help_content_func | sort | column -c2 -t -s,
|
|
||||||
else
|
|
||||||
help_content_func
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
|
|||||||
28
plugins/ssh-keys/internal-functions
Executable file
28
plugins/ssh-keys/internal-functions
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
|
ssh_keys_help_content_func() {
|
||||||
|
declare desc="return ssh-keys plugin help content"
|
||||||
|
cat<<help_content
|
||||||
|
ssh-keys:list, List of all authorized dokku public ssh keys
|
||||||
|
ssh-keys:add <name> [/path/to/key], Add a new public key by pipe or path
|
||||||
|
ssh-keys:remove <name>, Remove SSH public key by name
|
||||||
|
help_content
|
||||||
|
}
|
||||||
|
|
||||||
|
ssh_keys_help_cmd() {
|
||||||
|
if [[ $1 = "ssh-keys:help" ]] ; then
|
||||||
|
echo -e 'Usage: dokku ssh-keys[:COMMAND]'
|
||||||
|
echo ''
|
||||||
|
echo 'Manage public ssh keys that are allowed to connect to Dokku'
|
||||||
|
echo ''
|
||||||
|
echo 'Additional commands:'
|
||||||
|
ssh_keys_help_content_func | sort | column -c2 -t -s,
|
||||||
|
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
|
||||||
|
ssh_keys_help_content_func
|
||||||
|
else
|
||||||
|
cat<<help_desc
|
||||||
|
ssh-keys, Manage public ssh keys that are allowed to connect to Dokku
|
||||||
|
help_desc
|
||||||
|
fi
|
||||||
|
}
|
||||||
11
plugins/ssh-keys/subcommands/default
Normal file → Executable file
11
plugins/ssh-keys/subcommands/default
Normal file → Executable file
@@ -1,12 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_AVAILABLE_PATH/ssh-keys/internal-functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions"
|
|
||||||
|
|
||||||
ssh_keys_main_cmd() {
|
ssh_keys_help_cmd "$@"
|
||||||
declare desc="an alias for ssh-keys:list"
|
|
||||||
local cmd="ssh-keys"
|
|
||||||
list_ssh_keys
|
|
||||||
}
|
|
||||||
|
|
||||||
ssh_keys_main_cmd "$@"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user