Skip to content

Commit 9264aa9

Browse files
committed
Add fallback to get console to containers until remove SSH command
1 parent c912807 commit 9264aa9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

.led/plugins/ssh.plugin.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ ssh_in() {
101101
done
102102

103103
if [ -z "$server" ]; then
104+
fallback_deprecated_ssh "$user" "$server" "$@"
104105
help ssh
105106
exit
106107
fi
@@ -121,11 +122,30 @@ ssh_in() {
121122
fi
122123
command ssh "${ssh_remote}" -F "${SSH_PLUGIN_CACHE_CONFIG}"
123124
else
125+
fallback_deprecated_ssh "$user" "$server" "$@"
124126
echo "Can't find server named $server"
125127
exit 1
126128
fi
127129
}
128130

131+
# If ssh command is known as deprecated yet, fallback to docker exec
132+
fallback_deprecated_ssh() {
133+
if key_in_array "ssh" in DEPRECATED_COMMANDS; then
134+
135+
echo "Warning: Deprecated command. Please use led in to get console on container or install ssh plugin to connect servers."
136+
137+
# get command from remaining arguments
138+
local user=${1:-"dev"}
139+
shift
140+
local server=${1:-"apache"}
141+
shift
142+
local cmd=${*:-$cmd}
143+
144+
_docker_exec "${user}" "${server}" "${cmd}"
145+
fi
146+
return 0
147+
}
148+
129149
# Generate single file with all ssh config files founds
130150
ssh_do_cache() {
131151
local sshconfig=(.led/sshconfig "${HOME}"/.led/sshconfig "${SCRIPT_DIR}"/etc/sshconfig)

0 commit comments

Comments
 (0)