mirror of
https://github.com/actions/runner.git
synced 2026-04-04 09:29:34 +08:00
Compare updated template evaluator (#4092)
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
|
||||
namespace GitHub.Actions.WorkflowParser.Conversion
|
||||
{
|
||||
internal static class PermissionLevelExtensions
|
||||
{
|
||||
public static bool IsLessThanOrEqualTo(
|
||||
this PermissionLevel permissionLevel,
|
||||
PermissionLevel other)
|
||||
{
|
||||
switch (permissionLevel, other)
|
||||
{
|
||||
case (PermissionLevel.NoAccess, PermissionLevel.NoAccess):
|
||||
case (PermissionLevel.NoAccess, PermissionLevel.Read):
|
||||
case (PermissionLevel.NoAccess, PermissionLevel.Write):
|
||||
case (PermissionLevel.Read, PermissionLevel.Read):
|
||||
case (PermissionLevel.Read, PermissionLevel.Write):
|
||||
case (PermissionLevel.Write, PermissionLevel.Write):
|
||||
return true;
|
||||
case (PermissionLevel.Read, PermissionLevel.NoAccess):
|
||||
case (PermissionLevel.Write, PermissionLevel.NoAccess):
|
||||
case (PermissionLevel.Write, PermissionLevel.Read):
|
||||
return false;
|
||||
default:
|
||||
throw new ArgumentException($"Invalid enum comparison: {permissionLevel} and {other}");
|
||||
}
|
||||
}
|
||||
|
||||
public static string ConvertToString(this PermissionLevel permissionLevel)
|
||||
{
|
||||
switch (permissionLevel)
|
||||
{
|
||||
case PermissionLevel.NoAccess:
|
||||
return "none";
|
||||
case PermissionLevel.Read:
|
||||
return "read";
|
||||
case PermissionLevel.Write:
|
||||
return "write";
|
||||
default:
|
||||
throw new NotSupportedException($"invalid permission level found. {permissionLevel}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user