mirror of
https://github.com/containers/skopeo.git
synced 2025-09-12 21:16:52 +00:00
Bump github.com/containers/storage from 1.41.0 to 1.42.0
Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.41.0 to 1.42.0. - [Release notes](https://github.com/containers/storage/releases) - [Changelog](https://github.com/containers/storage/blob/main/docs/containers-storage-changes.md) - [Commits](https://github.com/containers/storage/compare/v1.41.0...v1.42.0) --- updated-dependencies: - dependency-name: github.com/containers/storage dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
119
vendor/github.com/containers/storage/store.go
generated
vendored
119
vendor/github.com/containers/storage/store.go
generated
vendored
@@ -2,6 +2,7 @@ package storage
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -21,14 +22,12 @@ import (
|
||||
"github.com/containers/storage/pkg/idtools"
|
||||
"github.com/containers/storage/pkg/ioutils"
|
||||
"github.com/containers/storage/pkg/parsers"
|
||||
"github.com/containers/storage/pkg/stringid"
|
||||
"github.com/containers/storage/pkg/stringutils"
|
||||
"github.com/containers/storage/pkg/system"
|
||||
"github.com/containers/storage/types"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/opencontainers/selinux/go-selinux/label"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type updateNameOperation int
|
||||
@@ -173,6 +172,7 @@ type Store interface {
|
||||
GraphRoot() string
|
||||
GraphDriverName() string
|
||||
GraphOptions() []string
|
||||
PullOptions() map[string]string
|
||||
UIDMap() []idtools.IDMap
|
||||
GIDMap() []idtools.IDMap
|
||||
|
||||
@@ -607,6 +607,7 @@ type store struct {
|
||||
graphRoot string
|
||||
graphDriverName string
|
||||
graphOptions []string
|
||||
pullOptions map[string]string
|
||||
uidMap []idtools.IDMap
|
||||
gidMap []idtools.IDMap
|
||||
autoUsernsUser string
|
||||
@@ -642,8 +643,12 @@ type store struct {
|
||||
// return
|
||||
// }
|
||||
func GetStore(options types.StoreOptions) (Store, error) {
|
||||
defaultOpts, err := types.Options()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if options.RunRoot == "" && options.GraphRoot == "" && options.GraphDriverName == "" && len(options.GraphDriverOptions) == 0 {
|
||||
options = types.Options()
|
||||
options = defaultOpts
|
||||
}
|
||||
|
||||
if options.GraphRoot != "" {
|
||||
@@ -674,11 +679,11 @@ func GetStore(options types.StoreOptions) (Store, error) {
|
||||
// if passed a run-root or graph-root alone, the other should be defaulted only error if we have neither.
|
||||
switch {
|
||||
case options.RunRoot == "" && options.GraphRoot == "":
|
||||
return nil, errors.Wrap(ErrIncompleteOptions, "no storage runroot or graphroot specified")
|
||||
return nil, fmt.Errorf("no storage runroot or graphroot specified: %w", ErrIncompleteOptions)
|
||||
case options.GraphRoot == "":
|
||||
options.GraphRoot = types.Options().GraphRoot
|
||||
options.GraphRoot = defaultOpts.GraphRoot
|
||||
case options.RunRoot == "":
|
||||
options.RunRoot = types.Options().RunRoot
|
||||
options.RunRoot = defaultOpts.RunRoot
|
||||
}
|
||||
|
||||
if err := os.MkdirAll(options.RunRoot, 0700); err != nil {
|
||||
@@ -726,6 +731,7 @@ func GetStore(options types.StoreOptions) (Store, error) {
|
||||
additionalGIDs: nil,
|
||||
usernsLock: usernsLock,
|
||||
disableVolatile: options.DisableVolatile,
|
||||
pullOptions: options.PullOptions,
|
||||
}
|
||||
if err := s.load(); err != nil {
|
||||
return nil, err
|
||||
@@ -776,6 +782,14 @@ func (s *store) GraphOptions() []string {
|
||||
return s.graphOptions
|
||||
}
|
||||
|
||||
func (s *store) PullOptions() map[string]string {
|
||||
cp := make(map[string]string, len(s.pullOptions))
|
||||
for k, v := range s.pullOptions {
|
||||
cp[k] = v
|
||||
}
|
||||
return cp
|
||||
}
|
||||
|
||||
func (s *store) UIDMap() []idtools.IDMap {
|
||||
return copyIDMap(s.uidMap)
|
||||
}
|
||||
@@ -1005,9 +1019,6 @@ func (s *store) PutLayer(id, parent string, names []string, mountLabel string, w
|
||||
if err := rcstore.ReloadIfChanged(); err != nil {
|
||||
return nil, -1, err
|
||||
}
|
||||
if id == "" {
|
||||
id = stringid.GenerateRandomID()
|
||||
}
|
||||
if options == nil {
|
||||
options = &LayerOptions{}
|
||||
}
|
||||
@@ -1086,10 +1097,6 @@ func (s *store) CreateLayer(id, parent string, names []string, mountLabel string
|
||||
}
|
||||
|
||||
func (s *store) CreateImage(id string, names []string, layer, metadata string, options *ImageOptions) (*Image, error) {
|
||||
if id == "" {
|
||||
id = stringid.GenerateRandomID()
|
||||
}
|
||||
|
||||
if layer != "" {
|
||||
lstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
@@ -1241,13 +1248,13 @@ func (s *store) imageTopLayerForMapping(image *Image, ristore ROImageStore, crea
|
||||
layerOptions.TemplateLayer = layer.ID
|
||||
mappedLayer, _, err := rlstore.Put("", parentLayer, nil, layer.MountLabel, nil, &layerOptions, false, nil, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error creating an ID-mapped copy of layer %q", layer.ID)
|
||||
return nil, fmt.Errorf("creating an ID-mapped copy of layer %q: %w", layer.ID, err)
|
||||
}
|
||||
if err = istore.addMappedTopLayer(image.ID, mappedLayer.ID); err != nil {
|
||||
if err2 := rlstore.Delete(mappedLayer.ID); err2 != nil {
|
||||
err = errors.WithMessage(err, fmt.Sprintf("error deleting layer %q: %v", mappedLayer.ID, err2))
|
||||
err = fmt.Errorf("deleting layer %q: %v: %w", mappedLayer.ID, err2, err)
|
||||
}
|
||||
return nil, errors.Wrapf(err, "error registering ID-mapped layer with image %q", image.ID)
|
||||
return nil, fmt.Errorf("registering ID-mapped layer with image %q: %w", image.ID, err)
|
||||
}
|
||||
layer = mappedLayer
|
||||
}
|
||||
@@ -1268,9 +1275,6 @@ func (s *store) CreateContainer(id string, names []string, image, layer, metadat
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if id == "" {
|
||||
id = stringid.GenerateRandomID()
|
||||
}
|
||||
|
||||
var imageTopLayer *Layer
|
||||
imageID := ""
|
||||
@@ -1326,14 +1330,14 @@ func (s *store) CreateContainer(id string, names []string, image, layer, metadat
|
||||
}
|
||||
}
|
||||
if cimage == nil {
|
||||
return nil, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id)
|
||||
return nil, fmt.Errorf("locating image with ID %q: %w", image, ErrImageUnknown)
|
||||
}
|
||||
imageID = cimage.ID
|
||||
}
|
||||
|
||||
if options.AutoUserNs {
|
||||
var err error
|
||||
options.UIDMap, options.GIDMap, err = s.getAutoUserNS(id, &options.AutoUserNsOpts, cimage)
|
||||
options.UIDMap, options.GIDMap, err = s.getAutoUserNS(&options.AutoUserNsOpts, cimage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1399,7 +1403,7 @@ func (s *store) CreateContainer(id string, names []string, image, layer, metadat
|
||||
mlabel, _ := options.Flags["MountLabel"].(string)
|
||||
if (plabel == "" && mlabel != "") ||
|
||||
(plabel != "" && mlabel == "") {
|
||||
return nil, errors.Errorf("ProcessLabel and Mountlabel must either not be specified or both specified")
|
||||
return nil, errors.New("processLabel and Mountlabel must either not be specified or both specified")
|
||||
}
|
||||
|
||||
if plabel == "" {
|
||||
@@ -1557,7 +1561,7 @@ func (s *store) ListImageBigData(id string) ([]string, error) {
|
||||
return bigDataNames, err
|
||||
}
|
||||
}
|
||||
return nil, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id)
|
||||
return nil, fmt.Errorf("locating image with ID %q: %w", id, ErrImageUnknown)
|
||||
}
|
||||
|
||||
func (s *store) ImageBigDataSize(id, key string) (int64, error) {
|
||||
@@ -1635,9 +1639,9 @@ func (s *store) ImageBigData(id, key string) ([]byte, error) {
|
||||
}
|
||||
}
|
||||
if foundImage {
|
||||
return nil, errors.Wrapf(os.ErrNotExist, "error locating item named %q for image with ID %q (consider removing the image to resolve the issue)", key, id)
|
||||
return nil, fmt.Errorf("locating item named %q for image with ID %q (consider removing the image to resolve the issue): %w", key, id, os.ErrNotExist)
|
||||
}
|
||||
return nil, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id)
|
||||
return nil, fmt.Errorf("locating image with ID %q: %w", id, ErrImageUnknown)
|
||||
}
|
||||
|
||||
// ListLayerBigData retrieves a list of the (possibly large) chunks of
|
||||
@@ -1668,9 +1672,9 @@ func (s *store) ListLayerBigData(id string) ([]string, error) {
|
||||
}
|
||||
}
|
||||
if foundLayer {
|
||||
return nil, errors.Wrapf(os.ErrNotExist, "error locating big data for layer with ID %q", id)
|
||||
return nil, fmt.Errorf("locating big data for layer with ID %q: %w", id, os.ErrNotExist)
|
||||
}
|
||||
return nil, errors.Wrapf(ErrLayerUnknown, "error locating layer with ID %q", id)
|
||||
return nil, fmt.Errorf("locating layer with ID %q: %w", id, ErrLayerUnknown)
|
||||
}
|
||||
|
||||
// LayerBigData retrieves a (possibly large) chunk of named data
|
||||
@@ -1701,9 +1705,9 @@ func (s *store) LayerBigData(id, key string) (io.ReadCloser, error) {
|
||||
}
|
||||
}
|
||||
if foundLayer {
|
||||
return nil, errors.Wrapf(os.ErrNotExist, "error locating item named %q for layer with ID %q", key, id)
|
||||
return nil, fmt.Errorf("locating item named %q for layer with ID %q: %w", key, id, os.ErrNotExist)
|
||||
}
|
||||
return nil, errors.Wrapf(ErrLayerUnknown, "error locating layer with ID %q", id)
|
||||
return nil, fmt.Errorf("locating layer with ID %q: %w", id, ErrLayerUnknown)
|
||||
}
|
||||
|
||||
// SetLayerBigData stores a (possibly large) chunk of named data
|
||||
@@ -1742,11 +1746,11 @@ func (s *store) ImageSize(id string) (int64, error) {
|
||||
|
||||
lstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return -1, errors.Wrapf(err, "error loading primary layer store data")
|
||||
return -1, fmt.Errorf("loading primary layer store data: %w", err)
|
||||
}
|
||||
lstores, err := s.ROLayerStores()
|
||||
if err != nil {
|
||||
return -1, errors.Wrapf(err, "error loading additional layer stores")
|
||||
return -1, fmt.Errorf("loading additional layer stores: %w", err)
|
||||
}
|
||||
for _, s := range append([]ROLayerStore{lstore}, lstores...) {
|
||||
store := s
|
||||
@@ -1760,11 +1764,11 @@ func (s *store) ImageSize(id string) (int64, error) {
|
||||
var imageStore ROBigDataStore
|
||||
istore, err := s.ImageStore()
|
||||
if err != nil {
|
||||
return -1, errors.Wrapf(err, "error loading primary image store data")
|
||||
return -1, fmt.Errorf("loading primary image store data: %w", err)
|
||||
}
|
||||
istores, err := s.ROImageStores()
|
||||
if err != nil {
|
||||
return -1, errors.Wrapf(err, "error loading additional image stores")
|
||||
return -1, fmt.Errorf("loading additional image stores: %w", err)
|
||||
}
|
||||
|
||||
// Look for the image's record.
|
||||
@@ -1781,7 +1785,7 @@ func (s *store) ImageSize(id string) (int64, error) {
|
||||
}
|
||||
}
|
||||
if image == nil {
|
||||
return -1, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id)
|
||||
return -1, fmt.Errorf("locating image with ID %q: %w", id, ErrImageUnknown)
|
||||
}
|
||||
|
||||
// Start with a list of the image's top layers, if it has any.
|
||||
@@ -1811,7 +1815,7 @@ func (s *store) ImageSize(id string) (int64, error) {
|
||||
}
|
||||
}
|
||||
if layer == nil {
|
||||
return -1, errors.Wrapf(ErrLayerUnknown, "error locating layer with ID %q", layerID)
|
||||
return -1, fmt.Errorf("locating layer with ID %q: %w", layerID, ErrLayerUnknown)
|
||||
}
|
||||
// The UncompressedSize is only valid if there's a digest to go with it.
|
||||
n := layer.UncompressedSize
|
||||
@@ -1819,7 +1823,7 @@ func (s *store) ImageSize(id string) (int64, error) {
|
||||
// Compute the size.
|
||||
n, err = layerStore.DiffSize("", layer.ID)
|
||||
if err != nil {
|
||||
return -1, errors.Wrapf(err, "size/digest of layer with ID %q could not be calculated", layerID)
|
||||
return -1, fmt.Errorf("size/digest of layer with ID %q could not be calculated: %w", layerID, err)
|
||||
}
|
||||
}
|
||||
// Count this layer.
|
||||
@@ -1834,12 +1838,12 @@ func (s *store) ImageSize(id string) (int64, error) {
|
||||
// Count big data items.
|
||||
names, err := imageStore.BigDataNames(id)
|
||||
if err != nil {
|
||||
return -1, errors.Wrapf(err, "error reading list of big data items for image %q", id)
|
||||
return -1, fmt.Errorf("reading list of big data items for image %q: %w", id, err)
|
||||
}
|
||||
for _, name := range names {
|
||||
n, err := imageStore.BigDataSize(id, name)
|
||||
if err != nil {
|
||||
return -1, errors.Wrapf(err, "error reading size of big data item %q for image %q", name, id)
|
||||
return -1, fmt.Errorf("reading size of big data item %q for image %q: %w", name, id, err)
|
||||
}
|
||||
size += n
|
||||
}
|
||||
@@ -1899,24 +1903,24 @@ func (s *store) ContainerSize(id string) (int64, error) {
|
||||
if layer, err = store.Get(container.LayerID); err == nil {
|
||||
size, err = store.DiffSize("", layer.ID)
|
||||
if err != nil {
|
||||
return -1, errors.Wrapf(err, "error determining size of layer with ID %q", layer.ID)
|
||||
return -1, fmt.Errorf("determining size of layer with ID %q: %w", layer.ID, err)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if layer == nil {
|
||||
return -1, errors.Wrapf(ErrLayerUnknown, "error locating layer with ID %q", container.LayerID)
|
||||
return -1, fmt.Errorf("locating layer with ID %q: %w", container.LayerID, ErrLayerUnknown)
|
||||
}
|
||||
|
||||
// Count big data items.
|
||||
names, err := rcstore.BigDataNames(id)
|
||||
if err != nil {
|
||||
return -1, errors.Wrapf(err, "error reading list of big data items for container %q", container.ID)
|
||||
return -1, fmt.Errorf("reading list of big data items for container %q: %w", container.ID, err)
|
||||
}
|
||||
for _, name := range names {
|
||||
n, err := rcstore.BigDataSize(id, name)
|
||||
if err != nil {
|
||||
return -1, errors.Wrapf(err, "error reading size of big data item %q for container %q", name, id)
|
||||
return -1, fmt.Errorf("reading size of big data item %q for container %q: %w", name, id, err)
|
||||
}
|
||||
size += n
|
||||
}
|
||||
@@ -2334,7 +2338,7 @@ func (s *store) DeleteLayer(id string) error {
|
||||
}
|
||||
for _, layer := range layers {
|
||||
if layer.Parent == id {
|
||||
return errors.Wrapf(ErrLayerHasChildren, "used by layer %v", layer.ID)
|
||||
return fmt.Errorf("used by layer %v: %w", layer.ID, ErrLayerHasChildren)
|
||||
}
|
||||
}
|
||||
images, err := ristore.Images()
|
||||
@@ -2344,12 +2348,12 @@ func (s *store) DeleteLayer(id string) error {
|
||||
|
||||
for _, image := range images {
|
||||
if image.TopLayer == id {
|
||||
return errors.Wrapf(ErrLayerUsedByImage, "layer %v used by image %v", id, image.ID)
|
||||
return fmt.Errorf("layer %v used by image %v: %w", id, image.ID, ErrLayerUsedByImage)
|
||||
}
|
||||
if stringutils.InSlice(image.MappedTopLayers, id) {
|
||||
// No write access to the image store, fail before the layer is deleted
|
||||
if _, ok := ristore.(*imageStore); !ok {
|
||||
return errors.Wrapf(ErrLayerUsedByImage, "layer %v used by image %v", id, image.ID)
|
||||
return fmt.Errorf("layer %v used by image %v: %w", id, image.ID, ErrLayerUsedByImage)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2359,11 +2363,11 @@ func (s *store) DeleteLayer(id string) error {
|
||||
}
|
||||
for _, container := range containers {
|
||||
if container.LayerID == id {
|
||||
return errors.Wrapf(ErrLayerUsedByContainer, "layer %v used by container %v", id, container.ID)
|
||||
return fmt.Errorf("layer %v used by container %v: %w", id, container.ID, ErrLayerUsedByContainer)
|
||||
}
|
||||
}
|
||||
if err := rlstore.Delete(id); err != nil {
|
||||
return errors.Wrapf(err, "delete layer %v", id)
|
||||
return fmt.Errorf("delete layer %v: %w", id, err)
|
||||
}
|
||||
|
||||
// The check here is used to avoid iterating the images if we don't need to.
|
||||
@@ -2372,7 +2376,7 @@ func (s *store) DeleteLayer(id string) error {
|
||||
for _, image := range images {
|
||||
if stringutils.InSlice(image.MappedTopLayers, id) {
|
||||
if err = istore.removeMappedTopLayer(image.ID, id); err != nil {
|
||||
return errors.Wrapf(err, "remove mapped top layer %v from image %v", id, image.ID)
|
||||
return fmt.Errorf("remove mapped top layer %v from image %v: %w", id, image.ID, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2427,7 +2431,7 @@ func (s *store) DeleteImage(id string, commit bool) (layers []string, err error)
|
||||
aContainerByImage[container.ImageID] = container.ID
|
||||
}
|
||||
if container, ok := aContainerByImage[id]; ok {
|
||||
return nil, errors.Wrapf(ErrImageUsedByContainer, "Image used by %v", container)
|
||||
return nil, fmt.Errorf("image used by %v: %w", container, ErrImageUsedByContainer)
|
||||
}
|
||||
images, err := ristore.Images()
|
||||
if err != nil {
|
||||
@@ -3045,7 +3049,7 @@ func (s *store) layersByMappedDigest(m func(ROLayerStore, digest.Digest) ([]Laye
|
||||
}
|
||||
storeLayers, err := m(store, d)
|
||||
if err != nil {
|
||||
if errors.Cause(err) != ErrLayerUnknown {
|
||||
if !errors.Is(err, ErrLayerUnknown) {
|
||||
return nil, err
|
||||
}
|
||||
continue
|
||||
@@ -3060,14 +3064,14 @@ func (s *store) layersByMappedDigest(m func(ROLayerStore, digest.Digest) ([]Laye
|
||||
|
||||
func (s *store) LayersByCompressedDigest(d digest.Digest) ([]Layer, error) {
|
||||
if err := d.Validate(); err != nil {
|
||||
return nil, errors.Wrapf(err, "error looking for compressed layers matching digest %q", d)
|
||||
return nil, fmt.Errorf("looking for compressed layers matching digest %q: %w", d, err)
|
||||
}
|
||||
return s.layersByMappedDigest(func(r ROLayerStore, d digest.Digest) ([]Layer, error) { return r.LayersByCompressedDigest(d) }, d)
|
||||
}
|
||||
|
||||
func (s *store) LayersByUncompressedDigest(d digest.Digest) ([]Layer, error) {
|
||||
if err := d.Validate(); err != nil {
|
||||
return nil, errors.Wrapf(err, "error looking for layers matching digest %q", d)
|
||||
return nil, fmt.Errorf("looking for layers matching digest %q: %w", d, err)
|
||||
}
|
||||
return s.layersByMappedDigest(func(r ROLayerStore, d digest.Digest) ([]Layer, error) { return r.LayersByUncompressedDigest(d) }, d)
|
||||
}
|
||||
@@ -3347,7 +3351,7 @@ func (s *store) Image(id string) (*Image, error) {
|
||||
return image, nil
|
||||
}
|
||||
}
|
||||
return nil, errors.Wrapf(ErrImageUnknown, "error locating image with ID %q", id)
|
||||
return nil, fmt.Errorf("locating image with ID %q: %w", id, ErrImageUnknown)
|
||||
}
|
||||
|
||||
func (s *store) ImagesByTopLayer(id string) ([]*Image, error) {
|
||||
@@ -3405,7 +3409,7 @@ func (s *store) ImagesByDigest(d digest.Digest) ([]*Image, error) {
|
||||
return nil, err
|
||||
}
|
||||
imageList, err := store.ByDigest(d)
|
||||
if err != nil && errors.Cause(err) != ErrImageUnknown {
|
||||
if err != nil && !errors.Is(err, ErrImageUnknown) {
|
||||
return nil, err
|
||||
}
|
||||
images = append(images, imageList...)
|
||||
@@ -3601,7 +3605,7 @@ func (s *store) Shutdown(force bool) ([]string, error) {
|
||||
}
|
||||
}
|
||||
if len(mounted) > 0 && err == nil {
|
||||
err = errors.Wrap(ErrLayerUsedByContainer, "A layer is mounted")
|
||||
err = fmt.Errorf("a layer is mounted: %w", ErrLayerUsedByContainer)
|
||||
}
|
||||
if err == nil {
|
||||
err = s.graphDriver.Cleanup()
|
||||
@@ -3715,7 +3719,10 @@ func ReloadConfigurationFile(configFile string, storeOptions *types.StoreOptions
|
||||
|
||||
// GetDefaultMountOptions returns the default mountoptions defined in container/storage
|
||||
func GetDefaultMountOptions() ([]string, error) {
|
||||
defaultStoreOptions := types.Options()
|
||||
defaultStoreOptions, err := types.Options()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return GetMountOptions(defaultStoreOptions.GraphDriverName, defaultStoreOptions.GraphDriverOptions)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user