aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/podmanimage/README.md15
-rw-r--r--pkg/domain/infra/abi/containers_runlabel.go19
-rw-r--r--pkg/domain/infra/abi/containers_runlabel_test.go40
3 files changed, 64 insertions, 10 deletions
diff --git a/contrib/podmanimage/README.md b/contrib/podmanimage/README.md
index 32590d185..6effec38b 100644
--- a/contrib/podmanimage/README.md
+++ b/contrib/podmanimage/README.md
@@ -1,4 +1,4 @@
-![PODMAN logo](logo/podman-logo-source.svg)
+![PODMAN logo](../../logo/podman-logo-source.svg)
# podmanimage
@@ -17,22 +17,21 @@ default to `/`.
The container images are:
* `quay.io/containers/podman:<version>` and `quay.io/podman/stable:<version>` -
- These images are built when a new podman version becomes available in
+ These images are built when a new Podman version becomes available in
Fedora. These images are intended to be unchanging and stable, they will
- never be updated by automation once they've been pushed. For build
- details, see the configuration used to build it,
- [podmanimage/stable/Dockerfile](stable/Dockerfile).
+ never be updated by automation once they've been pushed. For build details,
+ please [see the configuration file](stable/Dockerfile).
* `quay.io/containers/podman:latest` and `quay.io/podman/stable:latest` -
- Built daily using the same Containerfile as above. The podman version
+ Built daily using the same Dockerfile as above. The Podman version
will remain the "latest" available in Fedora, however the other image
contents may vary compared to the version-tagged images.
* `quay.io/podman/testing:latest` - This image is built daily, using the
latest version of Podman that was in the Fedora `updates-testing` repository.
- The image is Built with [podmanimage/testing/Dockerfile](testing/Dockerfile).
+ The image is Built with [the testing Dockerfile](testing/Dockerfile).
* `quay.io/podman/upstream:latest` - This image is built daily using the latest
code found in this GitHub repository. Due to the image changing frequently,
it's not guaranteed to be stable or even executable. The image is built with
- [podmanimage/upstream/Dockerfile](upstream/Dockerfile).
+ [the upstream Dockerfile](upstream/Dockerfile).
## Sample Usage
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
diff --git a/pkg/domain/infra/abi/containers_runlabel_test.go b/pkg/domain/infra/abi/containers_runlabel_test.go
new file mode 100644
index 000000000..10f9ae004
--- /dev/null
+++ b/pkg/domain/infra/abi/containers_runlabel_test.go
@@ -0,0 +1,40 @@
+package abi
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestReplaceName(t *testing.T) {
+ tests := [][]string{
+ {"NAME=$NAME", "test1", "NAME=test1"},
+ {"NAME=${NAME}", "test2", "NAME=test2"},
+ {"NAME=NAME", "test3", "NAME=test3"},
+ {"NAME=NAMEFOO", "test3", "NAME=NAMEFOO"},
+ {"NAME", "test4", "test4"},
+ {"FNAME", "test5", "FNAME"},
+ {"NAME=foo", "test6", "NAME=foo"},
+ {"This is my NAME", "test7", "This is my NAME"},
+ }
+ for _, args := range tests {
+ val := replaceName(args[0], args[1])
+ assert.Equal(t, val, args[2])
+ }
+}
+
+func TestReplaceImage(t *testing.T) {
+ tests := [][]string{
+ {"IMAGE=$IMAGE", "test1", "IMAGE=test1"},
+ {"IMAGE=${IMAGE}", "test2", "IMAGE=test2"},
+ {"IMAGE=IMAGE", "test3", "IMAGE=test3"},
+ {"IMAGE=IMAGEFOO", "test3", "IMAGE=IMAGEFOO"},
+ {"IMAGE", "test4", "test4"},
+ {"FIMAGE", "test5", "FIMAGE"},
+ {"IMAGE=foo", "test6", "IMAGE=foo"},
+ }
+ for _, args := range tests {
+ val := replaceImage(args[0], args[1])
+ assert.Equal(t, val, args[2])
+ }
+}