diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-05-05 16:47:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-05 16:47:59 -0400 |
commit | ed6f399770946bb2e88f8b94e1d2f279208648d4 (patch) | |
tree | 21d94cb2d4d3571952a933ea98cfd6f701c52a2d /pkg/domain/infra/abi/containers_runlabel.go | |
parent | db48da4d99a69171c0ae9998ea527e6b31e0c680 (diff) | |
parent | f8846bd17b5c6dacb5908112ec24ce332185e5d1 (diff) | |
download | podman-ed6f399770946bb2e88f8b94e1d2f279208648d4.tar.gz podman-ed6f399770946bb2e88f8b94e1d2f279208648d4.tar.bz2 podman-ed6f399770946bb2e88f8b94e1d2f279208648d4.zip |
Merge pull request #10193 from rhatdan/runlabel
Fix handling of runlabel IMAGE and NAME
Diffstat (limited to 'pkg/domain/infra/abi/containers_runlabel.go')
-rw-r--r-- | pkg/domain/infra/abi/containers_runlabel.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/pkg/domain/infra/abi/containers_runlabel.go b/pkg/domain/infra/abi/containers_runlabel.go index 199ae43ad..d448627dc 100644 --- a/pkg/domain/infra/abi/containers_runlabel.go +++ b/pkg/domain/infra/abi/containers_runlabel.go @@ -180,13 +180,28 @@ func generateRunlabelCommand(runlabel string, img *libimage.Image, inputName str } func replaceName(arg, name string) string { + if arg == "NAME" { + return name + } + newarg := strings.ReplaceAll(arg, "$NAME", name) - return strings.ReplaceAll(newarg, "${NAME}", name) + newarg = strings.ReplaceAll(newarg, "${NAME}", name) + if strings.HasSuffix(newarg, "=NAME") { + newarg = strings.ReplaceAll(newarg, "=NAME", fmt.Sprintf("=%s", name)) + } + return newarg } func replaceImage(arg, image string) string { + if arg == "IMAGE" { + return image + } newarg := strings.ReplaceAll(arg, "$IMAGE", image) - return strings.ReplaceAll(newarg, "${IMAGE}", image) + newarg = strings.ReplaceAll(newarg, "${IMAGE}", image) + if strings.HasSuffix(newarg, "=IMAGE") { + newarg = strings.ReplaceAll(newarg, "=IMAGE", fmt.Sprintf("=%s", image)) + } + return newarg } // generateCommand takes a label (string) and converts it to an executable command |