mirror of
https://github.com/containers/podman.git
synced 2025-05-20 16:47:39 +08:00
Stage 4 Image cleanup
Cull funcs from runtime_img.go which are no longer needed. Also, fix any remaining spots that use the old image technique. Signed-off-by: baude <bbaude@redhat.com> Closes: #532 Approved by: mheon
This commit is contained in:
@ -82,7 +82,7 @@ var (
|
|||||||
|
|
||||||
func imagesCmd(c *cli.Context) error {
|
func imagesCmd(c *cli.Context) error {
|
||||||
var (
|
var (
|
||||||
filterFuncs []libpod.ImageResultFilter
|
filterFuncs []image.ResultFilter
|
||||||
newImage *image.Image
|
newImage *image.Image
|
||||||
)
|
)
|
||||||
if err := validateFlags(c, imagesFlags); err != nil {
|
if err := validateFlags(c, imagesFlags); err != nil {
|
||||||
@ -136,7 +136,7 @@ func imagesCmd(c *cli.Context) error {
|
|||||||
var filteredImages []*image.Image
|
var filteredImages []*image.Image
|
||||||
// filter the images
|
// filter the images
|
||||||
if len(c.StringSlice("filter")) > 0 || newImage != nil {
|
if len(c.StringSlice("filter")) > 0 || newImage != nil {
|
||||||
filteredImages = libpod.FilterImages(images, filterFuncs)
|
filteredImages = image.FilterImages(images, filterFuncs)
|
||||||
} else {
|
} else {
|
||||||
filteredImages = images
|
filteredImages = images
|
||||||
}
|
}
|
||||||
@ -266,8 +266,8 @@ func (i *imagesTemplateParams) HeaderMap() map[string]string {
|
|||||||
|
|
||||||
// CreateFilterFuncs returns an array of filter functions based on the user inputs
|
// CreateFilterFuncs returns an array of filter functions based on the user inputs
|
||||||
// and is later used to filter images for output
|
// and is later used to filter images for output
|
||||||
func CreateFilterFuncs(r *libpod.Runtime, c *cli.Context, image *image.Image) ([]libpod.ImageResultFilter, error) {
|
func CreateFilterFuncs(r *libpod.Runtime, c *cli.Context, img *image.Image) ([]image.ResultFilter, error) {
|
||||||
var filterFuncs []libpod.ImageResultFilter
|
var filterFuncs []image.ResultFilter
|
||||||
for _, filter := range c.StringSlice("filter") {
|
for _, filter := range c.StringSlice("filter") {
|
||||||
splitFilter := strings.Split(filter, "=")
|
splitFilter := strings.Split(filter, "=")
|
||||||
switch splitFilter[0] {
|
switch splitFilter[0] {
|
||||||
@ -276,24 +276,24 @@ func CreateFilterFuncs(r *libpod.Runtime, c *cli.Context, image *image.Image) ([
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "unable to find image % in local stores", splitFilter[1])
|
return nil, errors.Wrapf(err, "unable to find image % in local stores", splitFilter[1])
|
||||||
}
|
}
|
||||||
filterFuncs = append(filterFuncs, libpod.ImageCreatedBefore(before.Created()))
|
filterFuncs = append(filterFuncs, image.CreatedBeforeFilter(before.Created()))
|
||||||
case "after":
|
case "after":
|
||||||
after, err := r.ImageRuntime().NewFromLocal(splitFilter[1])
|
after, err := r.ImageRuntime().NewFromLocal(splitFilter[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "unable to find image % in local stores", splitFilter[1])
|
return nil, errors.Wrapf(err, "unable to find image % in local stores", splitFilter[1])
|
||||||
}
|
}
|
||||||
filterFuncs = append(filterFuncs, libpod.ImageCreatedAfter(after.Created()))
|
filterFuncs = append(filterFuncs, image.CreatedAfterFilter(after.Created()))
|
||||||
case "dangling":
|
case "dangling":
|
||||||
filterFuncs = append(filterFuncs, libpod.ImageDangling())
|
filterFuncs = append(filterFuncs, image.DanglingFilter())
|
||||||
case "label":
|
case "label":
|
||||||
labelFilter := strings.Join(splitFilter[1:], "=")
|
labelFilter := strings.Join(splitFilter[1:], "=")
|
||||||
filterFuncs = append(filterFuncs, libpod.ImageLabel(labelFilter))
|
filterFuncs = append(filterFuncs, image.LabelFilter(labelFilter))
|
||||||
default:
|
default:
|
||||||
return nil, errors.Errorf("invalid filter %s ", splitFilter[0])
|
return nil, errors.Errorf("invalid filter %s ", splitFilter[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if image != nil {
|
if img != nil {
|
||||||
filterFuncs = append(filterFuncs, libpod.OutputImageFilter(image))
|
filterFuncs = append(filterFuncs, image.OutputImageFilter(img))
|
||||||
}
|
}
|
||||||
return filterFuncs, nil
|
return filterFuncs, nil
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ func importCmd(c *cli.Context) error {
|
|||||||
source = file
|
source = file
|
||||||
}
|
}
|
||||||
|
|
||||||
newImage, err := runtime.Import(source, reference, writer, image.SigningOptions{}, config)
|
newImage, err := runtime.ImageRuntime().Import(source, reference, writer, image.SigningOptions{}, config)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
fmt.Println(newImage.ID())
|
fmt.Println(newImage.ID())
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/projectatomic/libpod/libpod"
|
"github.com/projectatomic/libpod/libpod"
|
||||||
|
libpodImage "github.com/projectatomic/libpod/libpod/image"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ func loadCmd(c *cli.Context) error {
|
|||||||
|
|
||||||
args := c.Args()
|
args := c.Args()
|
||||||
var image string
|
var image string
|
||||||
|
|
||||||
if len(args) == 1 {
|
if len(args) == 1 {
|
||||||
image = args[0]
|
image = args[0]
|
||||||
}
|
}
|
||||||
@ -96,28 +98,23 @@ func loadCmd(c *cli.Context) error {
|
|||||||
writer = os.Stderr
|
writer = os.Stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
options := libpod.CopyOptions{
|
|
||||||
SignaturePolicyPath: c.String("signature-policy"),
|
|
||||||
Writer: writer,
|
|
||||||
}
|
|
||||||
|
|
||||||
src := libpod.DockerArchive + ":" + input
|
src := libpod.DockerArchive + ":" + input
|
||||||
imgName, err := runtime.PullImage(src, options)
|
newImage, err := runtime.ImageRuntime().New(src, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// generate full src name with specified image:tag
|
// generate full src name with specified image:tag
|
||||||
fullSrc := libpod.OCIArchive + ":" + input
|
fullSrc := libpod.OCIArchive + ":" + input
|
||||||
if image != "" {
|
if image != "" {
|
||||||
fullSrc = fullSrc + ":" + image
|
fullSrc = fullSrc + ":" + image
|
||||||
}
|
}
|
||||||
imgName, err = runtime.PullImage(fullSrc, options)
|
newImage, err = runtime.ImageRuntime().New(fullSrc, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
src = libpod.DirTransport + ":" + input
|
src = libpod.DirTransport + ":" + input
|
||||||
imgName, err = runtime.PullImage(src, options)
|
newImage, err = runtime.ImageRuntime().New(src, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "error pulling %q", src)
|
return errors.Wrapf(err, "error pulling %q", src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("Loaded image: ", imgName)
|
fmt.Println("Loaded image: ", newImage.InputName)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/projectatomic/libpod/libpod"
|
image2 "github.com/projectatomic/libpod/libpod/image"
|
||||||
"github.com/projectatomic/libpod/libpod/common"
|
|
||||||
"github.com/projectatomic/libpod/pkg/util"
|
"github.com/projectatomic/libpod/pkg/util"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
@ -94,27 +93,19 @@ func pullCmd(c *cli.Context) error {
|
|||||||
writer = os.Stderr
|
writer = os.Stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
options := libpod.CopyOptions{
|
dockerRegistryOptions := image2.DockerRegistryOptions{
|
||||||
SignaturePolicyPath: c.String("signature-policy"),
|
|
||||||
AuthFile: c.String("authfile"),
|
|
||||||
DockerRegistryOptions: common.DockerRegistryOptions{
|
|
||||||
DockerRegistryCreds: registryCreds,
|
DockerRegistryCreds: registryCreds,
|
||||||
DockerCertPath: c.String("cert-dir"),
|
DockerCertPath: c.String("cert-dir"),
|
||||||
DockerInsecureSkipTLSVerify: !c.BoolT("tls-verify"),
|
DockerInsecureSkipTLSVerify: !c.BoolT("tls-verify"),
|
||||||
},
|
|
||||||
Writer: writer,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := runtime.PullImage(image, options); err != nil {
|
newImage, err := runtime.ImageRuntime().New(image, c.String("signature-policy"), c.String("authfile"), writer, &dockerRegistryOptions, image2.SigningOptions{})
|
||||||
|
if err != nil {
|
||||||
return errors.Wrapf(err, "error pulling image %q", image)
|
return errors.Wrapf(err, "error pulling image %q", image)
|
||||||
}
|
}
|
||||||
|
|
||||||
newImage := runtime.NewImage(image)
|
|
||||||
iid, err := newImage.GetImageID()
|
|
||||||
// Intentially choosing to ignore if there is an error because
|
// Intentially choosing to ignore if there is an error because
|
||||||
// outputting the image ID is a NTH and not integral to the pull
|
// outputting the image ID is a NTH and not integral to the pull
|
||||||
if err == nil {
|
fmt.Println(newImage.ID())
|
||||||
fmt.Println(iid)
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,10 @@ import (
|
|||||||
|
|
||||||
"github.com/containers/image/manifest"
|
"github.com/containers/image/manifest"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/containers/storage/pkg/archive"
|
|
||||||
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/projectatomic/libpod/libpod"
|
"github.com/projectatomic/libpod/libpod"
|
||||||
"github.com/projectatomic/libpod/libpod/common"
|
"github.com/projectatomic/libpod/libpod/image"
|
||||||
"github.com/projectatomic/libpod/pkg/util"
|
"github.com/projectatomic/libpod/pkg/util"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -135,23 +134,22 @@ func pushCmd(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
options := libpod.CopyOptions{
|
dockerRegistryOptions := image.DockerRegistryOptions{
|
||||||
Compression: archive.Uncompressed,
|
|
||||||
SignaturePolicyPath: c.String("signature-policy"),
|
|
||||||
DockerRegistryOptions: common.DockerRegistryOptions{
|
|
||||||
DockerRegistryCreds: registryCreds,
|
DockerRegistryCreds: registryCreds,
|
||||||
DockerCertPath: certPath,
|
DockerCertPath: certPath,
|
||||||
DockerInsecureSkipTLSVerify: skipVerify,
|
DockerInsecureSkipTLSVerify: skipVerify,
|
||||||
},
|
|
||||||
SigningOptions: common.SigningOptions{
|
|
||||||
RemoveSignatures: removeSignatures,
|
|
||||||
SignBy: signBy,
|
|
||||||
},
|
|
||||||
AuthFile: c.String("authfile"),
|
|
||||||
Writer: writer,
|
|
||||||
ManifestMIMEType: manifestType,
|
|
||||||
ForceCompress: c.Bool("compress"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return runtime.PushImage(srcName, destName, options)
|
so := image.SigningOptions{
|
||||||
|
RemoveSignatures: removeSignatures,
|
||||||
|
SignBy: signBy,
|
||||||
|
}
|
||||||
|
|
||||||
|
newImage, err := runtime.ImageRuntime().NewFromLocal(srcName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
//return runtime.PushImage(srcName, destName, options)
|
||||||
|
return newImage.PushImage(destName, manifestType, c.String("authfile"), c.String("signature-policy"), writer, c.Bool("compress"), so, &dockerRegistryOptions)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/projectatomic/libpod/libpod"
|
|
||||||
"github.com/projectatomic/libpod/libpod/image"
|
"github.com/projectatomic/libpod/libpod/image"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -56,7 +55,7 @@ func rmiCmd(c *cli.Context) error {
|
|||||||
var lastError error
|
var lastError error
|
||||||
var imagesToDelete []*image.Image
|
var imagesToDelete []*image.Image
|
||||||
if removeAll {
|
if removeAll {
|
||||||
imagesToDelete, err = runtime.GetImages(&libpod.ImageFilterParams{})
|
imagesToDelete, err = runtime.ImageRuntime().GetImages()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "unable to query local images")
|
return errors.Wrapf(err, "unable to query local images")
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/projectatomic/libpod/libpod"
|
"github.com/projectatomic/libpod/libpod"
|
||||||
|
libpodImage "github.com/projectatomic/libpod/libpod/image"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -104,13 +105,6 @@ func saveCmd(c *cli.Context) error {
|
|||||||
return errors.Errorf("unknown format option %q", c.String("format"))
|
return errors.Errorf("unknown format option %q", c.String("format"))
|
||||||
}
|
}
|
||||||
|
|
||||||
saveOpts := libpod.CopyOptions{
|
|
||||||
SignaturePolicyPath: "",
|
|
||||||
Writer: writer,
|
|
||||||
ManifestMIMEType: manifestType,
|
|
||||||
ForceCompress: c.Bool("compress"),
|
|
||||||
}
|
|
||||||
|
|
||||||
// only one image is supported for now
|
// only one image is supported for now
|
||||||
// future pull requests will fix this
|
// future pull requests will fix this
|
||||||
for _, image := range args {
|
for _, image := range args {
|
||||||
@ -119,7 +113,11 @@ func saveCmd(c *cli.Context) error {
|
|||||||
if strings.Contains(dst, libpod.OCIArchive) || strings.Contains(dst, libpod.DockerArchive) {
|
if strings.Contains(dst, libpod.OCIArchive) || strings.Contains(dst, libpod.DockerArchive) {
|
||||||
dest = dst + ":" + image
|
dest = dst + ":" + image
|
||||||
}
|
}
|
||||||
if err := runtime.PushImage(image, dest, saveOpts); err != nil {
|
newImage, err := runtime.ImageRuntime().NewFromLocal(image)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := newImage.PushImage(dest, manifestType, "", "", writer, c.Bool("compress"), libpodImage.SigningOptions{}, &libpodImage.DockerRegistryOptions{}); err != nil {
|
||||||
if err2 := os.Remove(output); err2 != nil {
|
if err2 := os.Remove(output); err2 != nil {
|
||||||
logrus.Errorf("error deleting %q: %v", output, err)
|
logrus.Errorf("error deleting %q: %v", output, err)
|
||||||
}
|
}
|
||||||
|
@ -565,7 +565,7 @@ func (c *Container) Commit(pause bool, reference string, writer io.Writer, signi
|
|||||||
if err := c.export(tempFile.Name()); err != nil {
|
if err := c.export(tempFile.Name()); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return image.Import(tempFile.Name(), reference, writer, signingOptions, imageConfig, c.runtime.imageRuntime)
|
return c.runtime.imageRuntime.Import(tempFile.Name(), reference, writer, signingOptions, imageConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait blocks on a container to exit and returns its exit code
|
// Wait blocks on a container to exit and returns its exit code
|
||||||
|
@ -27,7 +27,7 @@ func (r *Runtime) GetDiff(from, to string) ([]archive.Change, error) {
|
|||||||
// If the id matches a layer, the top layer id is returned
|
// If the id matches a layer, the top layer id is returned
|
||||||
func (r *Runtime) getLayerID(id string) (string, error) {
|
func (r *Runtime) getLayerID(id string) (string, error) {
|
||||||
var toLayer string
|
var toLayer string
|
||||||
toImage, err := r.GetImage(id)
|
toImage, err := r.imageRuntime.NewFromLocal(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
toCtr, err := r.store.Container(id)
|
toCtr, err := r.store.Container(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -39,7 +39,7 @@ func (r *Runtime) getLayerID(id string) (string, error) {
|
|||||||
toLayer = toCtr.LayerID
|
toLayer = toCtr.LayerID
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toLayer = toImage.TopLayer
|
toLayer = toImage.TopLayer()
|
||||||
}
|
}
|
||||||
return toLayer, nil
|
return toLayer, nil
|
||||||
}
|
}
|
||||||
|
82
libpod/image/filters.go
Normal file
82
libpod/image/filters.go
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
package image
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/projectatomic/libpod/pkg/inspect"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ResultFilter is a mock function for image filtering
|
||||||
|
type ResultFilter func(*Image) bool
|
||||||
|
|
||||||
|
// Filter is a function to determine whether an image is included in
|
||||||
|
// command output. Images to be outputted are tested using the function. A true
|
||||||
|
// return will include the image, a false return will exclude it.
|
||||||
|
type Filter func(*Image, *inspect.ImageData) bool
|
||||||
|
|
||||||
|
// CreatedBeforeFilter allows you to filter on images created before
|
||||||
|
// the given time.Time
|
||||||
|
func CreatedBeforeFilter(createTime time.Time) ResultFilter {
|
||||||
|
return func(i *Image) bool {
|
||||||
|
return i.Created().Before(createTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAfterFilter allows you to filter on images created after
|
||||||
|
// the given time.Time
|
||||||
|
func CreatedAfterFilter(createTime time.Time) ResultFilter {
|
||||||
|
return func(i *Image) bool {
|
||||||
|
return i.Created().After(createTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DanglingFilter allows you to filter images for dangling images
|
||||||
|
func DanglingFilter() ResultFilter {
|
||||||
|
return func(i *Image) bool {
|
||||||
|
return i.Dangling()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LabelFilter allows you to filter by images labels key and/or value
|
||||||
|
func LabelFilter(labelfilter string) ResultFilter {
|
||||||
|
// We need to handle both label=key and label=key=value
|
||||||
|
return func(i *Image) bool {
|
||||||
|
var value string
|
||||||
|
splitFilter := strings.Split(labelfilter, "=")
|
||||||
|
key := splitFilter[0]
|
||||||
|
if len(splitFilter) > 1 {
|
||||||
|
value = splitFilter[1]
|
||||||
|
}
|
||||||
|
labels, err := i.Labels()
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(strings.TrimSpace(labels[key])) > 0 && len(strings.TrimSpace(value)) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return labels[key] == value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OutputImageFilter allows you to filter by an a specific image name
|
||||||
|
func OutputImageFilter(userImage *Image) ResultFilter {
|
||||||
|
return func(i *Image) bool {
|
||||||
|
return userImage.ID() == i.ID()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterImages filters images using a set of predefined fitler funcs
|
||||||
|
func FilterImages(images []*Image, filters []ResultFilter) []*Image {
|
||||||
|
var filteredImages []*Image
|
||||||
|
for _, image := range images {
|
||||||
|
include := true
|
||||||
|
for _, filter := range filters {
|
||||||
|
include = include && filter(image)
|
||||||
|
}
|
||||||
|
if include {
|
||||||
|
filteredImages = append(filteredImages, image)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filteredImages
|
||||||
|
}
|
@ -641,7 +641,7 @@ func (i *Image) Inspect() (*inspect.ImageData, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Import imports and image into the store and returns an image
|
// Import imports and image into the store and returns an image
|
||||||
func Import(path, reference string, writer io.Writer, signingOptions SigningOptions, imageConfig ociv1.Image, runtime *Runtime) (*Image, error) {
|
func (ir *Runtime) Import(path, reference string, writer io.Writer, signingOptions SigningOptions, imageConfig ociv1.Image) (*Image, error) {
|
||||||
file := TarballTransport + ":" + path
|
file := TarballTransport + ":" + path
|
||||||
src, err := alltransports.ParseImageName(file)
|
src, err := alltransports.ParseImageName(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -676,14 +676,14 @@ func Import(path, reference string, writer io.Writer, signingOptions SigningOpti
|
|||||||
}
|
}
|
||||||
defer policyContext.Destroy()
|
defer policyContext.Destroy()
|
||||||
copyOptions := getCopyOptions(writer, "", nil, nil, signingOptions, "", "", false)
|
copyOptions := getCopyOptions(writer, "", nil, nil, signingOptions, "", "", false)
|
||||||
dest, err := is.Transport.ParseStoreReference(runtime.store, reference)
|
dest, err := is.Transport.ParseStoreReference(ir.store, reference)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors.Wrapf(err, "error getting image reference for %q", reference)
|
errors.Wrapf(err, "error getting image reference for %q", reference)
|
||||||
}
|
}
|
||||||
if err = cp.Image(policyContext, dest, src, copyOptions); err != nil {
|
if err = cp.Image(policyContext, dest, src, copyOptions); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return runtime.NewFromLocal(reference)
|
return ir.NewFromLocal(reference)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MatchRepoTag takes a string and tries to match it against an
|
// MatchRepoTag takes a string and tries to match it against an
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -47,11 +47,6 @@ func FuncTimer(funcName string) {
|
|||||||
fmt.Printf("%s executed in %d ms\n", funcName, elapsed)
|
fmt.Printf("%s executed in %d ms\n", funcName, elapsed)
|
||||||
}
|
}
|
||||||
|
|
||||||
// hasTransport determines if the image string contains '://', returns bool
|
|
||||||
func hasTransport(image string) bool {
|
|
||||||
return strings.Contains(image, "://")
|
|
||||||
}
|
|
||||||
|
|
||||||
// CopyStringStringMap deep copies a map[string]string and returns the result
|
// CopyStringStringMap deep copies a map[string]string and returns the result
|
||||||
func CopyStringStringMap(m map[string]string) map[string]string {
|
func CopyStringStringMap(m map[string]string) map[string]string {
|
||||||
n := map[string]string{}
|
n := map[string]string{}
|
||||||
|
Reference in New Issue
Block a user