Skip to content

Commit 5837426

Browse files
csweichelroboquat
authored andcommitted
[image-builder] Pull digested base refs correctly
1 parent b6c0295 commit 5837426

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

components/image-builder-mk3/pkg/orchestrator/orchestrator.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"sync"
1818
"time"
1919

20+
"github.com/docker/distribution/reference"
2021
"github.com/google/uuid"
2122
"github.com/opentracing/opentracing-go"
2223
"github.com/sirupsen/logrus"
@@ -306,6 +307,17 @@ func (o *Orchestrator) Build(req *protocol.BuildRequest, resp protocol.ImageBuil
306307
return false
307308
}
308309

310+
pbaseref, err := reference.Parse(baseref)
311+
if err != nil {
312+
return xerrors.Errorf("cannot parse baseref: %v", err)
313+
}
314+
bobBaseref := "localhost:8080/base"
315+
if r, ok := pbaseref.(reference.Digested); ok {
316+
bobBaseref += "@" + r.Digest().String()
317+
} else {
318+
bobBaseref += ":latest"
319+
}
320+
309321
var swr *wsmanapi.StartWorkspaceResponse
310322
err = retry(ctx, func(ctx context.Context) (err error) {
311323
swr, err = o.wsman.StartWorkspace(ctx, &wsmanapi.StartWorkspaceRequest{
@@ -333,7 +345,7 @@ func (o *Orchestrator) Build(req *protocol.BuildRequest, resp protocol.ImageBuil
333345
WorkspaceLocation: contextPath,
334346
Envvars: []*wsmanapi.EnvironmentVariable{
335347
{Name: "BOB_TARGET_REF", Value: "localhost:8080/target:latest"},
336-
{Name: "BOB_BASE_REF", Value: "localhost:8080/base:latest"},
348+
{Name: "BOB_BASE_REF", Value: bobBaseref},
337349
{Name: "BOB_BUILD_BASE", Value: buildBase},
338350
{Name: "BOB_DOCKERFILE_PATH", Value: dockerfilePath},
339351
{Name: "BOB_CONTEXT_DIR", Value: contextPath},

0 commit comments

Comments
 (0)