Skip to content

Commit

Permalink
Add fallback to get console to containers until remove SSH command
Browse files Browse the repository at this point in the history
  • Loading branch information
dgaussin committed Dec 11, 2018
1 parent c912807 commit 9264aa9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .led/plugins/ssh.plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ ssh_in() {
done

if [ -z "$server" ]; then
fallback_deprecated_ssh "$user" "$server" "$@"
help ssh
exit
fi
Expand All @@ -121,11 +122,30 @@ ssh_in() {
fi
command ssh "${ssh_remote}" -F "${SSH_PLUGIN_CACHE_CONFIG}"
else
fallback_deprecated_ssh "$user" "$server" "$@"
echo "Can't find server named $server"
exit 1
fi
}

# If ssh command is known as deprecated yet, fallback to docker exec
fallback_deprecated_ssh() {
if key_in_array "ssh" in DEPRECATED_COMMANDS; then

echo "Warning: Deprecated command. Please use led in to get console on container or install ssh plugin to connect servers."

# get command from remaining arguments
local user=${1:-"dev"}
shift
local server=${1:-"apache"}
shift
local cmd=${*:-$cmd}

_docker_exec "${user}" "${server}" "${cmd}"
fi
return 0
}

# Generate single file with all ssh config files founds
ssh_do_cache() {
local sshconfig=(.led/sshconfig "${HOME}"/.led/sshconfig "${SCRIPT_DIR}"/etc/sshconfig)
Expand Down

0 comments on commit 9264aa9

Please sign in to comment.