Skip to content

Commit

Permalink
Merge pull request #60 from groupon/pinata
Browse files Browse the repository at this point in the history
#2: Implements pinata forwarded keys for MacOS
  • Loading branch information
udondan authored Jun 8, 2018
2 parents 55b9d06 + 7ec3121 commit 4685ef2
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions silo/runner_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,37 @@ silo_ssh_config() {
#######################################
# Mounts location of a potentially forwarded ssh key and forwards the
# SSH_AUTH_SOCK env var
# As socket forwarding is still not supported on Docker 4 Mac, this function
# has support for pinata-ssh-mount. See:
# https://github.com/groupon/ansible-silo/issues/2
# Globals:
# SSH_AUTH_SOCK
# Arguments:
# None
# Returns:
# --env and --volume options for mounting and forwarding the SSH_AUTH_SOCK
#######################################

silo_ssh_key_forwarding() {
local auth_sock_link_dir auth_sock_dir return=""
local auth_sock_link_dir auth_sock_dir forwarding_status return=""

if [[ ! -z "${SSH_AUTH_SOCK}" ]]; then
if [[ -L "${SSH_AUTH_SOCK}" ]]; then
auth_sock_link_dir="$(dirname "$(cd "${SSH_AUTH_SOCK}" && pwd -P)")"
return+="--volume \"${auth_sock_link_dir}\":\"${auth_sock_link_dir}\" "
if command -v pinata-ssh-mount >/dev/null 2>&1; then
forwarding_status=$(docker inspect -f "{{.State.Running}}" pinata-sshd)
if [[ "$forwarding_status" == "true" ]]; then
return=$(pinata-ssh-mount)
fi
else
if [[ ! -z "${SSH_AUTH_SOCK}" ]]; then
if [[ -L "${SSH_AUTH_SOCK}" ]]; then
auth_sock_link_dir="$(dirname "$(cd "${SSH_AUTH_SOCK}" && pwd -P)")"
return+="--volume \"${auth_sock_link_dir}\":\"${auth_sock_link_dir}\" "
fi
auth_sock_dir="$(dirname "${SSH_AUTH_SOCK}")"
return+="--volume \"${auth_sock_dir}\":\"${auth_sock_dir}\" "
return+="--env SSH_AUTH_SOCK"
fi
auth_sock_dir="$(dirname "${SSH_AUTH_SOCK}")"
return+="--volume \"${auth_sock_dir}\":\"${auth_sock_dir}\" "
return+="--env SSH_AUTH_SOCK"
fi

echo "${return}"
}

Expand Down

0 comments on commit 4685ef2

Please sign in to comment.