Add add-hosts to DockerBuild

Signed-off-by: dubo-dubon-duponey <dubodubonduponey+github@pm.me>
This commit is contained in:
dubo-dubon-duponey 2021-05-09 21:09:56 -07:00
parent 38200f556c
commit 53611be733
No known key found for this signature in database
GPG Key ID: C3B96779C681DA56
2 changed files with 20 additions and 0 deletions

View File

@ -849,6 +849,25 @@ func dockerBuildOpts(op *compiler.Value) (map[string]string, error) {
}
opts["target"] = tgr
}
if hosts := op.Lookup("hosts"); hosts.Exists() {
p := []string{}
fields, err := hosts.Fields()
if err != nil {
return nil, err
}
for _, host := range fields {
s, err := host.Value.String()
if err != nil {
return nil, err
}
p = append(p, host.Label()+"="+s)
}
if len(p) > 0 {
opts["add-hosts"] = strings.Join(p, ",")
}
}
if buildArgs := op.Lookup("buildArg"); buildArgs.Exists() {
fields, err := buildArgs.Fields()
if err != nil {

View File

@ -93,6 +93,7 @@ package op
buildArg?: [string]: string
label?: [string]: string
target?: string
hosts?: [string]: string
}
#WriteFile: {