Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: setting the container name to the image
In commit 47ac961 the image name that is used for setting the container name is taken from the resolved image unless it is empty. The image has the "Names" field and right now the first name is taken. However, when the image is a tagged image, the container name will end up using the original name instead of the given one. For example: $ buildah tag busybox busybox1 $ buildah from busybox1 Will set the name of the container as "busybox-working-container" while it was expected to be "busybox1-working-container". This patch fixes this particular issue. Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com> Closes: #399 Approved by: rhatdan
- Loading branch information
1 parent
2dbb2a1
commit b68f88c
Showing
3 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package buildah | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/containers/storage" | ||
) | ||
|
||
func TestGetImageName(t *testing.T) { | ||
tt := []struct { | ||
caseName string | ||
name string | ||
names []string | ||
expected string | ||
}{ | ||
{"tagged image", "busybox1", []string{"docker.io/library/busybox:latest", "docker.io/library/busybox1:latest"}, "docker.io/library/busybox1:latest"}, | ||
{"image name not in the resolved image names", "image1", []string{"docker.io/library/busybox:latest", "docker.io/library/busybox1:latest"}, "docker.io/library/busybox:latest"}, | ||
{"resolved image with empty name list", "image1", []string{}, "image1"}, | ||
} | ||
|
||
for _, tc := range tt { | ||
img := &storage.Image{Names: tc.names} | ||
res := getImageName(tc.name, img) | ||
if res != tc.expected { | ||
t.Errorf("test case '%s' failed: expected %#v but got %#v", tc.caseName, tc.expected, res) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters