refactor: unify command declaration across codebase

This commit is contained in:
Jose Diaz-Gonzalez
2020-02-10 01:40:30 -05:00
parent b0abeb49dd
commit e67b96780d
108 changed files with 475 additions and 315 deletions

View File

@@ -4,7 +4,9 @@ set -eo pipefail
cmd-list-ssh-keys() {
declare desc="List ssh key hashes"
local cmd="ssh-keys:list"
declare cmd="ssh-keys:list"
[[ "$1" == "$cmd" ]] && shift 1
verify_ssh_key_file
sshcommand list dokku
}

View File

@@ -6,10 +6,11 @@ source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions"
cmd-ssh-keys-add() {
declare desc="add a new key via sshcommand"
local cmd="ssh-keys:add"
declare cmd="ssh-keys:add"
[[ "$1" == "$cmd" ]] && shift 1
declare NAME="$1" KEY_FILE="$2"
local TMP_KEY_FILE
TMP_KEY_FILE=$(mktemp "/tmp/dokku-${DOKKU_PID}-${FUNCNAME[0]}.XXXXXX")
trap "rm -rf '$TMP_KEY_FILE' >/dev/null" RETURN INT TERM EXIT

View File

@@ -6,12 +6,13 @@ source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions"
cmd-ssh-keys-remove() {
declare desc="Removes key from authorized_keys"
local cmd="ssh-keys:remove"
shift
local name="$1"
declare cmd="ssh-keys:remove"
[[ "$1" == "$cmd" ]] && shift 1
declare NAME="$1"
verify_ssh_key_file
[[ -z $1 ]] && dokku_log_fail "A name is required to remove a key, ie: dokku ssh-keys:remove <name>"
sshcommand acl-remove dokku "$name" || dokku_log_fail "sshcommand returned an error $?"
[[ -z "$NAME" ]] && dokku_log_fail "A name is required to remove a key, ie: dokku ssh-keys:remove <name>"
sshcommand acl-remove dokku "$NAME" || dokku_log_fail "sshcommand returned an error $?"
}
cmd-ssh-keys-remove "$@"