Skip to content

Commit 67a2532

Browse files
authored
Fix list required devices (#137)
1 parent 51dab70 commit 67a2532

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

internal/orchestrator/provision.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,39 +236,39 @@ func generateMainComposeFile(
236236
ports[fmt.Sprintf("%s:%s", p, p)] = struct{}{}
237237
}
238238

239+
// 2. Collect all the required device classes
240+
if len(idxBrick.RequiredDevices) > 0 {
241+
for _, deviceClass := range idxBrick.RequiredDevices {
242+
requiredDeviceClasses[deviceClass] = true
243+
}
244+
}
245+
239246
// The following code is needed only if the brick requires a container.
240247
// In case it doesn't we just skip to the next one.
241248
if !idxBrick.RequireContainer {
242249
continue
243250
}
244251

245-
// 2. Retrieve the brick_compose.yaml file.
252+
// 3. Retrieve the brick_compose.yaml file.
246253
composeFilePath, err := staticStore.GetBrickComposeFilePathFromID(brick.ID)
247254
if err != nil {
248255
slog.Error("brick compose id not valid", slog.String("error", err.Error()), slog.String("brick_id", brick.ID))
249256
continue
250257
}
251258

252-
// 3. Retrieve the compose services names.
259+
// 4. Retrieve the compose services names.
253260
svcs, err := extractServicesFromComposeFile(composeFilePath)
254261
if err != nil {
255262
slog.Error("loading brick_compose", slog.String("brick_id", brick.ID), slog.String("path", composeFilePath.String()), slog.Any("error", err))
256263
continue
257264
}
258265

259-
// 4. Retrieve the required devices that we have to mount
266+
// 5. Retrieve the required devices that we have to mount
260267
slog.Debug("Brick config", slog.Bool("mount_devices_into_container", idxBrick.MountDevicesIntoContainer), slog.Any("ports", ports), slog.Any("required_devices", idxBrick.RequiredDevices))
261268
if idxBrick.MountDevicesIntoContainer {
262269
servicesThatRequireDevices = slices.AppendSeq(servicesThatRequireDevices, maps.Keys(svcs))
263270
}
264271

265-
// 5. Collect all the required device classes
266-
if len(idxBrick.RequiredDevices) > 0 {
267-
for _, deviceClass := range idxBrick.RequiredDevices {
268-
requiredDeviceClasses[deviceClass] = true
269-
}
270-
}
271-
272272
composeFiles.Add(composeFilePath)
273273
maps.Insert(services, maps.All(svcs))
274274
}

0 commit comments

Comments
 (0)