diff options
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/libpodruntime/runtime.go | 5 | ||||
-rw-r--r-- | cmd/podman/pod_ps.go | 36 | ||||
-rw-r--r-- | cmd/podman/save.go | 19 | ||||
-rw-r--r-- | cmd/podman/umount.go | 13 |
4 files changed, 37 insertions, 36 deletions
diff --git a/cmd/podman/libpodruntime/runtime.go b/cmd/podman/libpodruntime/runtime.go index 098864810..3216d288b 100644 --- a/cmd/podman/libpodruntime/runtime.go +++ b/cmd/podman/libpodruntime/runtime.go @@ -57,6 +57,11 @@ func GetDefaultStoreOptions() (storage.StoreOptions, error) { if err != nil { return storageOpts, err } + + storageConf := filepath.Join(os.Getenv("HOME"), ".config/containers/storage.conf") + if _, err := os.Stat(storageConf); err == nil { + storage.ReloadConfigurationFile(storageConf, &storageOpts) + } } return storageOpts, nil } diff --git a/cmd/podman/pod_ps.go b/cmd/podman/pod_ps.go index 470810901..0f5c7a51d 100644 --- a/cmd/podman/pod_ps.go +++ b/cmd/podman/pod_ps.go @@ -296,17 +296,13 @@ func generatePodFilterFuncs(filter, filterValue string, runtime *libpod.Runtime) return nil, errors.Errorf("%s is not a valid status", filterValue) } return func(p *libpod.Pod) bool { - ctrs, err := p.AllContainers() + ctr_statuses, err := p.Status() if err != nil { return false } - for _, ctr := range ctrs { - status, err := ctr.State() - if err != nil { - return false - } - state := status.String() - if status == libpod.ContainerStateConfigured { + for _, ctr_status := range ctr_statuses { + state := ctr_status.String() + if ctr_status == libpod.ContainerStateConfigured { state = "created" } if state == filterValue { @@ -328,11 +324,7 @@ func generatePodFilterFuncs(filter, filterValue string, runtime *libpod.Runtime) return nil, errors.Errorf("%s is not a valid pod status", filterValue) } return func(p *libpod.Pod) bool { - ctrs, err := p.AllContainers() - if err != nil { - return false - } - status, err := getPodStatus(ctrs) + status, err := getPodStatus(p) if err != nil { return false } @@ -468,8 +460,12 @@ func getPodTemplateOutput(psParams []podPsJSONParams, opts podPsOptions) ([]podP return psOutput, nil } -func getPodStatus(ctrs []*libpod.Container) (string, error) { - ctrNum := len(ctrs) +func getPodStatus(pod *libpod.Pod) (string, error) { + ctr_statuses, err := pod.Status() + if err != nil { + return ERROR, err + } + ctrNum := len(ctr_statuses) if ctrNum == 0 { return CREATED, nil } @@ -480,12 +476,8 @@ func getPodStatus(ctrs []*libpod.Container) (string, error) { CREATED: 0, ERROR: 0, } - for _, ctr := range ctrs { - state, err := ctr.State() - if err != nil { - return "", err - } - switch state { + for _, ctr_status := range ctr_statuses { + switch ctr_status { case libpod.ContainerStateStopped: statuses[STOPPED]++ case libpod.ContainerStateRunning: @@ -527,7 +519,7 @@ func getAndSortPodJSONParams(pods []*libpod.Pod, opts podPsOptions, runtime *lib return nil, err } ctrNum := len(ctrs) - status, err := getPodStatus(ctrs) + status, err := getPodStatus(pod) if err != nil { return nil, err } diff --git a/cmd/podman/save.go b/cmd/podman/save.go index 2f9adc843..016fa580a 100644 --- a/cmd/podman/save.go +++ b/cmd/podman/save.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "io" "os" "strings" @@ -118,14 +119,26 @@ func saveCmd(c *cli.Context) error { return err } } - newImage, err := runtime.ImageRuntime().NewFromLocal(args[0]) + source := args[0] + newImage, err := runtime.ImageRuntime().NewFromLocal(source) if err != nil { return err } dest := dst // need dest to be in the format transport:path:reference for the following transports - if (strings.Contains(dst, libpod.OCIArchive) || strings.Contains(dst, libpod.DockerArchive)) && !strings.Contains(newImage.ID(), args[0]) { - dest = dst + ":" + args[0] + if (strings.Contains(dst, libpod.OCIArchive) || strings.Contains(dst, libpod.DockerArchive)) && !strings.Contains(newImage.ID(), source) { + prepend := "" + if !strings.Contains(source, libpodImage.DefaultLocalRepo) { + // we need to check if localhost was added to the image name in NewFromLocal + for _, name := range newImage.Names() { + // if the user searched for the image whose tag was prepended with localhost, we'll need to prepend localhost to successfully search + if strings.Contains(name, libpodImage.DefaultLocalRepo) && strings.Contains(name, source) { + prepend = fmt.Sprintf("%s/", libpodImage.DefaultLocalRepo) + break + } + } + } + dest = fmt.Sprintf("%s:%s%s", dst, prepend, source) } if err := newImage.PushImage(getContext(), dest, manifestType, "", "", writer, c.Bool("compress"), libpodImage.SigningOptions{}, &libpodImage.DockerRegistryOptions{}, false, additionaltags); err != nil { if err2 := os.Remove(output); err2 != nil { diff --git a/cmd/podman/umount.go b/cmd/podman/umount.go index 0fd7ff144..1a2cf22c6 100644 --- a/cmd/podman/umount.go +++ b/cmd/podman/umount.go @@ -58,7 +58,7 @@ func umountCmd(c *cli.Context) error { continue } - if err = unmountContainer(ctr); err != nil { + if err = ctr.Unmount(); err != nil { if lastError != nil { logrus.Error(lastError) } @@ -78,7 +78,7 @@ func umountCmd(c *cli.Context) error { continue } - if err = unmountContainer(ctr); err != nil { + if err = ctr.Unmount(); err != nil { if lastError != nil { logrus.Error(lastError) } @@ -90,12 +90,3 @@ func umountCmd(c *cli.Context) error { } return lastError } - -func unmountContainer(ctr *libpod.Container) error { - if mounted, err := ctr.Mounted(); mounted { - return ctr.Unmount() - } else { - return err - } - return errors.Errorf("container is not mounted") -} |