summaryrefslogtreecommitdiff
path: root/libpod/image
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-01-03 14:53:05 -0600
committerbaude <bbaude@redhat.com>2019-01-04 12:57:55 -0600
commit10a62d60a9b27626a47ab2bee00c32febb21f0e9 (patch)
tree6d3117e882dcadb0c5cc61f216ed5c6fc0ee6381 /libpod/image
parent133469681486788591f6979f853c662ccf7f9118 (diff)
downloadpodman-10a62d60a9b27626a47ab2bee00c32febb21f0e9.tar.gz
podman-10a62d60a9b27626a47ab2bee00c32febb21f0e9.tar.bz2
podman-10a62d60a9b27626a47ab2bee00c32febb21f0e9.zip
container runlabel NAME implementation
when using container runlabel, if a --name is not provided, we must deduce the container name from the base name of the image to maintain parity with the atomic cli. fixed small bug where we split the cmd on " " rather than using fields could lead to extra spaces in command output. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/image')
-rw-r--r--libpod/image/parts.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/libpod/image/parts.go b/libpod/image/parts.go
index 1509005e5..9adf26fb9 100644
--- a/libpod/image/parts.go
+++ b/libpod/image/parts.go
@@ -22,6 +22,18 @@ func isRegistry(name string) bool {
return strings.ContainsAny(name, ".:") || name == "localhost"
}
+// GetImageBaseName uses decompose and string splits to obtain the base
+// name of an image. Doing this here because it beats changing the
+// imageParts struct names to be exported as well.
+func GetImageBaseName(input string) (string, error) {
+ decomposedImage, err := decompose(input)
+ if err != nil {
+ return "", err
+ }
+ splitImageName := strings.Split(decomposedImage.name, "/")
+ return splitImageName[len(splitImageName)-1], nil
+}
+
// decompose breaks an input name into an imageParts description
func decompose(input string) (imageParts, error) {
var (