Files
git.stella-ops.org/src/AirGap/__Libraries/StellaOps.AirGap.Bundle/Services/LocalRbacBundleExtensions.Manifest.cs
2026-02-04 19:59:20 +02:00

47 lines
1.3 KiB
C#

using StellaOps.AirGap.Bundle.Models;
namespace StellaOps.AirGap.Bundle.Services;
public static partial class LocalRbacBundleExtensions
{
/// <summary>
/// Checks if a bundle manifest contains local RBAC policy.
/// </summary>
/// <param name="manifest">Bundle manifest to check.</param>
/// <returns>True if the manifest contains local RBAC policy.</returns>
public static bool HasLocalRbacPolicy(this BundleManifest manifest)
{
ArgumentNullException.ThrowIfNull(manifest);
foreach (var policy in manifest.Policies)
{
if (policy.Type == PolicyType.LocalRbac)
{
return true;
}
}
return false;
}
/// <summary>
/// Gets the local RBAC policy component from a bundle manifest.
/// </summary>
/// <param name="manifest">Bundle manifest to search.</param>
/// <returns>The local RBAC policy component, or null if not found.</returns>
public static PolicyComponent? GetLocalRbacPolicy(this BundleManifest manifest)
{
ArgumentNullException.ThrowIfNull(manifest);
foreach (var policy in manifest.Policies)
{
if (policy.Type == PolicyType.LocalRbac)
{
return policy;
}
}
return null;
}
}