Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to latest libimage #3194

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/buildah/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func formatImages(images []*libimage.Image, opts imageOptions) error {
outputParam.Size = formattedSize(size)
outputParam.ReadOnly = image.IsReadOnly()

repoTags, err := image.NamedTaggedRepoTags()
repoTags, err := image.NamedRepoTags()
if err != nil {
return err
}
Expand Down
20 changes: 14 additions & 6 deletions cmd/buildah/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/containers/image/v5/transports/alltransports"
"github.com/containers/image/v5/types"
"github.com/containers/storage"
"github.com/hashicorp/go-multierror"
digest "github.com/opencontainers/go-digest"
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
Expand Down Expand Up @@ -462,14 +463,21 @@ func manifestRmCmd(c *cobra.Command, args []string) error {
options := &libimage.RemoveImagesOptions{
Filters: []string{"readonly=false"},
}
untagged, removed, err := runtime.RemoveImages(context.Background(), args, options)
for _, u := range untagged {
fmt.Printf("untagged: %s\n", u)
rmiReports, rmiErrors := runtime.RemoveImages(context.Background(), args, options)
for _, r := range rmiReports {
for _, u := range r.Untagged {
fmt.Printf("untagged: %s\n", u)
}
}
for _, r := range removed {
fmt.Printf("%s\n", r)
for _, r := range rmiReports {
if r.Removed {
fmt.Printf("%s\n", r.ID)
}
}
return err

var multiE *multierror.Error
multiE = multierror.Append(multiE, rmiErrors...)
return multiE.ErrorOrNil()
}

func manifestAnnotateCmd(c *cobra.Command, args []string, opts manifestAnnotateOpts) error {
Expand Down
20 changes: 14 additions & 6 deletions cmd/buildah/rmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
buildahcli "github.com/containers/buildah/pkg/cli"
"github.com/containers/buildah/pkg/parse"
"github.com/containers/common/libimage"
"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -87,12 +88,19 @@ func rmiCmd(c *cobra.Command, args []string, iopts rmiOptions) error {
}
options.Force = iopts.force

untagged, removed, err := runtime.RemoveImages(context.Background(), args, options)
for _, u := range untagged {
fmt.Printf("untagged: %s\n", u)
rmiReports, rmiErrors := runtime.RemoveImages(context.Background(), args, options)
for _, r := range rmiReports {
for _, u := range r.Untagged {
fmt.Printf("untagged: %s\n", u)
}
}
for _, r := range removed {
fmt.Printf("%s\n", r)
for _, r := range rmiReports {
if r.Removed {
fmt.Printf("%s\n", r.ID)
}
}
return err

var multiE *multierror.Error
multiE = multierror.Append(multiE, rmiErrors...)
return multiE.ErrorOrNil()
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.12

require (
github.com/containernetworking/cni v0.8.1
github.com/containers/common v0.37.1
github.com/containers/common v0.37.2-0.20210503193405-42134aa138ce
github.com/containers/image/v5 v5.11.1
github.com/containers/ocicrypt v1.1.1
github.com/containers/storage v1.30.1
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ github.com/containernetworking/cni v0.8.0/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ
github.com/containernetworking/cni v0.8.1 h1:7zpDnQ3T3s4ucOuJ/ZCLrYBxzkg0AELFfII3Epo9TmI=
github.com/containernetworking/cni v0.8.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHVlzhJpcY6TQxn/fUyDDM=
github.com/containers/common v0.37.1 h1:V71FK6k2KsNgcNtspGlrdCaKrSml/SO6bKmJdWjSnaY=
github.com/containers/common v0.37.1/go.mod h1:ONPdpc69oQG9e75v/eBzzAReuv0we5NcGdEzK4meDv4=
github.com/containers/common v0.37.2-0.20210503193405-42134aa138ce h1:e7VNmGqwfUQkw+D5bms262x1HYqxfN9/+t5SoaFnwTk=
github.com/containers/common v0.37.2-0.20210503193405-42134aa138ce/go.mod h1:JjU+yvzIGyx8ZsY8nyf7snzs4VSNh1eIaYsqoSKBoRw=
github.com/containers/image/v5 v5.11.1 h1:mNybUvU6zXUwcMsQaa3n+Idsru5pV+GE7k4oRuPzYi0=
github.com/containers/image/v5 v5.11.1/go.mod h1:HC9lhJ/Nz5v3w/5Co7H431kLlgzlVlOC+auD/er3OqE=
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b h1:Q8ePgVfHDplZ7U33NwHZkrVELsZP5fYj9pM5WBZB2GE=
Expand Down Expand Up @@ -223,6 +223,8 @@ github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8l
github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/disiqueira/gotree/v3 v3.0.2 h1:ik5iuLQQoufZBNPY518dXhiO5056hyNBIK9lWhkNRq8=
github.com/disiqueira/gotree/v3 v3.0.2/go.mod h1:ZuyjE4+mUQZlbpkI24AmruZKhg3VHEgPLDY8Qk+uUu8=
github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E=
github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY=
github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
Expand Down Expand Up @@ -415,6 +417,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
github.com/ishidawataru/sctp v0.0.0-20210226210310-f2269e66cdee h1:PAXLXk1heNZ5yokbMBpVLZQxo43wCZxRwl00mX+dd44=
github.com/ishidawataru/sctp v0.0.0-20210226210310-f2269e66cdee/go.mod h1:co9pwDoBCm1kGxawmb4sPq0cSIOOWNPT4KnHotMP1Zg=
github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA=
github.com/jinzhu/copier v0.3.0 h1:P5zN9OYSxmtzZmwgcVmt5Iu8egfP53BGMPAFgEksKPI=
github.com/jinzhu/copier v0.3.0/go.mod h1:24xnZezI2Yqac9J61UC6/dG/k76ttpq0DdJI3QmUvro=
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
Expand Down
15 changes: 2 additions & 13 deletions imagebuildah/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,22 +317,11 @@ func (b *Executor) resolveNameToImageRef(output string) (types.ImageReference, e
if err != nil {
return nil, err
}
// If we can resolve the image locally, make sure we use the resolved name.
localImage, resolvedName, err := runtime.LookupImage(output, nil)
resolved, err := runtime.ResolveName(output)
if err != nil {
return nil, err
}
if localImage != nil {
output = resolvedName
}
// If we cannot find an image, make sure we normalize the name
// according the conventions and rules in libimage (e.g.,
// "localhost/" prefixing).
named, err := libimage.NormalizeName(output)
if err != nil {
return nil, err
}
imageRef, err := storageTransport.Transport.ParseStoreReference(b.store, named.String())
imageRef, err := storageTransport.Transport.ParseStoreReference(b.store, resolved)
if err == nil {
return imageRef, nil
}
Expand Down
5 changes: 2 additions & 3 deletions new.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/containers/buildah/define"
"github.com/containers/buildah/pkg/blobcache"
"github.com/containers/common/libimage"
libimageTypes "github.com/containers/common/libimage/types"
"github.com/containers/common/pkg/config"
"github.com/containers/image/v5/image"
"github.com/containers/image/v5/manifest"
"github.com/containers/image/v5/transports"
Expand Down Expand Up @@ -119,7 +119,7 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions
return nil, err
}

pullPolicy, err := libimageTypes.ParsePullPolicy(options.PullPolicy.String())
pullPolicy, err := config.ParsePullPolicy(options.PullPolicy.String())
if err != nil {
return nil, err
}
Expand All @@ -138,7 +138,6 @@ func newBuilder(ctx context.Context, store storage.Store, options BuilderOptions

if options.BlobDirectory != "" {
pullOptions.DestinationLookupReferenceFunc = blobcache.CacheLookupReferenceFunc(options.BlobDirectory, types.PreserveOriginal)
// pullOptions.SourceLookupReferenceFunc = blobcache.CacheLookupReferenceFunc(options.BlobDirectory, types.PreserveOriginal)
}

pulledImages, err := imageRuntime.Pull(ctx, options.FromImage, pullPolicy, &pullOptions)
Expand Down
4 changes: 2 additions & 2 deletions pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/containers/buildah/define"
"github.com/containers/buildah/pkg/blobcache"
"github.com/containers/common/libimage"
libimageTypes "github.com/containers/common/libimage/types"
"github.com/containers/common/pkg/config"
"github.com/containers/image/v5/types"
encconfig "github.com/containers/ocicrypt/config"
"github.com/containers/storage"
Expand Down Expand Up @@ -73,7 +73,7 @@ func Pull(ctx context.Context, imageName string, options PullOptions) (imageID s
libimageOptions.DestinationLookupReferenceFunc = blobcache.CacheLookupReferenceFunc(options.BlobDirectory, types.PreserveOriginal)
}

pullPolicy, err := libimageTypes.ParsePullPolicy(options.PullPolicy.String())
pullPolicy, err := config.ParsePullPolicy(options.PullPolicy.String())
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion tests/from.bats
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ load helpers
run_buildah rm $output

run_buildah 125 from sha256:1111111111111111111111111111111111111111111111111111111111111111
expect_output --substring "sha256:1111111111111111111111111111111111111111111111111111111111111111: image not known"
expect_output --substring "1111111111111111111111111111111111111111111111111111111111111111: image not known"
}

@test "commit-to-from-elsewhere" {
Expand Down
2 changes: 1 addition & 1 deletion tests/pull.bats
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ load helpers

@test "pull-from-registry" {
run_buildah --retry pull --registries-conf ${TESTSDIR}/registries.conf --signature-policy ${TESTSDIR}/policy.json busybox:glibc
run_buildah pull --registries-conf ${TESTSDIR}/registries.conf --signature-policy ${TESTSDIR}/policy.json busybox
run_buildah pull --registries-conf ${TESTSDIR}/registries.conf --signature-policy ${TESTSDIR}/policy.json busybox:latest
run_buildah images --format "{{.Name}}:{{.Tag}}"
expect_output --substring "busybox:glibc"
expect_output --substring "busybox:latest"
Expand Down
17 changes: 7 additions & 10 deletions tests/rmi.bats
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@ load helpers

@test "remove multiple non-existent images errors" {
run_buildah 125 rmi image1 image2 image3
expect_output --from="${lines[0]}" "image1: image not known"

run_buildah 125 rmi image2 image3
expect_output --from="${lines[0]}" "image2: image not known"

run_buildah 125 rmi image3
expect_output --from="${lines[0]}" "image3: image not known"
expect_output --from="${lines[1]}" --substring " image1: image not known"
expect_output --from="${lines[2]}" --substring " image2: image not known"
expect_output --from="${lines[3]}" --substring " image3: image not known"
}

@test "remove all images" {
Expand Down Expand Up @@ -189,13 +185,14 @@ load helpers
run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid new-image
run_buildah rm -a

# Since it has children, alpine will only be untagged (Podman compat).
# Since it has children, alpine will only be untagged (Podman compat) but not
# marked as removed. However, it won't show up in the image list anymore.
run_buildah rmi alpine
expect_output --substring "untagged: "
run_buildah images -q
expect_line_count 1
run_buildah images -q -a
expect_line_count 2
expect_line_count 1
}

@test "rmi with cached images" {
Expand All @@ -208,7 +205,7 @@ load helpers
expect_line_count 9
run_buildah rmi test2
run_buildah images -a -q
expect_line_count 6
expect_line_count 7
run_buildah rmi test1
run_buildah images -a -q
expect_line_count 1
Expand Down
6 changes: 0 additions & 6 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,6 @@ func FindImage(store storage.Store, firstRegistry string, systemContext *types.S
if err != nil {
return nil, nil, err
}
if localImage == nil {
return nil, nil, errors.Wrap(storage.ErrImageUnknown, image)
}
ref, err := localImage.StorageReference()
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -227,9 +224,6 @@ func AddImageNames(store storage.Store, firstRegistry string, systemContext *typ
if err != nil {
return err
}
if localImage == nil {
return errors.Errorf("could not find libimage for %s", image.ID)
}

for _, tag := range addNames {
if err := localImage.Tag(tag); err != nil {
Expand Down
50 changes: 33 additions & 17 deletions vendor/github.com/containers/common/libimage/copier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading