summaryrefslogtreecommitdiff
path: root/cmd/podman/import.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-04-23 13:32:41 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-04-26 19:14:44 +0000
commit39a7a773a653176e294382bc6301275fd57aff6b (patch)
tree334db314ef5681bd6979e2be91dd39640f8e00ff /cmd/podman/import.go
parent0ccfd7dc20c11bc2f9d646c98cc67fb399cd9013 (diff)
downloadpodman-39a7a773a653176e294382bc6301275fd57aff6b.tar.gz
podman-39a7a773a653176e294382bc6301275fd57aff6b.tar.bz2
podman-39a7a773a653176e294382bc6301275fd57aff6b.zip
varlink images
implement varlink image functions for working with libpod with the exception of a couple due to incompletions on the libpod side of things (build). also, created a first pass at a libpodpy package which will stand as a client to working with libpod's varlink methods using python. Signed-off-by: baude <bbaude@redhat.com> Closes: #669 Approved by: baude
Diffstat (limited to 'cmd/podman/import.go')
-rw-r--r--cmd/podman/import.go72
1 files changed, 4 insertions, 68 deletions
diff --git a/cmd/podman/import.go b/cmd/podman/import.go
index f57d70af0..5a4fa45d9 100644
--- a/cmd/podman/import.go
+++ b/cmd/podman/import.go
@@ -7,11 +7,12 @@ import (
"net/http"
"net/url"
"os"
- "strings"
"github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
+ "github.com/projectatomic/libpod/cmd/podman/libpodruntime"
"github.com/projectatomic/libpod/libpod/image"
+ "github.com/projectatomic/libpod/pkg/util"
"github.com/urfave/cli"
)
@@ -49,7 +50,7 @@ func importCmd(c *cli.Context) error {
return err
}
- runtime, err := getRuntime(c)
+ runtime, err := libpodruntime.GetRuntime(c)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
@@ -76,7 +77,7 @@ func importCmd(c *cli.Context) error {
changes := v1.ImageConfig{}
if c.IsSet("change") {
- changes, err = getImageConfig(c.StringSlice("change"))
+ changes, err = util.GetImageConfig(c.StringSlice("change"))
if err != nil {
return errors.Wrapf(err, "error adding config changes to image %q", source)
}
@@ -138,68 +139,3 @@ func downloadFromURL(source string) (string, error) {
return outFile.Name(), nil
}
-
-// getImageConfig converts the --change flag values in the format "CMD=/bin/bash USER=example"
-// to a type v1.ImageConfig
-func getImageConfig(changes []string) (v1.ImageConfig, error) {
- // USER=value | EXPOSE=value | ENV=value | ENTRYPOINT=value |
- // CMD=value | VOLUME=value | WORKDIR=value | LABEL=key=value | STOPSIGNAL=value
-
- var (
- user string
- env []string
- entrypoint []string
- cmd []string
- workingDir string
- stopSignal string
- )
-
- exposedPorts := make(map[string]struct{})
- volumes := make(map[string]struct{})
- labels := make(map[string]string)
-
- for _, ch := range changes {
- pair := strings.Split(ch, "=")
- if len(pair) == 1 {
- return v1.ImageConfig{}, errors.Errorf("no value given for instruction %q", ch)
- }
- switch pair[0] {
- case "USER":
- user = pair[1]
- case "EXPOSE":
- var st struct{}
- exposedPorts[pair[1]] = st
- case "ENV":
- env = append(env, pair[1])
- case "ENTRYPOINT":
- entrypoint = append(entrypoint, pair[1])
- case "CMD":
- cmd = append(cmd, pair[1])
- case "VOLUME":
- var st struct{}
- volumes[pair[1]] = st
- case "WORKDIR":
- workingDir = pair[1]
- case "LABEL":
- if len(pair) == 3 {
- labels[pair[1]] = pair[2]
- } else {
- labels[pair[1]] = ""
- }
- case "STOPSIGNAL":
- stopSignal = pair[1]
- }
- }
-
- return v1.ImageConfig{
- User: user,
- ExposedPorts: exposedPorts,
- Env: env,
- Entrypoint: entrypoint,
- Cmd: cmd,
- Volumes: volumes,
- WorkingDir: workingDir,
- Labels: labels,
- StopSignal: stopSignal,
- }, nil
-}