mirror of
https://github.com/containers/podman.git
synced 2025-05-25 19:16:59 +08:00
Vendor in latest container/image
Add feature so that podman pull and load can pull in compressed docker-archive files Signed-off-by: umohnani8 <umohnani@redhat.com> Closes: #468 Approved by: baude
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
github.com/sirupsen/logrus v1.0.0
|
github.com/sirupsen/logrus v1.0.0
|
||||||
github.com/containers/image f7ea1dcb32a06092905672e99faa75bf2f61632b
|
github.com/containers/image b129a8413fd1e8c53379acbbacfc7b667070ae50
|
||||||
github.com/docker/docker-credential-helpers d68f9aeca33f5fd3f08eeae5e9d175edf4e731d1
|
github.com/docker/docker-credential-helpers d68f9aeca33f5fd3f08eeae5e9d175edf4e731d1
|
||||||
github.com/ostreedev/ostree-go master
|
github.com/ostreedev/ostree-go master
|
||||||
github.com/containers/storage 1e5ce40cdb84ab66e26186435b1273e04b879fef
|
github.com/containers/storage 1e5ce40cdb84ab66e26186435b1273e04b879fef
|
||||||
|
14
vendor/github.com/containers/image/docker/archive/src.go
generated
vendored
14
vendor/github.com/containers/image/docker/archive/src.go
generated
vendored
@ -13,15 +13,18 @@ type archiveImageSource struct {
|
|||||||
|
|
||||||
// newImageSource returns a types.ImageSource for the specified image reference.
|
// newImageSource returns a types.ImageSource for the specified image reference.
|
||||||
// The caller must call .Close() on the returned ImageSource.
|
// The caller must call .Close() on the returned ImageSource.
|
||||||
func newImageSource(ctx *types.SystemContext, ref archiveReference) types.ImageSource {
|
func newImageSource(ctx *types.SystemContext, ref archiveReference) (types.ImageSource, error) {
|
||||||
if ref.destinationRef != nil {
|
if ref.destinationRef != nil {
|
||||||
logrus.Warnf("docker-archive: references are not supported for sources (ignoring)")
|
logrus.Warnf("docker-archive: references are not supported for sources (ignoring)")
|
||||||
}
|
}
|
||||||
src := tarfile.NewSource(ref.path)
|
src, err := tarfile.NewSourceFromFile(ref.path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return &archiveImageSource{
|
return &archiveImageSource{
|
||||||
Source: src,
|
Source: src,
|
||||||
ref: ref,
|
ref: ref,
|
||||||
}
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference returns the reference used to set up this source, _as specified by the user_
|
// Reference returns the reference used to set up this source, _as specified by the user_
|
||||||
@ -30,11 +33,6 @@ func (s *archiveImageSource) Reference() types.ImageReference {
|
|||||||
return s.ref
|
return s.ref
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close removes resources associated with an initialized ImageSource, if any.
|
|
||||||
func (s *archiveImageSource) Close() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LayerInfosForCopy() returns updated layer info that should be used when reading, in preference to values in the manifest, if specified.
|
// LayerInfosForCopy() returns updated layer info that should be used when reading, in preference to values in the manifest, if specified.
|
||||||
func (s *archiveImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
|
func (s *archiveImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
7
vendor/github.com/containers/image/docker/archive/transport.go
generated
vendored
7
vendor/github.com/containers/image/docker/archive/transport.go
generated
vendored
@ -131,14 +131,17 @@ func (ref archiveReference) PolicyConfigurationNamespaces() []string {
|
|||||||
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
|
// verify that UnparsedImage, and convert it into a real Image via image.FromUnparsedImage.
|
||||||
// WARNING: This may not do the right thing for a manifest list, see image.FromSource for details.
|
// WARNING: This may not do the right thing for a manifest list, see image.FromSource for details.
|
||||||
func (ref archiveReference) NewImage(ctx *types.SystemContext) (types.ImageCloser, error) {
|
func (ref archiveReference) NewImage(ctx *types.SystemContext) (types.ImageCloser, error) {
|
||||||
src := newImageSource(ctx, ref)
|
src, err := newImageSource(ctx, ref)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return ctrImage.FromSource(ctx, src)
|
return ctrImage.FromSource(ctx, src)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewImageSource returns a types.ImageSource for this reference.
|
// NewImageSource returns a types.ImageSource for this reference.
|
||||||
// The caller must call .Close() on the returned ImageSource.
|
// The caller must call .Close() on the returned ImageSource.
|
||||||
func (ref archiveReference) NewImageSource(ctx *types.SystemContext) (types.ImageSource, error) {
|
func (ref archiveReference) NewImageSource(ctx *types.SystemContext) (types.ImageSource, error) {
|
||||||
return newImageSource(ctx, ref), nil
|
return newImageSource(ctx, ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewImageDestination returns a types.ImageDestination for this reference.
|
// NewImageDestination returns a types.ImageDestination for this reference.
|
||||||
|
31
vendor/github.com/containers/image/docker/daemon/daemon_src.go
generated
vendored
31
vendor/github.com/containers/image/docker/daemon/daemon_src.go
generated
vendored
@ -1,12 +1,7 @@
|
|||||||
package daemon
|
package daemon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/containers/image/docker/tarfile"
|
"github.com/containers/image/docker/tarfile"
|
||||||
"github.com/containers/image/internal/tmpdir"
|
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
@ -15,7 +10,6 @@ import (
|
|||||||
type daemonImageSource struct {
|
type daemonImageSource struct {
|
||||||
ref daemonReference
|
ref daemonReference
|
||||||
*tarfile.Source // Implements most of types.ImageSource
|
*tarfile.Source // Implements most of types.ImageSource
|
||||||
tarCopyPath string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type layerInfo struct {
|
type layerInfo struct {
|
||||||
@ -45,29 +39,13 @@ func newImageSource(ctx *types.SystemContext, ref daemonReference) (types.ImageS
|
|||||||
}
|
}
|
||||||
defer inputStream.Close()
|
defer inputStream.Close()
|
||||||
|
|
||||||
// FIXME: use SystemContext here.
|
src, err := tarfile.NewSourceFromStream(inputStream)
|
||||||
tarCopyFile, err := ioutil.TempFile(tmpdir.TemporaryDirectoryForBigFiles(), "docker-daemon-tar")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer tarCopyFile.Close()
|
|
||||||
|
|
||||||
succeeded := false
|
|
||||||
defer func() {
|
|
||||||
if !succeeded {
|
|
||||||
os.Remove(tarCopyFile.Name())
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
if _, err := io.Copy(tarCopyFile, inputStream); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
succeeded = true
|
|
||||||
return &daemonImageSource{
|
return &daemonImageSource{
|
||||||
ref: ref,
|
ref: ref,
|
||||||
Source: tarfile.NewSource(tarCopyFile.Name()),
|
Source: src,
|
||||||
tarCopyPath: tarCopyFile.Name(),
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,11 +55,6 @@ func (s *daemonImageSource) Reference() types.ImageReference {
|
|||||||
return s.ref
|
return s.ref
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close removes resources associated with an initialized ImageSource, if any.
|
|
||||||
func (s *daemonImageSource) Close() error {
|
|
||||||
return os.Remove(s.tarCopyPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// LayerInfosForCopy() returns updated layer info that should be used when reading, in preference to values in the manifest, if specified.
|
// LayerInfosForCopy() returns updated layer info that should be used when reading, in preference to values in the manifest, if specified.
|
||||||
func (s *daemonImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
|
func (s *daemonImageSource) LayerInfosForCopy() ([]types.BlobInfo, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
65
vendor/github.com/containers/image/docker/tarfile/src.go
generated
vendored
65
vendor/github.com/containers/image/docker/tarfile/src.go
generated
vendored
@ -3,6 +3,7 @@ package tarfile
|
|||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"compress/gzip"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
@ -10,6 +11,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
|
"github.com/containers/image/internal/tmpdir"
|
||||||
"github.com/containers/image/manifest"
|
"github.com/containers/image/manifest"
|
||||||
"github.com/containers/image/pkg/compression"
|
"github.com/containers/image/pkg/compression"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
@ -20,6 +22,7 @@ import (
|
|||||||
// Source is a partial implementation of types.ImageSource for reading from tarPath.
|
// Source is a partial implementation of types.ImageSource for reading from tarPath.
|
||||||
type Source struct {
|
type Source struct {
|
||||||
tarPath string
|
tarPath string
|
||||||
|
removeTarPathOnClose bool // Remove temp file on close if true
|
||||||
// The following data is only available after ensureCachedDataIsPresent() succeeds
|
// The following data is only available after ensureCachedDataIsPresent() succeeds
|
||||||
tarManifest *ManifestItem // nil if not available yet.
|
tarManifest *ManifestItem // nil if not available yet.
|
||||||
configBytes []byte
|
configBytes []byte
|
||||||
@ -35,14 +38,58 @@ type layerInfo struct {
|
|||||||
size int64
|
size int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSource returns a tarfile.Source for the specified path.
|
// TODO: We could add support for multiple images in a single archive, so
|
||||||
func NewSource(path string) *Source {
|
// that people could use docker-archive:opensuse.tar:opensuse:leap as
|
||||||
// TODO: We could add support for multiple images in a single archive, so
|
// the source of an image.
|
||||||
// that people could use docker-archive:opensuse.tar:opensuse:leap as
|
// To do for both the NewSourceFromFile and NewSourceFromStream functions
|
||||||
// the source of an image.
|
|
||||||
|
// NewSourceFromFile returns a tarfile.Source for the specified path
|
||||||
|
// NewSourceFromFile supports both conpressed and uncompressed input
|
||||||
|
func NewSourceFromFile(path string) (*Source, error) {
|
||||||
|
file, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "error opening file %q", path)
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
reader, err := gzip.NewReader(file)
|
||||||
|
if err != nil {
|
||||||
return &Source{
|
return &Source{
|
||||||
tarPath: path,
|
tarPath: path,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
defer reader.Close()
|
||||||
|
|
||||||
|
return NewSourceFromStream(reader)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSourceFromStream returns a tarfile.Source for the specified inputStream, which must be uncompressed.
|
||||||
|
// The caller can close the inputStream immediately after NewSourceFromFile returns.
|
||||||
|
func NewSourceFromStream(inputStream io.Reader) (*Source, error) {
|
||||||
|
// FIXME: use SystemContext here.
|
||||||
|
// Save inputStream to a temporary file
|
||||||
|
tarCopyFile, err := ioutil.TempFile(tmpdir.TemporaryDirectoryForBigFiles(), "docker-tar")
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "error creating temporary file")
|
||||||
|
}
|
||||||
|
defer tarCopyFile.Close()
|
||||||
|
|
||||||
|
succeeded := false
|
||||||
|
defer func() {
|
||||||
|
if !succeeded {
|
||||||
|
os.Remove(tarCopyFile.Name())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if _, err := io.Copy(tarCopyFile, inputStream); err != nil {
|
||||||
|
return nil, errors.Wrapf(err, "error copying contents to temporary file %q", tarCopyFile.Name())
|
||||||
|
}
|
||||||
|
succeeded = true
|
||||||
|
|
||||||
|
return &Source{
|
||||||
|
tarPath: tarCopyFile.Name(),
|
||||||
|
removeTarPathOnClose: true,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// tarReadCloser is a way to close the backing file of a tar.Reader when the user no longer needs the tar component.
|
// tarReadCloser is a way to close the backing file of a tar.Reader when the user no longer needs the tar component.
|
||||||
@ -189,6 +236,14 @@ func (s *Source) loadTarManifest() ([]ManifestItem, error) {
|
|||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close removes resources associated with an initialized Source, if any.
|
||||||
|
func (s *Source) Close() error {
|
||||||
|
if s.removeTarPathOnClose {
|
||||||
|
return os.Remove(s.tarPath)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// LoadTarManifest loads and decodes the manifest.json
|
// LoadTarManifest loads and decodes the manifest.json
|
||||||
func (s *Source) LoadTarManifest() ([]ManifestItem, error) {
|
func (s *Source) LoadTarManifest() ([]ManifestItem, error) {
|
||||||
return s.loadTarManifest()
|
return s.loadTarManifest()
|
||||||
|
2
vendor/github.com/containers/image/transports/alltransports/ostree.go
generated
vendored
2
vendor/github.com/containers/image/transports/alltransports/ostree.go
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// +build !containers_image_ostree_stub
|
// +build !containers_image_ostree_stub,linux
|
||||||
|
|
||||||
package alltransports
|
package alltransports
|
||||||
|
|
||||||
|
2
vendor/github.com/containers/image/transports/alltransports/ostree_stub.go
generated
vendored
2
vendor/github.com/containers/image/transports/alltransports/ostree_stub.go
generated
vendored
@ -1,4 +1,4 @@
|
|||||||
// +build containers_image_ostree_stub
|
// +build containers_image_ostree_stub !linux
|
||||||
|
|
||||||
package alltransports
|
package alltransports
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user