mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
If quadlets have same name, only use first
If a user puts a quadlet file in his homedirectory with the same name as one in /etc/containers/systemd/user or /etc/containers/systemd/user/$UID, then only use the one in homedir and ignore the others. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -194,6 +194,8 @@ func isExtSupported(filename string) bool {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var seen = make(map[string]struct{})
|
||||||
|
|
||||||
func loadUnitsFromDir(sourcePath string) ([]*parser.UnitFile, error) {
|
func loadUnitsFromDir(sourcePath string) ([]*parser.UnitFile, error) {
|
||||||
var prevError error
|
var prevError error
|
||||||
files, err := os.ReadDir(sourcePath)
|
files, err := os.ReadDir(sourcePath)
|
||||||
@ -205,7 +207,6 @@ func loadUnitsFromDir(sourcePath string) ([]*parser.UnitFile, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var units []*parser.UnitFile
|
var units []*parser.UnitFile
|
||||||
var seen = make(map[string]struct{})
|
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
name := file.Name()
|
name := file.Name()
|
||||||
|
@ -176,6 +176,32 @@ EOF
|
|||||||
service_cleanup $QUADLET_SERVICE_NAME failed
|
service_cleanup $QUADLET_SERVICE_NAME failed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "quadlet conflict names" {
|
||||||
|
# If two directories in the search have files with the same name, quadlet should
|
||||||
|
# only process the first name
|
||||||
|
dir1=$PODMAN_TMPDIR/$(random_string)
|
||||||
|
dir2=$PODMAN_TMPDIR/$(random_string)
|
||||||
|
local quadlet_file=basic_$(random_string).container
|
||||||
|
mkdir -p $dir1 $dir2
|
||||||
|
|
||||||
|
cat > $dir1/$quadlet_file <<EOF
|
||||||
|
[Container]
|
||||||
|
Image=$IMAGE
|
||||||
|
Notify=yes
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > $dir2/$quadlet_file <<EOF
|
||||||
|
[Container]
|
||||||
|
Image=$IMAGE
|
||||||
|
Notify=no
|
||||||
|
EOF
|
||||||
|
QUADLET_UNIT_DIRS="$dir1:$dir2" run \
|
||||||
|
timeout --foreground -v --kill=10 $PODMAN_TIMEOUT \
|
||||||
|
$QUADLET --dryrun
|
||||||
|
assert "$output" =~ "Notify=yes" "quadlet should show Notify=yes"
|
||||||
|
assert "$output" !~ "Notify=no" "quadlet should not show Notify=no"
|
||||||
|
}
|
||||||
|
|
||||||
@test "quadlet - envvar" {
|
@test "quadlet - envvar" {
|
||||||
local quadlet_file=$PODMAN_TMPDIR/envvar_$(random_string).container
|
local quadlet_file=$PODMAN_TMPDIR/envvar_$(random_string).container
|
||||||
cat > $quadlet_file <<EOF
|
cat > $quadlet_file <<EOF
|
||||||
|
Reference in New Issue
Block a user