Quadlet - print warning when fail to parse

Fixes: #26542

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
This commit is contained in:
Ygal Blum
2025-07-07 14:49:32 -04:00
parent 462df8f894
commit cd807f8ff6
5 changed files with 39 additions and 18 deletions

View File

@ -0,0 +1,5 @@
## assert-podman-final-args localhost/imagename
[Container]
Image=localhost/imagename
Exec='test\.com'

View File

@ -0,0 +1,5 @@
## assert-podman-final-args localhost/imagename
[Container]
Image=localhost/imagename
ReloadCmd='test\.sh'

View File

@ -232,7 +232,7 @@ func (t *quadletTestcase) assertKeyNotContains(args []string, unit *parser.UnitF
}
func (t *quadletTestcase) assertPodmanArgs(args []string, unit *parser.UnitFile, key string, allowRegex, globalOnly bool) bool {
podmanArgs, _ := unit.LookupLastArgs("Service", key)
podmanArgs, _, _ := unit.LookupLastArgs("Service", key)
if globalOnly {
podmanCmdLocation := findSublist(podmanArgs, []string{args[0]})
if podmanCmdLocation == -1 {
@ -287,7 +287,7 @@ func keyValMapEqualRegex(expectedKeyValMap, actualKeyValMap map[string]string) b
}
func (t *quadletTestcase) assertPodmanArgsKeyVal(args []string, unit *parser.UnitFile, key string, allowRegex, globalOnly bool) bool {
podmanArgs, _ := unit.LookupLastArgs("Service", key)
podmanArgs, _, _ := unit.LookupLastArgs("Service", key)
if globalOnly {
podmanCmdLocation := findSublist(podmanArgs, []string{args[0]})
@ -334,7 +334,7 @@ func (t *quadletTestcase) assertPodmanArgsKeyVal(args []string, unit *parser.Uni
}
func (t *quadletTestcase) assertPodmanFinalArgs(args []string, unit *parser.UnitFile, key string) bool {
podmanArgs, _ := unit.LookupLastArgs("Service", key)
podmanArgs, _, _ := unit.LookupLastArgs("Service", key)
if len(podmanArgs) < len(args) {
return false
}
@ -342,7 +342,7 @@ func (t *quadletTestcase) assertPodmanFinalArgs(args []string, unit *parser.Unit
}
func (t *quadletTestcase) assertPodmanFinalArgsRegex(args []string, unit *parser.UnitFile, key string) bool {
podmanArgs, _ := unit.LookupLastArgs("Service", key)
podmanArgs, _, _ := unit.LookupLastArgs("Service", key)
if len(podmanArgs) < len(args) {
return false
}
@ -1106,6 +1106,9 @@ BOGUS=foo
Entry("Unsupported Service Key - DynamicUser.network", "service-dynamicuser.network", "Warning: using key DynamicUser in the Service group is not supported"),
Entry("Unsupported Service Key - DynamicUser.pod", "service-dynamicuser.pod", "Warning: using key DynamicUser in the Service group is not supported"),
Entry("Unsupported Service Key - DynamicUser.volume", "service-dynamicuser.volume", "Warning: using key DynamicUser in the Service group is not supported"),
Entry("exec-unsupported-escape.container", "exec-unsupported-escape.container", "unsupported escape char"),
Entry("reloadcmd-unsupported-escape.container", "reloadcmd-unsupported-escape.container", "unsupported escape char"),
)
DescribeTable("Running expected error quadlet test case",