mirror of
https://github.com/containers/podman.git
synced 2025-12-05 12:52:12 +08:00
vendor: update c/common
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
3
vendor/github.com/containers/image/v5/docker/archive/transport.go
generated
vendored
3
vendor/github.com/containers/image/v5/docker/archive/transport.go
generated
vendored
@@ -101,6 +101,9 @@ func NewReference(path string, ref reference.NamedTagged) (types.ImageReference,
|
||||
|
||||
// NewIndexReference returns a Docker archive reference for a path and a zero-based source manifest index.
|
||||
func NewIndexReference(path string, sourceIndex int) (types.ImageReference, error) {
|
||||
if sourceIndex < 0 {
|
||||
return nil, fmt.Errorf("invalid call to NewIndexReference with negative index %d", sourceIndex)
|
||||
}
|
||||
return newReference(path, nil, sourceIndex, nil, nil)
|
||||
}
|
||||
|
||||
|
||||
9
vendor/github.com/containers/image/v5/docker/daemon/daemon_transport.go
generated
vendored
9
vendor/github.com/containers/image/v5/docker/daemon/daemon_transport.go
generated
vendored
@@ -87,10 +87,13 @@ func ParseReference(refString string) (types.ImageReference, error) {
|
||||
|
||||
// NewReference returns a docker-daemon reference for either the supplied image ID (config digest) or the supplied reference (which must satisfy !reference.IsNameOnly)
|
||||
func NewReference(id digest.Digest, ref reference.Named) (types.ImageReference, error) {
|
||||
if id != "" && ref != nil {
|
||||
switch {
|
||||
case id != "" && ref != nil:
|
||||
return nil, errors.New("docker-daemon: reference must not have an image ID and a reference string specified at the same time")
|
||||
}
|
||||
if ref != nil {
|
||||
case id == "" && ref == nil:
|
||||
return nil, errors.New("docker-daemon: reference must have at least one of an image ID and a reference string")
|
||||
|
||||
case ref != nil:
|
||||
if reference.IsNameOnly(ref) {
|
||||
return nil, fmt.Errorf("docker-daemon: reference %s has neither a tag nor a digest", reference.FamiliarString(ref))
|
||||
}
|
||||
|
||||
30
vendor/github.com/containers/image/v5/docker/docker_client.go
generated
vendored
30
vendor/github.com/containers/image/v5/docker/docker_client.go
generated
vendored
@@ -998,7 +998,12 @@ func (c *dockerClient) getExternalBlob(ctx context.Context, urls []string) (io.R
|
||||
resp.Body.Close()
|
||||
continue
|
||||
}
|
||||
return resp.Body, getBlobSize(resp), nil
|
||||
|
||||
size, err := getBlobSize(resp)
|
||||
if err != nil {
|
||||
size = -1
|
||||
}
|
||||
return resp.Body, size, nil
|
||||
}
|
||||
if remoteErrors == nil {
|
||||
return nil, 0, nil // fallback to non-external blob
|
||||
@@ -1006,12 +1011,20 @@ func (c *dockerClient) getExternalBlob(ctx context.Context, urls []string) (io.R
|
||||
return nil, 0, fmt.Errorf("failed fetching external blob from all urls: %w", multierr.Format("", ", ", "", remoteErrors))
|
||||
}
|
||||
|
||||
func getBlobSize(resp *http.Response) int64 {
|
||||
size, err := strconv.ParseInt(resp.Header.Get("Content-Length"), 10, 64)
|
||||
if err != nil {
|
||||
size = -1
|
||||
func getBlobSize(resp *http.Response) (int64, error) {
|
||||
hdrs := resp.Header.Values("Content-Length")
|
||||
if len(hdrs) == 0 {
|
||||
return -1, errors.New(`Missing "Content-Length" header in response`)
|
||||
}
|
||||
return size
|
||||
hdr := hdrs[0] // Equivalent to resp.Header.Get(…)
|
||||
size, err := strconv.ParseInt(hdr, 10, 64)
|
||||
if err != nil { // Go’s response reader should already reject such values.
|
||||
return -1, err
|
||||
}
|
||||
if size < 0 { // '-' is not a valid character in Content-Length, so negative values are invalid. Go’s response reader should already reject such values.
|
||||
return -1, fmt.Errorf(`Invalid negative "Content-Length" %q`, hdr)
|
||||
}
|
||||
return size, nil
|
||||
}
|
||||
|
||||
// getBlob returns a stream for the specified blob in ref, and the blob’s size (or -1 if unknown).
|
||||
@@ -1042,7 +1055,10 @@ func (c *dockerClient) getBlob(ctx context.Context, ref dockerReference, info ty
|
||||
return nil, 0, fmt.Errorf("fetching blob: %w", err)
|
||||
}
|
||||
cache.RecordKnownLocation(ref.Transport(), bicTransportScope(ref), info.Digest, newBICLocationReference(ref))
|
||||
blobSize := getBlobSize(res)
|
||||
blobSize, err := getBlobSize(res)
|
||||
if err != nil {
|
||||
blobSize = -1
|
||||
}
|
||||
|
||||
reconnectingReader, err := newBodyReader(ctx, c, path, res.Body)
|
||||
if err != nil {
|
||||
|
||||
6
vendor/github.com/containers/image/v5/docker/docker_image_dest.go
generated
vendored
6
vendor/github.com/containers/image/v5/docker/docker_image_dest.go
generated
vendored
@@ -243,8 +243,12 @@ func (d *dockerImageDestination) blobExists(ctx context.Context, repo reference.
|
||||
defer res.Body.Close()
|
||||
switch res.StatusCode {
|
||||
case http.StatusOK:
|
||||
size, err := getBlobSize(res)
|
||||
if err != nil {
|
||||
return false, -1, fmt.Errorf("determining size of blob %s in %s: %w", digest, repo.Name(), err)
|
||||
}
|
||||
logrus.Debugf("... already exists")
|
||||
return true, getBlobSize(res), nil
|
||||
return true, size, nil
|
||||
case http.StatusUnauthorized:
|
||||
logrus.Debugf("... not authorized")
|
||||
return false, -1, fmt.Errorf("checking whether a blob %s exists in %s: %w", digest, repo.Name(), registryHTTPResponseToError(res))
|
||||
|
||||
4
vendor/github.com/containers/image/v5/oci/archive/oci_transport.go
generated
vendored
4
vendor/github.com/containers/image/v5/oci/archive/oci_transport.go
generated
vendored
@@ -52,13 +52,13 @@ func (t ociArchiveTransport) ValidatePolicyConfigurationScope(scope string) erro
|
||||
return internal.ValidateScope(scope)
|
||||
}
|
||||
|
||||
// ParseReference converts a string, which should not start with the ImageTransport.Name prefix, into an OCI ImageReference.
|
||||
// ParseReference converts a string, which should not start with the ImageTransport.Name prefix, into an OCI archive ImageReference.
|
||||
func ParseReference(reference string) (types.ImageReference, error) {
|
||||
file, image := internal.SplitPathAndImage(reference)
|
||||
return NewReference(file, image)
|
||||
}
|
||||
|
||||
// NewReference returns an OCI reference for a file and a image.
|
||||
// NewReference returns an OCI archive reference for a file and an optional image name annotation (if not "").
|
||||
func NewReference(file, image string) (types.ImageReference, error) {
|
||||
resolved, err := explicitfilepath.ResolvePathToFullyExplicit(file)
|
||||
if err != nil {
|
||||
|
||||
8
vendor/github.com/containers/image/v5/oci/layout/oci_transport.go
generated
vendored
8
vendor/github.com/containers/image/v5/oci/layout/oci_transport.go
generated
vendored
@@ -111,13 +111,13 @@ func newReference(dir, image string, sourceIndex int) (types.ImageReference, err
|
||||
|
||||
// NewIndexReference returns an OCI reference for a path and a zero-based source manifest index.
|
||||
func NewIndexReference(dir string, sourceIndex int) (types.ImageReference, error) {
|
||||
if sourceIndex < 0 {
|
||||
return nil, fmt.Errorf("invalid call to NewIndexReference with negative index %d", sourceIndex)
|
||||
}
|
||||
return newReference(dir, "", sourceIndex)
|
||||
}
|
||||
|
||||
// NewReference returns an OCI reference for a directory and a image.
|
||||
//
|
||||
// We do not expose an API supplying the resolvedDir; we could, but recomputing it
|
||||
// is generally cheap enough that we prefer being confident about the properties of resolvedDir.
|
||||
// NewReference returns an OCI reference for a directory and an optional image name annotation (if not "").
|
||||
func NewReference(dir, image string) (types.ImageReference, error) {
|
||||
return newReference(dir, image, -1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user