Thanks Allen!

It turns out that docker build options look unmodifiable? If so, I followed the DOCKER_EXTRAENVS pattern in YETUS-919 to add a function add_docker_build_arg. Is this a reasonable approach and should I look to do any BATS testing or the like?

-Clay

On Wed, 9 Oct 2019, Allen Wittenauer wrote:



On Oct 9, 2019, at 5:53 PM, Clay B. <c...@clayb.net> wrote:
I am trying to add entries to DOCKER_EXTRAARGS from a yetus-personality 
script[2] (or anywhere I can) but I can not seem to affect the 
DOCKER_EXTRAARGS[3] actually used by the Docker test-patch code. For reference, 
I have moved Ratis to use Yetus 0.11.0 in my tests[4].

        There have been a lot of recent-ish changes to abstract out some of the 
internal plumbing of Yetus' docker support since for a time there it was 
undergoing major renovation and there were a ton of edge-case bugs.  As a 
result, there are two key functions that you need to know about to make this 
work:

        (name)_docker_support is something that plugins and personalities 
should absolutely define if they need any sort of special docker handling.     
Anything defined outside of that may not make it through the rabbit hole.  For 
your particular use case, set the project name to ratis then you'll be able to 
define ratis_docker_support.   Inside that you should be able to modify the 
docker bits safely and they should make it through.

        If you just need to pass an env var, use add_docker_env (variable 
name).  That will take care of the docker -e, etc, stuff. If you want to pass a 
file or need to do something more complex, alas, you'll still need to do the 
DOCKER_EXTRAARGS work manually.  You can see an example in maven.sh:

====

function maven_docker_support
{
 DOCKER_EXTRAARGS+=("-v" "${HOME}/.m2:/home/${USER_NAME}/.m2")

 if [[ ${MAVEN_CUSTOM_REPOS} = true ]]; then
   DOCKER_EXTRAARGS+=("-v" 
"${MAVEN_CUSTOM_REPOS_DIR}:${MAVEN_CUSTOM_REPOS_DIR}")
 fi

 add_docker_env MAVEN_OPTS
}

===

Note that this is an array using += notation in order to avoid wiping it out 
and that each parameter is a separate entry in the array.  (IFS safe!)

Is there a flow diagram for how Yetus loads its various shell files or a 
function call diagram to understand why changing something in 
personality_globals (or simply the personality script outside any function) 
would not globally affect scope for Docker pre-commit? (Or to know where I 
should set DOCKER_EXTRAARGS?)

http://yetus.apache.org/documentation/0.11.0/precommit-advanced/ covers 
docker_support but it's not really spelled out that setting these things from 
outside that function generally won't work. :( Sorry. :(  Definitely a doc bug. 
 I've been rewriting the docs off and on for the past few months, so if you 
file a jira, I'll be sure to remember to clarify that.


Reply via email to