@@ -26,9 +26,11 @@ import (
26
26
hmac "github.com/alexellis/hmac/v2"
27
27
)
28
28
29
- type builderConfig struct {
29
+ type buildConfig struct {
30
30
Image string `json:"image"`
31
+ Frontend string `json:"frontend,omitempty"`
31
32
BuildArgs map [string ]string `json:"buildArgs,omitempty"`
33
+ Platforms []string `json:"platforms,omitempty"`
32
34
}
33
35
34
36
type builderResult struct {
@@ -87,11 +89,13 @@ func PublishImage(image string, handler string, functionName string, language st
87
89
88
90
tarPath := path .Join (tempDir , "req.tar" )
89
91
90
- if err := makeTar (builderConfig {Image : imageName , BuildArgs : buildArgMap }, path .Join ("build" , functionName ), tarPath ); err != nil {
92
+ builderPlatforms := strings .Split (platforms , "," )
93
+
94
+ if err := makeTar (buildConfig {Image : imageName , BuildArgs : buildArgMap , Platforms : builderPlatforms }, path .Join ("build" , functionName ), tarPath ); err != nil {
91
95
return fmt .Errorf ("failed to create tar file for %s, error: %w" , functionName , err )
92
96
}
93
97
94
- res , err := callBuilder (tarPath , tempPath , remoteBuilder , functionName , payloadSecretPath )
98
+ res , err := callBuilder (tarPath , remoteBuilder , functionName , payloadSecretPath )
95
99
if err != nil {
96
100
return err
97
101
}
@@ -200,7 +204,7 @@ func applyTag(index int, baseImage, tag string) string {
200
204
return fmt .Sprintf ("%s:%s" , baseImage [:index ], tag )
201
205
}
202
206
203
- func makeTar (buildConfig builderConfig , base , tarPath string ) error {
207
+ func makeTar (buildConfig buildConfig , base , tarPath string ) error {
204
208
configBytes , _ := json .Marshal (buildConfig )
205
209
if err := os .WriteFile (path .Join (base , BuilderConfigFilename ), configBytes , 0664 ); err != nil {
206
210
return err
@@ -251,7 +255,7 @@ func makeTar(buildConfig builderConfig, base, tarPath string) error {
251
255
return err
252
256
}
253
257
254
- func callBuilder (tarPath , tempPath , builderAddress , functionName , payloadSecretPath string ) (* http.Response , error ) {
258
+ func callBuilder (tarPath , builderAddress , functionName , payloadSecretPath string ) (* http.Response , error ) {
255
259
256
260
payloadSecret , err := os .ReadFile (payloadSecretPath )
257
261
if err != nil {
@@ -280,7 +284,7 @@ func callBuilder(tarPath, tempPath, builderAddress, functionName, payloadSecretP
280
284
r .Header .Set ("X-Build-Signature" , "sha256=" + hex .EncodeToString (digest ))
281
285
r .Header .Set ("Content-Type" , "application/octet-stream" )
282
286
283
- log .Printf ("%s invoking the API for build at %s " , functionName , builderAddress )
287
+ log .Printf ("%s invoking the API for build at %s" , functionName , builderAddress )
284
288
res , err := http .DefaultClient .Do (r )
285
289
if err != nil {
286
290
return nil , err
0 commit comments