toContainerSpec method
Implementation
ContainerSpec? toContainerSpec({required Map<String, String> values}) {
// Build env map with {var} expansion.
final env = <EnvironmentVariable>[];
if (environment != null) {
for (final e in environment!) {
env.add(EnvironmentVariable(name: e.name, value: e.value?.formatWith(values), token: e.token));
}
}
// Image is required on ServiceSpec; enforce like Pydantic would.
final img = image;
if (img == null || img.isEmpty) {
throw ArgumentError('ServiceTemplateSpec.image is required to build a ServiceSpec');
}
return ContainerSpec(
command: command?.formatWith(values),
image: img,
environment: env,
onDemand: onDemand,
writableRootFs: writableRootFs,
private: private,
storage: storage == null
? null
: ContainerMountSpec(
room: storage!.room,
// If you later add `project` to ServiceTemplateContainerMountSpec, map it here:
// project: storage!.project,
),
);
}