using ZB.MOM.WW.OtOpcUa.Cluster;
namespace ZB.MOM.WW.OtOpcUa.Host.Configuration;
///
/// Names the per-role appsettings overlay (appsettings.{suffix}.json) for a node.
///
///
/// The suffix is built from the node's PLAIN roles only. cluster-{ClusterId} roles are mesh-membership
/// tags (and carry a verbatim, operator-chosen ClusterId), not configuration profiles — folding one into the
/// filename produced names like appsettings.admin-cluster-MAIN-driver.json that never exist, so on every
/// node with a cluster role the shipped overlays silently never loaded.
///
internal static class RoleOverlay
{
///
/// The overlay filename suffix: the plain (non-cluster) roles, ordinal-sorted and joined with -, or
/// when the node has none.
///
public static string? Suffix(IReadOnlyList gossipedRoles)
{
var plain = gossipedRoles
.Where(r => !string.IsNullOrWhiteSpace(r) && !RoleParser.IsClusterRole(r))
.OrderBy(r => r, StringComparer.Ordinal)
.ToList();
return plain.Count == 0 ? null : string.Join('-', plain);
}
}