Skip to content

Commit faefd0b

Browse files
committed
quadlet: handle generate environment params that inherit from host
Fixes: #26247 Signed-off-by: Volodymyr Pankin <[email protected]>
1 parent 246a688 commit faefd0b

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

pkg/systemd/parser/unitfile.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -839,9 +839,9 @@ func (f *UnitFile) LookupLastArgs(groupName string, key string) ([]string, bool)
839839
}
840840

841841
// Look up 'Environment' style key-value keys
842-
func (f *UnitFile) LookupAllKeyVal(groupName string, key string) (map[string]string, error) {
842+
func (f *UnitFile) LookupAllKeyVal(groupName string, key string) (map[string]*string, error) {
843843
var warnings error
844-
res := make(map[string]string)
844+
res := make(map[string]*string)
845845
allKeyvals := f.LookupAll(groupName, key)
846846
for _, keyvals := range allKeyvals {
847847
assigns, err := splitString(keyvals, WhitespaceSeparators, SplitRelax|SplitUnquote|SplitCUnescape)
@@ -852,9 +852,9 @@ func (f *UnitFile) LookupAllKeyVal(groupName string, key string) (map[string]str
852852
for _, assign := range assigns {
853853
key, value, found := strings.Cut(assign, "=")
854854
if found {
855-
res[key] = value
855+
res[key] = &value
856856
} else {
857-
warnings = errors.Join(warnings, fmt.Errorf("separator was not found for %s", assign))
857+
res[key] = nil
858858
}
859859
}
860860
}

pkg/systemd/quadlet/podmancmdline.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,19 @@ func (c *PodmanCmdline) addf(format string, a ...interface{}) {
3333
c.add(fmt.Sprintf(format, a...))
3434
}
3535

36-
func (c *PodmanCmdline) addKeys(arg string, keys map[string]string) {
36+
func (c *PodmanCmdline) addKeys(arg string, keys map[string]*string) {
3737
ks := make([]string, 0, len(keys))
3838
for k := range keys {
3939
ks = append(ks, k)
4040
}
4141
sort.Strings(ks)
4242

4343
for _, k := range ks {
44-
c.add(arg, fmt.Sprintf("%s=%s", k, keys[k]))
44+
if keys[k] != nil {
45+
c.add(arg, fmt.Sprintf("%s=%s", k, *keys[k]))
46+
} else {
47+
c.add(arg, k)
48+
}
4549
}
4650
}
4751

pkg/systemd/quadlet/quadlet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,8 @@ func ConvertContainer(container *parser.UnitFile, isUser bool, unitsInfoMap map[
810810
if ok && len(update) > 0 {
811811
podman.addKeys(
812812
"--label",
813-
map[string]string{
814-
autoUpdateLabel: update,
813+
map[string]*string{
814+
autoUpdateLabel: &update,
815815
},
816816
)
817817
}

0 commit comments

Comments
 (0)