Fix broken windows 10 remote cli

Kubectl and helm commands didn't properly work under
Windows 10 by using remote CLI.

Changes included:
- add winpty dependency for windows 10 to properly use
  interactive prompt commands
- change Unix paths to full Windows paths to be passed
  to docker only if scripts are run under cygwin
- add information to README file about the new dependency

Change-Id: I4509941e051552133a77dd5c2a7922b2cade3858
Closes-bug: 1849131
Signed-off-by: Stefan Dinescu <stefan.dinescu@windriver.com>
This commit is contained in:
Stefan Dinescu 2019-10-24 14:33:05 +03:00
parent 63d1a87a6c
commit 9a068d8d6f
2 changed files with 34 additions and 6 deletions

View File

@ -26,6 +26,15 @@ are pulled automatically by the client scripts.
For instructions on how to install Docker for your system please
follow instructions at the following link: https://docs.docker.com/install/
On Windows, cygwin and winpty need to be installed as well.
Follow instruction on how to install cygwin at: https://www.cygwin.com/
For winpty, download the latest release tarball for cygwin
at https://github.com/rprichard/winpty/releases
After downloading the tarball, extract it to any location and change the
Windows PATH variable to include "bin" folder from the extracted
winpty folder
Using the Remote CLI Clients on a Linux machine:
------------------------------------------------

View File

@ -8,13 +8,25 @@
KUBE_CFG_PATH="/root/.kube/config"
SHELL_TYPE=$(uname -s)
if [[ "$CONFIG_TYPE" = "platform" ]]; then
CLIENT_IMAGE_NAME="docker.io/starlingx/stx-platformclients:${PLATFORM_DOCKER_IMAGE_TAG}"
# We only need to configure the kubernetes authentication file on the platform container
VOLUME_LIST="--volume ${OSC_WORKDIR}:/wd --volume ${K8S_CONFIG_FILE}:${KUBE_CFG_PATH}"
if [[ "${SHELL_TYPE}" == *"CYGWIN"* ]]; then
# On Windows 10, native docker needs the full windows path, not the UNIX one,
# so we pass the UNIX path through cygpath
VOLUME_LIST="--volume $(cygpath -m ${OSC_WORKDIR}):/wd --volume $(cygpath -m ${K8S_CONFIG_FILE}):${KUBE_CFG_PATH}"
else
VOLUME_LIST="--volume ${OSC_WORKDIR}:/wd --volume ${K8S_CONFIG_FILE}:${KUBE_CFG_PATH}"
fi
else
CLIENT_IMAGE_NAME="docker.io/starlingx/stx-openstackclients:${APPLICATION_DOCKER_IMAGE_TAG}"
VOLUME_LIST="--volume ${OSC_WORKDIR}:/wd"
if [[ "${SHELL_TYPE}" == *"CYGWIN"* ]]; then
VOLUME_LIST="--volume $(cygpath -m ${OSC_WORKDIR}):/wd"
else
VOLUME_LIST="--volume ${OSC_WORKDIR}:/wd"
fi
fi
# Environment variables related to keystone authentication
@ -49,13 +61,20 @@ if [[ "$FORCE_SHELL" == "true" ]] && [[ "$FORCE_NO_SHELL" == "true" ]]; then
exit 1
fi
if [[ "${SHELL_TYPE}" == *"CYGWIN"* ]]; then
# To fully support interactive shell in docker under cygwin
# we need to prefix the docker command with winpty
SHELL_COMMAND="winpty docker"
else
SHELL_COMMAND="docker"
fi
if [[ "$FORCE_SHELL" == "true" ]]; then
exec docker run --rm -ti ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@"
exec ${SHELL_COMMAND} run --rm -ti ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@"
elif [[ "$FORCE_NO_SHELL" == "true" ]]; then
exec docker run --rm -t ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@"
exec ${SHELL_COMMAND} run --rm -t ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@"
elif [ -z "$2" ]; then
exec docker run --rm -ti ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@"
exec ${SHELL_COMMAND} run --rm -ti ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@"
else
exec docker run --rm -t ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@"
exec ${SHELL_COMMAND} run --rm -t ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@"
fi