using StellaOps.AirGap.Bundle.Models;
namespace StellaOps.AirGap.Bundle.Services;
public static partial class LocalRbacBundleExtensions
{
///
/// Checks if a bundle manifest contains local RBAC policy.
///
/// Bundle manifest to check.
/// True if the manifest contains local RBAC policy.
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;
}
///
/// Gets the local RBAC policy component from a bundle manifest.
///
/// Bundle manifest to search.
/// The local RBAC policy component, or null if not found.
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;
}
}