Skip to content

Commit f599a8c

Browse files
ndeloofglours
authored andcommitted
add support for extra_hosts building with bake
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent 63b06f5 commit f599a8c

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

pkg/compose/build_bake.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ type bakeTarget struct {
114114
Ulimits []string `json:"ulimits,omitempty"`
115115
Call string `json:"call,omitempty"`
116116
Entitlements []string `json:"entitlements,omitempty"`
117+
ExtraHosts map[string]string `json:"extra-hosts,omitempty"`
117118
Outputs []string `json:"output,omitempty"`
118119
}
119120

@@ -223,6 +224,7 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
223224
ShmSize: build.ShmSize,
224225
Ulimits: toBakeUlimits(build.Ulimits),
225226
Entitlements: entitlements,
227+
ExtraHosts: toBakeExtraHosts(build.ExtraHosts),
226228

227229
Outputs: outputs,
228230
Call: call,
@@ -373,6 +375,14 @@ func (s *composeService) doBuildBake(ctx context.Context, project *types.Project
373375
return results, nil
374376
}
375377

378+
func toBakeExtraHosts(hosts types.HostsList) map[string]string {
379+
m := make(map[string]string)
380+
for k, v := range hosts {
381+
m[k] = strings.Join(v, ",")
382+
}
383+
return m
384+
}
385+
376386
func additionalContexts(contexts types.Mapping, targets map[string]string) map[string]string {
377387
ac := map[string]string{}
378388
for k, v := range contexts {

0 commit comments

Comments
 (0)