Skip to content

Commit

Permalink
[image-builder] Pull digested base refs correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
csweichel authored and roboquat committed Dec 3, 2021
1 parent b6c0295 commit 5837426
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion components/image-builder-mk3/pkg/orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"sync"
"time"

"github.com/docker/distribution/reference"
"github.com/google/uuid"
"github.com/opentracing/opentracing-go"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -306,6 +307,17 @@ func (o *Orchestrator) Build(req *protocol.BuildRequest, resp protocol.ImageBuil
return false
}

pbaseref, err := reference.Parse(baseref)
if err != nil {
return xerrors.Errorf("cannot parse baseref: %v", err)
}
bobBaseref := "localhost:8080/base"
if r, ok := pbaseref.(reference.Digested); ok {
bobBaseref += "@" + r.Digest().String()
} else {
bobBaseref += ":latest"
}

var swr *wsmanapi.StartWorkspaceResponse
err = retry(ctx, func(ctx context.Context) (err error) {
swr, err = o.wsman.StartWorkspace(ctx, &wsmanapi.StartWorkspaceRequest{
Expand Down Expand Up @@ -333,7 +345,7 @@ func (o *Orchestrator) Build(req *protocol.BuildRequest, resp protocol.ImageBuil
WorkspaceLocation: contextPath,
Envvars: []*wsmanapi.EnvironmentVariable{
{Name: "BOB_TARGET_REF", Value: "localhost:8080/target:latest"},
{Name: "BOB_BASE_REF", Value: "localhost:8080/base:latest"},
{Name: "BOB_BASE_REF", Value: bobBaseref},
{Name: "BOB_BUILD_BASE", Value: buildBase},
{Name: "BOB_DOCKERFILE_PATH", Value: dockerfilePath},
{Name: "BOB_CONTEXT_DIR", Value: contextPath},
Expand Down

0 comments on commit 5837426

Please sign in to comment.