All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] tests/docker: support proxy / corporate firewall
Date: Mon, 6 Mar 2017 09:46:16 +0800	[thread overview]
Message-ID: <20170306014616.GB31251@lemon.lan> (raw)
In-Reply-To: <20170304191230.11296-1-f4bug@amsat.org>

On Sat, 03/04 16:12, Philippe Mathieu-Daudé wrote:
> if FTP_PROXY/HTTP_PROXY/HTTPS_PROXY standard environment variables available,
> pass them to the docker daemon to build images.
> this is required when building behind corporate proxy/firewall, but also help
> when using local cache server (ie: apt/yum).
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/docker/docker.py | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/tests/docker/docker.py b/tests/docker/docker.py
> index 9fd32ab5fa..02bf9363e1 100755
> --- a/tests/docker/docker.py
> +++ b/tests/docker/docker.py
> @@ -22,12 +22,16 @@ import argparse
>  import tempfile
>  import re
>  import signal
> +import string
>  from tarfile import TarFile, TarInfo
>  from StringIO import StringIO
>  from shutil import copy, rmtree
>  from pwd import getpwuid
>  
>  
> +FILTERED_ENV_NAMES = ['FTP_PROXY', 'HTTP_PROXY', 'HTTPS_PROXY']
> +
> +
>  DEVNULL = open(os.devnull, 'wb')
>  
>  
> @@ -272,6 +276,12 @@ class BuildCommand(SubCommand):
>                  _copy_binary_with_libs(args.include_executable,
>                                         docker_dir)
>  
> +            filtered_keys = map(string.upper, FILTERED_ENV_NAMES)
> +            filtered_keys += map(string.lower, FILTERED_ENV_NAMES)
> +            for filtered_key in filtered_keys:
> +                if filtered_key in os.environ.keys():
> +                    argv += ["--build-arg=" + filtered_key +
> +                                "=" + os.environ[filtered_key]]

Makes sense.

Could you simplify the above hunk as

    args += ["--build-arg=" + k + "=" + v for k, v in \
                os.environ.iteritems() if k.upper() in FILTERED_ENV_NAMES]

then 'import string' is not necessary.

Fam

>              dkr.build_image(tag, docker_dir, dockerfile,
>                              quiet=args.quiet, user=args.user, argv=argv)
>  
> -- 
> 2.11.0
> 
> 

      reply	other threads:[~2017-03-06  1:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-04 19:12 [Qemu-devel] [PATCH] tests/docker: support proxy / corporate firewall Philippe Mathieu-Daudé
2017-03-06  1:46 ` Fam Zheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170306014616.GB31251@lemon.lan \
    --to=famz@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=f4bug@amsat.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.