yetus-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject yetus git commit: YETUS-347. change docker handler to use arrays
Date Tue, 29 Mar 2016 21:01:31 GMT
Repository: yetus
Updated Branches:
  refs/heads/YETUS-156 7355288fe -> ce914e458


YETUS-347. change docker handler to use arrays

Signed-off-by: Allen Wittenauer <aw@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/ce914e45
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/ce914e45
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/ce914e45

Branch: refs/heads/YETUS-156
Commit: ce914e4581ffd597ee711c84c00f45f6a653f136
Parents: 7355288
Author: Allen Wittenauer <aw@apache.org>
Authored: Tue Mar 29 13:17:19 2016 -0700
Committer: Allen Wittenauer <aw@apache.org>
Committed: Tue Mar 29 14:01:19 2016 -0700

----------------------------------------------------------------------
 .../in-progress/precommit-buildtools.md         |  2 +-
 precommit/core.d/docker.sh                      | 21 ++++++++---------
 .../test-patch-docker/launch-test-patch.sh      | 24 ++++++++++++--------
 precommit/test-patch.d/ant.sh                   |  2 +-
 precommit/test-patch.d/gradle.sh                |  2 +-
 precommit/test-patch.d/maven.sh                 |  5 ++--
 6 files changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/ce914e45/asf-site-src/source/documentation/in-progress/precommit-buildtools.md
----------------------------------------------------------------------
diff --git a/asf-site-src/source/documentation/in-progress/precommit-buildtools.md b/asf-site-src/source/documentation/in-progress/precommit-buildtools.md
index e800135..bf530ba 100644
--- a/asf-site-src/source/documentation/in-progress/precommit-buildtools.md
+++ b/asf-site-src/source/documentation/in-progress/precommit-buildtools.md
@@ -102,7 +102,7 @@ For example, the gradle build tool does not have a standard way to execute
check
 
 * pluginname\_docker\_support
 
-    - If this build tool requires extra settings on the `docker run` command line, this function
should be defined and write those options into a file called `${PATCH_DIR}/buildtool-docker-params.txt`.
 This is particularly useful for things like mounting volumes for repository caches.
+    - If this build tool requires extra settings on the `docker run` command line, this function
should be defined and add those options into an array called `${DOCKER_EXTRAARGS[@]}`. This
is particularly useful for things like mounting volumes for repository caches.
 
        **WARNING**: Be aware that directories that do not exist MAY be created by root by
Docker itself under certain conditions.  It is HIGHLY recommend that `pluginname_initialize`
be used to create the necessary directories prior to be used in the `docker run` command.
 

http://git-wip-us.apache.org/repos/asf/yetus/blob/ce914e45/precommit/core.d/docker.sh
----------------------------------------------------------------------
diff --git a/precommit/core.d/docker.sh b/precommit/core.d/docker.sh
index e0706a3..2d7f550 100755
--- a/precommit/core.d/docker.sh
+++ b/precommit/core.d/docker.sh
@@ -23,6 +23,8 @@ DOCKERFAIL="fallback,continue,fail"
 DOCKERSUPPORT=false
 DOCKER_ENABLE_PRIVILEGED=true
 
+declare -a DOCKER_EXTRAARGS
+
 ####
 #### IMPORTANT
 ####
@@ -531,7 +533,7 @@ function docker_run_image
     cleanup_and_exit 1
   fi
 
-  big_console_header "Building patch image: ${patchimagename}"
+  big_console_header "Building ${BUILDMODE} image: ${patchimagename}"
   start_clock
   # using the base image, make one that is patch specific
   dockercmd build \
@@ -564,14 +566,8 @@ PatchSpecificDocker
     cleanup_and_exit 1
   fi
 
-  if [[ -f "${PATCH_DIR}/buildtool-docker-params.txt" ]]; then
-    extraargs=$(cat "${PATCH_DIR}/buildtool-docker-params.txt")
-  else
-    extraargs=""
-  fi
-
   if [[ "${DOCKER_ENABLE_PRIVILEGED}" = true ]]; then
-    extraargs="${extraargs} --privileged "
+    DOCKER_EXTRAARGS=("--privileged" "${DOCKER_EXTRAARGS[@]}")
   fi
 
   client=$(docker_version Client)
@@ -579,9 +575,8 @@ PatchSpecificDocker
 
   dockerversion="Client=${client} Server=${server}"
   if [[ ${PATCH_DIR} =~ ^/ ]]; then
-    # shellcheck disable=SC2086
     exec "${DOCKERCMD}" run --rm=true -i \
-      ${extraargs} \
+      "${DOCKER_EXTRAARGS[@]}" \
       -v "${PWD}:/testptch/${PROJECT_NAME}" \
       -v "${PATCH_DIR}:/testptch/patchprocess" \
       -u "${USER_NAME}" \
@@ -596,9 +591,8 @@ PatchSpecificDocker
       --name "${containername}" \
       "${patchimagename}"
   else
-    # shellcheck disable=SC2086
     exec "${DOCKERCMD}" run --rm=true -i \
-      ${extraargs} \
+      "${DOCKER_EXTRAARGS[@]}" \
       -v "${PWD}:/testptch/${PROJECT_NAME}" \
       -u "${USER_NAME}" \
       -w "/testptch/${PROJECT_NAME}" \
@@ -612,6 +606,9 @@ PatchSpecificDocker
       --name "${containername}" \
       "${patchimagename}"
   fi
+
+  # this should never get reached, but we put it here just in case
+  cleanup_and_exit 1
 }
 
 ## @description  Switch over to a Docker container

http://git-wip-us.apache.org/repos/asf/yetus/blob/ce914e45/precommit/test-patch-docker/launch-test-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch-docker/launch-test-patch.sh b/precommit/test-patch-docker/launch-test-patch.sh
index aac0d21..a7b040c 100755
--- a/precommit/test-patch-docker/launch-test-patch.sh
+++ b/precommit/test-patch-docker/launch-test-patch.sh
@@ -14,6 +14,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+declare -a OVERWRITEARGS=("--reexec")
+
+OVERWRITEARGS=("${OVERWRITEARGS[@]}" "--dockermode")
+OVERWRITEARGS=("${OVERWRITEARGS[@]}" "--basedir=${BASEDIR}")
+
 cd "${BASEDIR}"
 
 if [[ -n ${JAVA_HOME}
@@ -25,6 +30,10 @@ fi
 if [[ -z ${JAVA_HOME} ]]; then
   JAVA_HOME=$(find /usr/lib/jvm/ -name "java-*" -type d | tail -1)
   export JAVA_HOME
+  if [[ -n "${JAVA_HOME}" ]]; then
+    OVERWRITEARGS=("${OVERWRITEARGS[@]}" "--java-home=${JAVA_HOME}")
+    echo "Setting ${JAVA_HOME} as the JAVA_HOME."
+  fi
 fi
 
 # Avoid out of memory errors in builds
@@ -35,9 +44,9 @@ export MAVEN_OPTS
 TESTPATCHMODE=${TESTPATCHMODE/--docker }
 TESTPATCHMODE=${TESTPATCHMODE%--docker}
 
-
-cd "${BASEDIR}"
 PATCH_DIR=$(cd -P -- "${PATCH_DIR}" >/dev/null && pwd -P)
+OVERWRITEARGS=("${OVERWRITEARGS[@]}" "--patch-dir=${PATCH_DIR}")
+OVERWRITEARGS=("${OVERWRITEARGS[@]}" "--user-plugins=${PATCH_DIR}/precommit/user-plugins")
 
 # if patch system is generic, then it's either a local
 # patch file or was in some other way not pulled from a bug
@@ -45,16 +54,11 @@ PATCH_DIR=$(cd -P -- "${PATCH_DIR}" >/dev/null && pwd -P)
 # test-patch where to find it.
 if [[ "${PATCH_SYSTEM}" = generic ]]; then
   cp -p "${PATCH_DIR}/patch" /testptch/extras/patch
-  patchfile="/testptch/extras/patch"
+  OVERWRITEARGS=("${OVERWRITEARGS[@]}" "/testptch/extras/patch")
 fi
 
 cd "${PATCH_DIR}/precommit/"
 #shellcheck disable=SC2086
 "${PATCH_DIR}/precommit/test-patch.sh" \
-   --reexec \
-   --dockermode ${TESTPATCHMODE} \
-   --basedir="${BASEDIR}" \
-   --patch-dir="${PATCH_DIR}" \
-   --java-home="${JAVA_HOME}" \
-   --user-plugins="${PATCH_DIR}/precommit/user-plugins" \
-   ${patchfile}
+   ${TESTPATCHMODE} \
+  "${OVERWRITEARGS[@]}"

http://git-wip-us.apache.org/repos/asf/yetus/blob/ce914e45/precommit/test-patch.d/ant.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/ant.sh b/precommit/test-patch.d/ant.sh
index 64c4067..61e13c9 100755
--- a/precommit/test-patch.d/ant.sh
+++ b/precommit/test-patch.d/ant.sh
@@ -200,5 +200,5 @@ function ant_builtin_personality_file_tests
 
 function ant_docker_support
 {
-  echo "-v ${HOME}/.ivy2:${HOME}/.ivy2" > "${PATCH_DIR}/buildtool-docker-params.txt"
+  DOCKER_EXTRAARGS=("${DOCKER_EXTRAARGS}" "-v" "${HOME}/.ivy2:${HOME}/.ivy2")
 }

http://git-wip-us.apache.org/repos/asf/yetus/blob/ce914e45/precommit/test-patch.d/gradle.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/gradle.sh b/precommit/test-patch.d/gradle.sh
index 57e023d..1f971fa 100755
--- a/precommit/test-patch.d/gradle.sh
+++ b/precommit/test-patch.d/gradle.sh
@@ -277,5 +277,5 @@ function gradle_builtin_personality_file_tests
 
 function gradle_docker_support
 {
-  echo "-v ${HOME}/.gradle:${HOME}/.gradle" > "${PATCH_DIR}/buildtool-docker-params.txt"
+  DOCKER_EXTRAARGS=("${DOCKER_EXTRAARGS[@]}" "-v" "${HOME}/.gradle:${HOME}/.gradle")
 }

http://git-wip-us.apache.org/repos/asf/yetus/blob/ce914e45/precommit/test-patch.d/maven.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/maven.sh b/precommit/test-patch.d/maven.sh
index 2e006c1..1a2a86b 100755
--- a/precommit/test-patch.d/maven.sh
+++ b/precommit/test-patch.d/maven.sh
@@ -554,11 +554,10 @@ function maven_precompile
 
 function maven_docker_support
 {
-  echo "-v ${HOME}/.m2:${HOME}/.m2" > "${PATCH_DIR}/buildtool-docker-params.txt"
+  DOCKER_EXTRAARGS=("${DOCKER_EXTRAARGS[@]}" "-v" "${HOME}/.m2:${HOME}/.m2")
 
   if [[ ${MAVEN_CUSTOM_REPOS} = true ]]; then
-    echo "-v ${MAVEN_CUSTOM_REPOS_DIR}:${MAVEN_CUSTOM_REPOS_DIR}" \
-      >> "${PATCH_DIR}/buildtool-docker-params.txt"
+    DOCKER_EXTRAARGS=("${DOCKER_EXTRAARGS[@]}" "-v" "${MAVEN_CUSTOM_REPOS_DIR}:${MAVEN_CUSTOM_REPOS_DIR}")
   fi
 }
 


Mime
View raw message