Begin converting kpod pull to use libpod/runtime
We want to drop brute force mechainism for handling image movement, this patch experiments with moving kpod pull to use new libpod interfaces. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
e18e962238
commit
9f282717da
5 changed files with 31 additions and 30 deletions
|
@ -8,7 +8,9 @@ import (
|
|||
"github.com/containers/storage"
|
||||
"github.com/fatih/camelcase"
|
||||
"github.com/kubernetes-incubator/cri-o/libkpod"
|
||||
"github.com/kubernetes-incubator/cri-o/libpod"
|
||||
"github.com/kubernetes-incubator/cri-o/server"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -32,6 +34,22 @@ func getStore(c *libkpod.Config) (storage.Store, error) {
|
|||
return store, nil
|
||||
}
|
||||
|
||||
func getRuntime(c *cli.Context) (*libpod.Runtime, error) {
|
||||
|
||||
config, err := getConfig(c)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get config")
|
||||
}
|
||||
|
||||
options := storage.DefaultStoreOptions
|
||||
options.GraphRoot = config.Root
|
||||
options.RunRoot = config.RunRoot
|
||||
options.GraphDriverName = config.Storage
|
||||
options.GraphDriverOptions = config.StorageOptions
|
||||
|
||||
return libpod.NewRuntime(libpod.WithStorageConfig(options))
|
||||
}
|
||||
|
||||
func shutdownStores() {
|
||||
for store := range stores {
|
||||
if _, err := store.Shutdown(false); err != nil {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/kubernetes-incubator/cri-o/libkpod/common"
|
||||
"github.com/kubernetes-incubator/cri-o/libpod/images"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
|
@ -45,21 +45,11 @@ func pullCmd(c *cli.Context) error {
|
|||
}
|
||||
image := args[0]
|
||||
|
||||
config, err := getConfig(c)
|
||||
runtime, err := getRuntime(c)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "could not get config")
|
||||
return errors.Wrapf(err, "could not create runtime")
|
||||
}
|
||||
store, err := getStore(config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
allTags := c.Bool("all-tags")
|
||||
|
||||
systemContext := common.GetSystemContext("")
|
||||
|
||||
err = images.PullImage(store, image, allTags, false, systemContext)
|
||||
if err != nil {
|
||||
if err := runtime.PullImage(image, c.Bool("all-tags"), os.Stdout); err != nil {
|
||||
return errors.Errorf("error pulling image from %q: %v", image, err)
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/containers/image/types"
|
||||
"github.com/containers/storage/pkg/archive"
|
||||
"github.com/kubernetes-incubator/cri-o/libkpod/common"
|
||||
"github.com/kubernetes-incubator/cri-o/libpod/common"
|
||||
"github.com/kubernetes-incubator/cri-o/libpod/images"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
|
@ -103,7 +103,7 @@ func pushCmd(c *cli.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
options := libkpodimage.CopyOptions{
|
||||
options := images.CopyOptions{
|
||||
Compression: archive.Uncompressed,
|
||||
SignaturePolicyPath: signaturePolicy,
|
||||
Store: store,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue