Skip to content

Commit 823ae9c

Browse files
committed
fix(mcl/deploy-spec): Handle 0 agents case and simplify logging
1 parent 171f1e0 commit 823ae9c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

packages/mcl/src/src/mcl/commands/deploy_spec.d

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export void deploy_spec()
2020
{
2121
const deploySpecFile = resultDir.buildPath("cachix-deploy-spec.json");
2222

23+
DeploySpec spec;
24+
2325
if (!exists(deploySpecFile))
2426
{
2527
auto nixosConfigs = flakeAttr("legacyPackages", SupportedSystem.x86_64_linux, "bareMetalMachines")
@@ -39,19 +41,21 @@ export void deploy_spec()
3941
if (!configsMissingFromCachix.empty)
4042
throw new Exception("Some Nixos configurations are not in cachix. Please cache them first.");
4143

42-
auto spec = nixosConfigs.createMachineDeploySpec().toJSON;
43-
44-
infof("Deploy spec: %s", spec.toPrettyString(JSONOptions.doNotEscapeSlashes));
45-
46-
writeFile(deploySpecFile, spec.toString());
44+
spec = nixosConfigs.createMachineDeploySpec();
45+
writeFile(deploySpecFile, spec.toJSON.toPrettyString(JSONOptions.doNotEscapeSlashes));
4746
}
4847
else
4948
{
5049
warningf("Reusing existing deploy spec at:\n'%s'", deploySpecFile.bold);
51-
52-
warningf("\n---\n%s\n---", deploySpecFile.tryDeserializeFromJsonFile!DeploySpec);
50+
spec = deploySpecFile.tryDeserializeFromJsonFile!DeploySpec;
5351
}
5452

53+
infof("\n---\n%s\n---", spec);
54+
infof("%s machines will be deployed.", spec.agents.length);
55+
56+
if (!spec.agents.length)
57+
return;
58+
5559
spawnProcessInline([
5660
"cachix", "deploy", "activate", deploySpecFile, "--async"
5761
]);

0 commit comments

Comments
 (0)