fix(transport): import diff compares secrets and bindings; preview honours the name map; CI lookups; area paths; no Rename where unsupported (TRN-2, TRN-3, TRN-6, TRN-7, TRN-8, TRN-9, WP2 tasks 2.4+2.5)
2.4 — ArtifactDiff: - TRN-2: secret-bearing values (data-connection primary/backup config, DB connection string, external-system auth, SMTP credentials, SMS token) are compared by SHA-256 and reported value-free as <present> -> <changed>, so a changed endpoint no longer reads Identical and is force-skipped. - TRN-6: the instance diff resolves each existing binding's DataConnectionId to its name and compares it (a rebind OPC1 -> OPC2 is Modified); State is no longer compared (the import never carries a live state). 2.5 — BundleImporter / ManagementActor / Central UI: - TRN-3: PreviewAsync takes an optional BundleNameMap (additive optional param); under a MapToExisting redirect the connection/instance diffs, connection auto-match and unresolved-connection blocker run against the mapped target. The CLI import path passes its explicit --map-site/--map-connection redirects to the preview before the blocker gate; the Central UI re-runs the preview under the Map-step choices at Confirm. Apply binds a CreateNew site/connection whose identifier/name already exists to that row instead of inserting a duplicate the unique index rejects. - TRN-7: connection, instance, instance-template and composition/base-template lookups match exact spelling first, then case-insensitively. - TRN-8: InstanceDto gains the additive AreaPath (root->leaf); the exporter fills it and the importer resolves/creates areas level by level under their real parent. A legacy leaf-only bundle with an ambiguous leaf resolves deterministically and adds an ImportResult warning. - TRN-9: Rename is rejected by ApplyAsync for Site, DataConnection, SmtpConfiguration and SmsConfiguration (ImportRenameSupport); the UI does not offer it there and the CLI rename policy falls back to Skip with a warning. Also moves a doc comment misplaced by the 2.6 commit. Reflection round-trip guard (RoundTripEquivalenceTests) re-run: green.
This commit is contained in:
@@ -4664,7 +4664,13 @@ public class ManagementActor : ReceiveActor
|
||||
// is safe even when ApplyAsync already released the same id.
|
||||
try
|
||||
{
|
||||
var preview = await importer.PreviewAsync(session.SessionId);
|
||||
// TRN-3: an explicit --map-site / --map-connection redirect changes what
|
||||
// the site-scoped preview rows resolve against, so the preview (and its
|
||||
// unresolved-connection blockers and auto-matches) runs under those
|
||||
// redirects — otherwise a connection present only on the MAPPED site was
|
||||
// a blocker no mapping could clear.
|
||||
var preview = await importer.PreviewAsync(
|
||||
session.SessionId, nameMap: BuildExplicitRedirectMap(cmd));
|
||||
|
||||
var blockers = preview.Items.Where(i => i.Kind == ConflictKind.Blocker).ToList();
|
||||
if (blockers.Count > 0)
|
||||
@@ -4690,6 +4696,7 @@ public class ManagementActor : ReceiveActor
|
||||
// automatically correct — no bare-connection-name special case needed.
|
||||
var renameStamp = DateTime.UtcNow.ToString("yyyyMMdd-HHmmss");
|
||||
var resolutionsMap = new Dictionary<(string, string), ImportResolution>();
|
||||
var renameFallbacks = new SortedSet<string>(StringComparer.Ordinal);
|
||||
foreach (var item in preview.Items)
|
||||
{
|
||||
var action = item.Kind switch
|
||||
@@ -4699,15 +4706,31 @@ public class ManagementActor : ReceiveActor
|
||||
ConflictKind.Modified => policy,
|
||||
_ => ResolutionAction.Skip,
|
||||
};
|
||||
var renameTo = (item.Kind == ConflictKind.Modified && policy == ResolutionAction.Rename)
|
||||
// TRN-9: --conflict-policy rename has no meaning for a site, data
|
||||
// connection or SMTP/SMS configuration (the importer rejects it);
|
||||
// fall back to Skip for those and say so in the result.
|
||||
if (action == ResolutionAction.Rename && !ImportRenameSupport.IsSupported(item.EntityType))
|
||||
{
|
||||
action = ResolutionAction.Skip;
|
||||
renameFallbacks.Add($"{item.EntityType} '{item.Name}'");
|
||||
}
|
||||
var renameTo = (item.Kind == ConflictKind.Modified && action == ResolutionAction.Rename)
|
||||
? $"{item.Name}-imported-{renameStamp}"
|
||||
: null;
|
||||
resolutionsMap[(item.EntityType, item.Name)] = new ImportResolution(
|
||||
item.EntityType, item.Name, action, renameTo);
|
||||
}
|
||||
|
||||
return await importer.ApplyAsync(
|
||||
var importResult = await importer.ApplyAsync(
|
||||
session.SessionId, resolutionsMap.Values.ToList(), username, nameMap: nameMap);
|
||||
if (renameFallbacks.Count == 0) return importResult;
|
||||
return importResult with
|
||||
{
|
||||
Warnings = importResult.Warnings
|
||||
.Concat(renameFallbacks.Select(f =>
|
||||
$"{f} was skipped: Rename is not supported for sites, data connections, SMTP or SMS configurations."))
|
||||
.ToList(),
|
||||
};
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -4720,6 +4743,27 @@ public class ManagementActor : ReceiveActor
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TRN-3: the operator's explicit MapToExisting redirects (a <c>--map-site</c> /
|
||||
/// <c>--map-connection</c> with a target) as a <see cref="BundleNameMap"/> for the
|
||||
/// preview, or <c>null</c> when there are none (the preview then keeps its identity
|
||||
/// auto-match). Create-new specs are not redirects and are left to
|
||||
/// <see cref="BuildNameMap"/>.
|
||||
/// </summary>
|
||||
private static BundleNameMap? BuildExplicitRedirectMap(ImportBundleCommand cmd)
|
||||
{
|
||||
var sites = (cmd.SiteMappings ?? Array.Empty<SiteMappingSpec>())
|
||||
.Where(s => !string.IsNullOrWhiteSpace(s.TargetSiteIdentifier))
|
||||
.Select(s => new SiteMapping(s.SourceSiteIdentifier, MappingAction.MapToExisting, s.TargetSiteIdentifier))
|
||||
.ToList();
|
||||
var connections = (cmd.ConnectionMappings ?? Array.Empty<ConnectionMappingSpec>())
|
||||
.Where(c => !string.IsNullOrWhiteSpace(c.TargetConnectionName))
|
||||
.Select(c => new ConnectionMapping(
|
||||
c.SourceSiteIdentifier, c.SourceConnectionName, MappingAction.MapToExisting, c.TargetConnectionName))
|
||||
.ToList();
|
||||
return sites.Count == 0 && connections.Count == 0 ? null : new BundleNameMap(sites, connections);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merges the operator-supplied <see cref="SiteMappingSpec"/> /
|
||||
/// <see cref="ConnectionMappingSpec"/> lists with the preview's auto-matches
|
||||
|
||||
Reference in New Issue
Block a user