mirror of
https://github.com/dokku/dokku.git
synced 2025-12-16 20:17:44 +01:00
Rather than try and validate this out of band, depend on sshcommand for performing any such checks on the file. There isn't any need for dokku to duplicate this when listing the contents of the file.
38 lines
906 B
Bash
Executable File
38 lines
906 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eo pipefail
|
|
[[ $DOKKU_TRACE ]] && set -x
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
source "$PLUGIN_AVAILABLE_PATH/ssh-keys/functions"
|
|
|
|
cmd-ssh-keys-list() {
|
|
declare desc="List ssh key hashes"
|
|
declare cmd="ssh-keys:list"
|
|
[[ "$1" == "$cmd" ]] && shift 1
|
|
declare NAME="$1"
|
|
local FORMAT=text
|
|
if [[ "$NAME" == "--format" ]]; then
|
|
FORMAT="$2"
|
|
NAME="$3"
|
|
fi
|
|
|
|
if [[ "$FORMAT" != "text" ]] && [[ "$FORMAT" != "json" ]]; then
|
|
dokku_log_fail "Invalid output format specified, supported formats: json, text"
|
|
fi
|
|
|
|
if [[ "$FORMAT" == "text" ]]; then
|
|
FORMAT=""
|
|
fi
|
|
|
|
if [[ "$FORMAT" == "json" ]]; then
|
|
if [[ -n "$NAME" ]]; then
|
|
sshcommand list dokku "" "$FORMAT" | jq -cM "[.[] | select(.name == \"$NAME\")]"
|
|
else
|
|
sshcommand list dokku "" "$FORMAT"
|
|
fi
|
|
else
|
|
sshcommand list dokku "$NAME"
|
|
fi
|
|
}
|
|
|
|
cmd-ssh-keys-list "$@"
|