From 138def34018390165581c18dc89373944bbd4e13 Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Thu, 4 Dec 2025 09:35:08 +0100 Subject: [PATCH] Fix list required devices --- internal/orchestrator/provision.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/orchestrator/provision.go b/internal/orchestrator/provision.go index c5ab52b6..05527723 100644 --- a/internal/orchestrator/provision.go +++ b/internal/orchestrator/provision.go @@ -236,39 +236,39 @@ func generateMainComposeFile( ports[fmt.Sprintf("%s:%s", p, p)] = struct{}{} } + // 2. Collect all the required device classes + if len(idxBrick.RequiredDevices) > 0 { + for _, deviceClass := range idxBrick.RequiredDevices { + requiredDeviceClasses[deviceClass] = true + } + } + // The following code is needed only if the brick requires a container. // In case it doesn't we just skip to the next one. if !idxBrick.RequireContainer { continue } - // 2. Retrieve the brick_compose.yaml file. + // 3. Retrieve the brick_compose.yaml file. composeFilePath, err := staticStore.GetBrickComposeFilePathFromID(brick.ID) if err != nil { slog.Error("brick compose id not valid", slog.String("error", err.Error()), slog.String("brick_id", brick.ID)) continue } - // 3. Retrieve the compose services names. + // 4. Retrieve the compose services names. svcs, err := extractServicesFromComposeFile(composeFilePath) if err != nil { slog.Error("loading brick_compose", slog.String("brick_id", brick.ID), slog.String("path", composeFilePath.String()), slog.Any("error", err)) continue } - // 4. Retrieve the required devices that we have to mount + // 5. Retrieve the required devices that we have to mount slog.Debug("Brick config", slog.Bool("mount_devices_into_container", idxBrick.MountDevicesIntoContainer), slog.Any("ports", ports), slog.Any("required_devices", idxBrick.RequiredDevices)) if idxBrick.MountDevicesIntoContainer { servicesThatRequireDevices = slices.AppendSeq(servicesThatRequireDevices, maps.Keys(svcs)) } - // 5. Collect all the required device classes - if len(idxBrick.RequiredDevices) > 0 { - for _, deviceClass := range idxBrick.RequiredDevices { - requiredDeviceClasses[deviceClass] = true - } - } - composeFiles.Add(composeFilePath) maps.Insert(services, maps.All(svcs)) }