Skip to content

Commit 01dccba

Browse files
committed
quadlet: When loading dropin files for foo@instance, also load those for foo@.
This is how systemd works for templates, and it allows us lots of flexibilities. Signed-off-by: Alexander Larsson <[email protected]>
1 parent bb6dec4 commit 01dccba

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

cmd/quadlet/main.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,22 @@ func loadUnitDropins(unit *parser.UnitFile, sourcePaths []string) error {
254254
prevError = err
255255
}
256256

257-
var dropinPaths = make(map[string]string)
257+
dropinDirs := []string{}
258+
258259
for _, sourcePath := range sourcePaths {
259-
dropinDir := path.Join(sourcePath, unit.Filename+".d")
260+
dropinDirs = append(dropinDirs, path.Join(sourcePath, unit.Filename+".d"))
261+
}
260262

263+
// For instantiated templates, also look in the non-instanced template dropin dirs
264+
templateBase, templateInstance := unit.GetTemplateParts()
265+
if templateBase != "" && templateInstance != "" {
266+
for _, sourcePath := range sourcePaths {
267+
dropinDirs = append(dropinDirs, path.Join(sourcePath, templateBase+".d"))
268+
}
269+
}
270+
271+
var dropinPaths = make(map[string]string)
272+
for _, dropinDir := range dropinDirs {
261273
dropinFiles, err := os.ReadDir(dropinDir)
262274
if err != nil {
263275
if !errors.Is(err, os.ErrNotExist) {

0 commit comments

Comments
 (0)