Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to use local scripts and configuration files in lieu of generated when using openshift ocp.sh script. #8156

Merged
merged 9 commits into from
Jan 17, 2018
33 changes: 25 additions & 8 deletions dockerfiles/init/modules/openshift/files/scripts/ocp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export JQ_BINARY_DOWNLOAD_URL=${JQ_BINARY_DOWNLOAD_URL:-${DEFAULT_JQ_BINARY_DOWN
DEFAULT_CHE_MULTIUSER="false"
export CHE_MULTIUSER=${CHE_MULTIUSER:-${DEFAULT_CHE_MULTIUSER}}

#Using local scripts is error prone and should only be used temporarly while developing Che.
#If unsure leave the default value true set.
DEFAULT_CHE_GENERATE_SCRIPTS=true
export CHE_GENERATE_SCRIPTS=${CHE_GENERATE_SCRIPTS:-${DEFAULT_CHE_REMOVE_PROJECT}}

DEFAULT_OPENSHIFT_USERNAME="developer"
export OPENSHIFT_USERNAME=${OPENSHIFT_USERNAME:-${DEFAULT_OPENSHIFT_USERNAME}}

Expand Down Expand Up @@ -153,15 +158,27 @@ run_ocp() {
}

deploy_che_to_ocp() {
#Repull init image only if IMAGE_PULL_POLICY is set to Always
if [ $IMAGE_PULL_POLICY == "Always" ]; then
docker pull "$IMAGE_INIT"
#Only generate scripts and config files if CHE_GENERATE_SCRIPTS=true
if [ $CHE_GENERATE_SCRIPTS == true ]; then
echo "OCP generating temporary scripts and configuration files at ${CONFIG_DIR}/instance/config/openshift/scripts/ ."
#Repull init image only if IMAGE_PULL_POLICY is set to Always
if [ $IMAGE_PULL_POLICY == "Always" ]; then
docker pull "$IMAGE_INIT"
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 +      if [ $IMAGE_PULL_POLICY == "Always" ]; then
 +         docker pull "$IMAGE_INIT"
 +      fi

this must be moved out from if statement because it should be considered in both cases

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved.

#wipeout config folder
docker run -v "${CONFIG_DIR}":/to_remove alpine sh -c "rm -rf /to_remove/" || true
docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock -v "${CONFIG_DIR}":/data -e IMAGE_INIT="$IMAGE_INIT" -e CHE_MULTIUSER="$CHE_MULTIUSER" eclipse/che-cli:${CHE_IMAGE_TAG} config --skip:pull --skip:nightly
cd "${CONFIG_DIR}/instance/config/openshift/scripts/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${CONFIG_DIR}/instance/config/openshift/scripts/ is used twice. Please consider moving it into a separated variable like OPENSHIFT_SCRIPTS_FOLDER

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added variable OPENSHIFT_SCRIPTS_FOLDER.

else
echo "OCP using existing scripts in current folder."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous message contains information about configuration files but this one doesn't. Should we add it here too?
To be sure that I understand configuration files correctly: is it about yaml files?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is shell scripts and yaml files needed to deploy che multi user

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added configuration files to second mesage.

fi
if [[ ! -f "deploy_che.sh" ]]; then
CURRENT_PWD=$(pwd)
echo "OCP script deploy_che.sh does not exist in ${CURRENT_PWD} ."
exit 1
else
bash deploy_che.sh ${DEPLOY_SCRIPT_ARGS}
fi
#wipeout config folder
docker run -v "${CONFIG_DIR}":/to_remove alpine sh -c "rm -rf /to_remove/" || true
docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock -v "${CONFIG_DIR}":/data -e IMAGE_INIT="$IMAGE_INIT" -e CHE_MULTIUSER="$CHE_MULTIUSER" ${CHE_CLI_IMAGE} config --skip:pull --skip:nightly
cd "${CONFIG_DIR}/instance/config/openshift/scripts/"
bash deploy_che.sh ${DEPLOY_SCRIPT_ARGS}
wait_until_server_is_booted
if [ $CHE_MULTIUSER == true ]; then
wait_until_kc_is_booted
Expand Down