From 9870da385efc1db2ff6f4e4cd0b5904e05522cf4 Mon Sep 17 00:00:00 2001 From: barnett <576501057@qq.com> Date: Thu, 28 Feb 2019 18:19:08 +0800 Subject: [PATCH] [REV] support parse ARG variable value --- builder/build/dockerfile_build.go | 10 +++++++++- hack/contrib/docker/gateway/nginxtmp/tmpl/nginx.tmpl | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/builder/build/dockerfile_build.go b/builder/build/dockerfile_build.go index 77164c560..0943f6c53 100644 --- a/builder/build/dockerfile_build.go +++ b/builder/build/dockerfile_build.go @@ -27,6 +27,7 @@ import ( "github.com/docker/docker/api/types" "github.com/goodrain/rainbond/builder" "github.com/goodrain/rainbond/builder/sources" + "github.com/goodrain/rainbond/util" ) func dockerfileBuilder() (Build, error) { @@ -86,8 +87,10 @@ func (d *dockerfileBuild) Build(re *Request) (*Response, error) { }, nil } +//GetARGs get args and parse value func GetARGs(buildEnvs map[string]string) map[string]*string { - args := make(map[string]*string, 5) + args := make(map[string]*string) + argStr := make(map[string]string) for k, v := range buildEnvs { if strings.Replace(v, " ", "", -1) == "" { continue @@ -95,7 +98,12 @@ func GetARGs(buildEnvs map[string]string) map[string]*string { if ks := strings.Split(k, "ARG_"); len(ks) > 1 { value := v args[ks[1]] = &value + argStr[ks[1]] = value } } + for k, arg := range args { + value := util.ParseVariable(*arg, argStr) + args[k] = &value + } return args } diff --git a/hack/contrib/docker/gateway/nginxtmp/tmpl/nginx.tmpl b/hack/contrib/docker/gateway/nginxtmp/tmpl/nginx.tmpl index f4286cde2..b2f85b14e 100644 --- a/hack/contrib/docker/gateway/nginxtmp/tmpl/nginx.tmpl +++ b/hack/contrib/docker/gateway/nginxtmp/tmpl/nginx.tmpl @@ -101,7 +101,6 @@ http { server 0.0.0.1; # placeholder balancer_by_lua_block { - ngx.log(ngx.INFO, string.format("start balancer")) balancer.balance() } }