Skip to content

Commit

Permalink
image: replace GetStoreImage with ResolveReference
Browse files Browse the repository at this point in the history
replace deprecated GetStoreImage -> ResolveReference

Signed-off-by: Aditya R <arajan@redhat.com>
  • Loading branch information
flouthoc committed Nov 2, 2023
1 parent d6eb72b commit eda5d3f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package buildah
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"os"
Expand All @@ -22,7 +21,6 @@ import (
"github.com/containers/image/v5/transports"
"github.com/containers/image/v5/types"
encconfig "github.com/containers/ocicrypt/config"
"github.com/containers/storage"
"github.com/containers/storage/pkg/archive"
"github.com/containers/storage/pkg/stringid"
digest "github.com/opencontainers/go-digest"
Expand Down Expand Up @@ -358,7 +356,7 @@ func (b *Builder) Commit(ctx context.Context, dest types.ImageReference, options
if len(options.AdditionalTags) > 0 {
switch dest.Transport().Name() {
case is.Transport.Name():
img, err := is.Transport.GetStoreImage(b.store, dest)
_, img, err := is.ResolveReference(dest)
if err != nil {
return imgID, nil, "", fmt.Errorf("locating just-written image %q: %w", transports.ImageName(dest), err)
}
Expand All @@ -371,8 +369,8 @@ func (b *Builder) Commit(ctx context.Context, dest types.ImageReference, options
}
}

img, err := is.Transport.GetStoreImage(b.store, dest)
if err != nil && !errors.Is(err, storage.ErrImageUnknown) {
_, img, err := is.ResolveReference(dest)
if err != nil && err.Error() != fmt.Sprintf("trying to resolve a non-%s: reference %q", is.Transport.Name(), transports.ImageName(dest)) {
return imgID, nil, "", fmt.Errorf("locating image %q in local storage: %w", transports.ImageName(dest), err)
}
if err == nil {
Expand Down
4 changes: 2 additions & 2 deletions imagebuildah/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image
if dest, err := b.resolveNameToImageRef(b.output); err == nil {
switch dest.Transport().Name() {
case storageTransport.Transport.Name():
img, err := storageTransport.Transport.GetStoreImage(b.store, dest)
_, img, err := storageTransport.ResolveReference(dest)
if err != nil {
return imageID, ref, fmt.Errorf("locating just-written image %q: %w", transports.ImageName(dest), err)
}
Expand All @@ -1029,7 +1029,7 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (image
logrus.Debugf("assigned names %v to image %q", img.Names, img.ID)
}
// Report back the caller the tags applied, if any.
img, err = storageTransport.Transport.GetStoreImage(b.store, dest)
_, img, err = storageTransport.ResolveReference(dest)
if err != nil {
return imageID, ref, fmt.Errorf("locating just-written image %q: %w", transports.ImageName(dest), err)
}
Expand Down
2 changes: 1 addition & 1 deletion imagebuildah/stage_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,7 @@ func (s *StageExecutor) tagExistingImage(ctx context.Context, cacheID, output st
if err != nil {
return "", nil, fmt.Errorf("computing digest of manifest for image %q: %w", cacheID, err)
}
img, err := is.Transport.GetStoreImage(s.executor.store, dest)
_, img, err := is.ResolveReference(dest)
if err != nil {
return "", nil, fmt.Errorf("locating new copy of image %q (i.e., %q): %w", cacheID, transports.ImageName(dest), err)
}
Expand Down

0 comments on commit eda5d3f

Please sign in to comment.