[PATCH compass-ci 4/4] container: consider the situation that is no GITCACHE_HOST

When manually ./build in VM, the GITCACHE_HOST variable is not found. Signed-off-by: Hu XueJiao <huxuejiao1@huawei.com> --- container/crystal-shards/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/crystal-shards/Dockerfile b/container/crystal-shards/Dockerfile index 0c5713c..bdc5b66 100644 --- a/container/crystal-shards/Dockerfile +++ b/container/crystal-shards/Dockerfile @@ -7,7 +7,7 @@ MAINTAINER chief <taxcom@tom.com> ARG GITCACHE_HOST ARG GITCACHE_PORT -RUN [ -n "$GITCACHE_HOST" ] && echo -e "[url \"http://$GITCACHE_HOST:${GITCACHE_PORT:-5000}/\"]\n\tinsteadOf = https://" >> /etc/gitconfig +RUN [ -z "$GITCACHE_HOST" ] || echo -e "[url \"http://$GITCACHE_HOST:${GITCACHE_PORT:-5000}/\"]\n\tinsteadOf = https://" >> /etc/gitconfig copy shard.yml /usr/share/crystal/app/shard.yml -- 2.23.0

title: that is => there is or better: GITCACHE_HOST is undefined On Mon, Sep 28, 2020 at 05:58:54PM +0800, Hu Xuejiao wrote:
When manually ./build in VM, the GITCACHE_HOST variable is not found.
Signed-off-by: Hu XueJiao <huxuejiao1@huawei.com> --- container/crystal-shards/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/container/crystal-shards/Dockerfile b/container/crystal-shards/Dockerfile index 0c5713c..bdc5b66 100644 --- a/container/crystal-shards/Dockerfile +++ b/container/crystal-shards/Dockerfile @@ -7,7 +7,7 @@ MAINTAINER chief <taxcom@tom.com>
ARG GITCACHE_HOST ARG GITCACHE_PORT -RUN [ -n "$GITCACHE_HOST" ] && echo -e "[url \"http://$GITCACHE_HOST:${GITCACHE_PORT:-5000}/\"]\n\tinsteadOf = https://" >> /etc/gitconfig +RUN [ -z "$GITCACHE_HOST" ] || echo -e "[url \"http://$GITCACHE_HOST:${GITCACHE_PORT:-5000}/\"]\n\tinsteadOf = https://" >> /etc/gitconfig
They are equal logics? [ -n ...] && [ -z ...] || Thanks, Fengguang

On Mon, Sep 28, 2020 at 08:22:06PM +0800, Wu Fengguang wrote:
title: that is => there is
or better: GITCACHE_HOST is undefined
On Mon, Sep 28, 2020 at 05:58:54PM +0800, Hu Xuejiao wrote:
When manually ./build in VM, the GITCACHE_HOST variable is not found.
Signed-off-by: Hu XueJiao <huxuejiao1@huawei.com> --- container/crystal-shards/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/container/crystal-shards/Dockerfile b/container/crystal-shards/Dockerfile index 0c5713c..bdc5b66 100644 --- a/container/crystal-shards/Dockerfile +++ b/container/crystal-shards/Dockerfile @@ -7,7 +7,7 @@ MAINTAINER chief <taxcom@tom.com>
ARG GITCACHE_HOST ARG GITCACHE_PORT -RUN [ -n "$GITCACHE_HOST" ] && echo -e "[url \"http://$GITCACHE_HOST:${GITCACHE_PORT:-5000}/\"]\n\tinsteadOf = https://" >> /etc/gitconfig +RUN [ -z "$GITCACHE_HOST" ] || echo -e "[url \"http://$GITCACHE_HOST:${GITCACHE_PORT:-5000}/\"]\n\tinsteadOf = https://" >> /etc/gitconfig
They are equal logics?
[ -n ...] && [ -z ...] ||
I think the reason may be the follow: Because of the '-e' param, `[ -n ... ] &&`: if $GITCACHE_HOST is none, process will exit 1 `[ -z ... ] ||`: if $GITCACHE_HOST is none, process will keep executing. -------- Thanks Yu Chuan
Thanks, Fengguang

On Tue, Sep 29, 2020 at 09:49:14AM +0800, Yu Chuan wrote:
On Mon, Sep 28, 2020 at 08:22:06PM +0800, Wu Fengguang wrote:
title: that is => there is
or better: GITCACHE_HOST is undefined
On Mon, Sep 28, 2020 at 05:58:54PM +0800, Hu Xuejiao wrote:
When manually ./build in VM, the GITCACHE_HOST variable is not found.
Signed-off-by: Hu XueJiao <huxuejiao1@huawei.com> --- container/crystal-shards/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/container/crystal-shards/Dockerfile b/container/crystal-shards/Dockerfile index 0c5713c..bdc5b66 100644 --- a/container/crystal-shards/Dockerfile +++ b/container/crystal-shards/Dockerfile @@ -7,7 +7,7 @@ MAINTAINER chief <taxcom@tom.com>
ARG GITCACHE_HOST ARG GITCACHE_PORT -RUN [ -n "$GITCACHE_HOST" ] && echo -e "[url \"http://$GITCACHE_HOST:${GITCACHE_PORT:-5000}/\"]\n\tinsteadOf = https://" >> /etc/gitconfig +RUN [ -z "$GITCACHE_HOST" ] || echo -e "[url \"http://$GITCACHE_HOST:${GITCACHE_PORT:-5000}/\"]\n\tinsteadOf = https://" >> /etc/gitconfig
They are equal logics?
[ -n ...] && [ -z ...] ||
I think the reason may be the follow:
Because of the '-e' param,
echo "-e" is irrelevant here.
`[ -n ... ] &&`: if $GITCACHE_HOST is none, process will exit 1 `[ -z ... ] ||`: if $GITCACHE_HOST is none, process will keep executing.
That can be much better changelog. Xuejiao, would you include that? Real example: wfg@crystal ~/t% cat Dockerfile FROM debian RUN false wfg@crystal ~/t% docker build . Sending build context to Docker daemon 2.048kB Step 1/2 : FROM debian ---> d4e598e8f935 Step 2/2 : RUN false ---> Running in 534cd565f638 The command '/bin/sh -c false' returned a non-zero code: 1 Thanks, Fengguang
participants (3)
-
Hu Xuejiao
-
Wu Fengguang
-
Yu Chuan