part #2
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user