@treeseed/sdk 0.12.14 → 0.12.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3631,6 +3631,14 @@ function configuredRailwayIacDatabase(input, projectServices, detachVolumeIds =
|
|
|
3631
3631
|
detachVolumeIds
|
|
3632
3632
|
};
|
|
3633
3633
|
}
|
|
3634
|
+
function railwayIacChangeName(change) {
|
|
3635
|
+
return String(change?.resource?.name ?? change?.previous?.name ?? change?.address ?? change?.path ?? "");
|
|
3636
|
+
}
|
|
3637
|
+
function railwayIacPlanDeletesResource(changeSet, resourceName) {
|
|
3638
|
+
return (changeSet?.changes ?? []).some(
|
|
3639
|
+
(change) => change.kind === "resource.delete" && railwayIacChangeName(change) === resourceName
|
|
3640
|
+
);
|
|
3641
|
+
}
|
|
3634
3642
|
function activeAttachedRailwayVolumeIds(volumes, serviceId, environmentId, desiredVolumeName) {
|
|
3635
3643
|
if (!serviceId) {
|
|
3636
3644
|
return [];
|
|
@@ -3848,24 +3856,48 @@ async function syncRailwayEnvironmentForScope(input, { dryRun = false, serviceKe
|
|
|
3848
3856
|
renderRailwayIacProject,
|
|
3849
3857
|
validateRailwayIacChangeSet
|
|
3850
3858
|
} = await import("./providers/railway-iac.js");
|
|
3851
|
-
|
|
3859
|
+
let effectiveIacInput = iacInput;
|
|
3860
|
+
let rendered = renderRailwayIacProject(effectiveIacInput);
|
|
3852
3861
|
try {
|
|
3853
3862
|
traceRailwayReconcile(topology.env, "sync:iac-plan", `${project.name}/${environment.name}:${rendered.serviceNames.join(",")}:volumes=${rendered.volumeNames.join(",")}`);
|
|
3854
|
-
|
|
3863
|
+
let plan = await planRailwayIacProject(effectiveIacInput, rendered);
|
|
3855
3864
|
if (!plan.ok) {
|
|
3856
3865
|
const diagnostics = plan.diagnostics.map((entry) => entry.message).filter(Boolean).join("; ");
|
|
3857
3866
|
throw new Error(`Railway IaC plan failed for ${project.name}/${environment.name}${diagnostics ? `: ${diagnostics}` : "."}`);
|
|
3858
3867
|
}
|
|
3859
|
-
|
|
3868
|
+
let validation = validateRailwayIacChangeSet(plan.changeSet, {
|
|
3860
3869
|
services: rendered.serviceNames,
|
|
3861
3870
|
volumes: rendered.volumeNames,
|
|
3862
3871
|
database: rendered.databaseName,
|
|
3863
3872
|
scope
|
|
3864
3873
|
});
|
|
3874
|
+
if (!validation.ok && effectiveIacInput.database && !effectiveIacInput.database.useNativePostgres && railwayIacPlanDeletesResource(plan.changeSet, effectiveIacInput.database.serviceName)) {
|
|
3875
|
+
traceRailwayReconcile(topology.env, "sync:iac-native-postgres-adopt", `${project.name}/${environment.name}:${effectiveIacInput.database.serviceName}`);
|
|
3876
|
+
cleanupRailwayIacRender(rendered);
|
|
3877
|
+
effectiveIacInput = {
|
|
3878
|
+
...effectiveIacInput,
|
|
3879
|
+
database: {
|
|
3880
|
+
...effectiveIacInput.database,
|
|
3881
|
+
useNativePostgres: true
|
|
3882
|
+
}
|
|
3883
|
+
};
|
|
3884
|
+
rendered = renderRailwayIacProject(effectiveIacInput);
|
|
3885
|
+
plan = await planRailwayIacProject(effectiveIacInput, rendered);
|
|
3886
|
+
if (!plan.ok) {
|
|
3887
|
+
const diagnostics = plan.diagnostics.map((entry) => entry.message).filter(Boolean).join("; ");
|
|
3888
|
+
throw new Error(`Railway IaC plan failed for ${project.name}/${environment.name}${diagnostics ? `: ${diagnostics}` : "."}`);
|
|
3889
|
+
}
|
|
3890
|
+
validation = validateRailwayIacChangeSet(plan.changeSet, {
|
|
3891
|
+
services: rendered.serviceNames,
|
|
3892
|
+
volumes: rendered.volumeNames,
|
|
3893
|
+
database: rendered.databaseName,
|
|
3894
|
+
scope
|
|
3895
|
+
});
|
|
3896
|
+
}
|
|
3865
3897
|
if (!validation.ok) {
|
|
3866
3898
|
throw new Error(`Railway IaC plan rejected for ${project.name}/${environment.name}: ${validation.blockedReasons.join("; ")}`);
|
|
3867
3899
|
}
|
|
3868
|
-
const apply = await applyRailwayIacProject(
|
|
3900
|
+
const apply = await applyRailwayIacProject(effectiveIacInput, rendered);
|
|
3869
3901
|
if (!apply.ok) {
|
|
3870
3902
|
const diagnostics = apply.diagnostics.map((entry) => entry.message).filter(Boolean).join("; ");
|
|
3871
3903
|
throw new Error(`Railway IaC apply failed for ${project.name}/${environment.name}${diagnostics ? `: ${diagnostics}` : "."}`);
|