mirror of
https://github.com/actions/runner.git
synced 2025-12-30 13:27:25 +08:00
delete un-used code. (#218)
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public sealed class CounterNode : FunctionNode
|
||||
{
|
||||
protected override Object EvaluateCore(EvaluationContext evaluationContext)
|
||||
{
|
||||
int seed = 0;
|
||||
var prefix = String.Empty;
|
||||
if (Parameters.Count > 0)
|
||||
{
|
||||
prefix = Parameters[0].EvaluateString(evaluationContext);
|
||||
}
|
||||
|
||||
if (Parameters.Count > 1)
|
||||
{
|
||||
seed = Convert.ToInt32(Parameters[1].EvaluateNumber(evaluationContext));
|
||||
}
|
||||
|
||||
var context = evaluationContext.State as IPipelineContext;
|
||||
return context.CounterStore?.Increment(context, prefix, seed) ?? seed;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public static class ExpressionConstants
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name of the variables node.
|
||||
/// </summary>
|
||||
public static readonly String Variables = "variables";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pipeline context available in pipeline expressions.
|
||||
/// </summary>
|
||||
public static readonly INamedValueInfo PipelineNamedValue = new NamedValueInfo<PipelineContextNode>("pipeline");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the variable context available in pipeline expressions.
|
||||
/// </summary>
|
||||
public static readonly INamedValueInfo VariablesNamedValue = new NamedValueInfo<VariablesContextNode>("variables");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the counter function available in pipeline expressions.
|
||||
/// </summary>
|
||||
public static readonly IFunctionInfo CounterFunction = new FunctionInfo<CounterNode>("counter", 0, 2);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
internal static class InputValidationConstants
|
||||
{
|
||||
public static readonly String IsEmail = "isEmail";
|
||||
public static readonly String IsInRange = "isInRange";
|
||||
public static readonly String IsIPv4Address = "isIPv4Address";
|
||||
public static readonly String IsSha1 = "isSha1";
|
||||
public static readonly String IsUrl = "isUrl";
|
||||
public static readonly String IsMatch = "isMatch";
|
||||
public static readonly String Length = "length";
|
||||
|
||||
public static readonly IFunctionInfo[] Functions = new IFunctionInfo[]
|
||||
{
|
||||
new FunctionInfo<IsEmailNode>(InputValidationConstants.IsEmail, IsEmailNode.minParameters, IsEmailNode.maxParameters),
|
||||
new FunctionInfo<IsInRangeNode>(InputValidationConstants.IsInRange, IsInRangeNode.minParameters, IsInRangeNode.maxParameters),
|
||||
new FunctionInfo<IsIPv4AddressNode>(InputValidationConstants.IsIPv4Address, IsIPv4AddressNode.minParameters, IsIPv4AddressNode.maxParameters),
|
||||
new FunctionInfo<IsMatchNode>(InputValidationConstants.IsMatch, IsMatchNode.minParameters, IsMatchNode.maxParameters),
|
||||
new FunctionInfo<IsSHA1Node>(InputValidationConstants.IsSha1, IsSHA1Node.minParameters, IsSHA1Node.maxParameters),
|
||||
new FunctionInfo<IsUrlNode>(InputValidationConstants.IsUrl, IsUrlNode.minParameters, IsUrlNode.maxParameters),
|
||||
new FunctionInfo<LengthNode>(InputValidationConstants.Length, LengthNode.minParameters, LengthNode.maxParameters),
|
||||
};
|
||||
|
||||
public static readonly INamedValueInfo[] NamedValues = new INamedValueInfo[]
|
||||
{
|
||||
new NamedValueInfo<InputValueNode>("value"),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
using GitHub.DistributedTask.Pipelines.Validation;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
internal class InputValueNode : NamedValueNode
|
||||
{
|
||||
protected sealed override Object EvaluateCore(EvaluationContext evaluationContext)
|
||||
{
|
||||
var validationContext = evaluationContext.State as InputValidationContext;
|
||||
return validationContext.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public sealed class IsEmailNode : FunctionNode
|
||||
{
|
||||
protected sealed override Boolean TraceFullyRealized => false;
|
||||
|
||||
public static Int32 minParameters = 1;
|
||||
public static Int32 maxParameters = 1;
|
||||
|
||||
protected sealed override Object EvaluateCore(EvaluationContext context)
|
||||
{
|
||||
// isEmail(value: string)
|
||||
String value = Parameters[0].EvaluateString(context) ?? String.Empty;
|
||||
return RegexUtility.IsMatch(value, WellKnownRegularExpressions.Email);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public sealed class IsIPv4AddressNode : FunctionNode
|
||||
{
|
||||
protected sealed override Boolean TraceFullyRealized => false;
|
||||
|
||||
public static Int32 minParameters = 1;
|
||||
public static Int32 maxParameters = 1;
|
||||
|
||||
protected sealed override Object EvaluateCore(EvaluationContext context)
|
||||
{
|
||||
// isIpV4Address(value: string)
|
||||
String value = Parameters[0].EvaluateString(context) ?? String.Empty;
|
||||
return RegexUtility.IsMatch(value, WellKnownRegularExpressions.IPv4Address);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public sealed class IsInRangeNode : FunctionNode
|
||||
{
|
||||
protected sealed override Boolean TraceFullyRealized => false;
|
||||
|
||||
public static Int32 minParameters = 3;
|
||||
public static Int32 maxParameters = 3;
|
||||
|
||||
protected sealed override Object EvaluateCore(EvaluationContext context)
|
||||
{
|
||||
// isInRange(value: string, min: string, max: string)
|
||||
decimal value = Parameters[0].EvaluateNumber(context);
|
||||
decimal min = Parameters[1].EvaluateNumber(context);
|
||||
decimal max = Parameters[2].EvaluateNumber(context);
|
||||
return value >= min && value <= max;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public sealed class IsMatchNode : FunctionNode
|
||||
{
|
||||
protected sealed override Boolean TraceFullyRealized => false;
|
||||
|
||||
public static Int32 minParameters = 2;
|
||||
public static Int32 maxParameters = 3;
|
||||
|
||||
protected sealed override Object EvaluateCore(EvaluationContext context)
|
||||
{
|
||||
// isMatch(value: string, regEx: string, options?: string)
|
||||
String value = Parameters[0].EvaluateString(context) ?? String.Empty;
|
||||
String regEx = Parameters[1].EvaluateString(context) ?? String.Empty;
|
||||
String regExOptionsString = String.Empty;
|
||||
|
||||
if (Parameters.Count == 3)
|
||||
{
|
||||
regExOptionsString = Parameters[2].EvaluateString(context) ?? String.Empty;
|
||||
}
|
||||
|
||||
return RegexUtility.IsMatch(value, regEx, regExOptionsString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public sealed class IsSHA1Node : FunctionNode
|
||||
{
|
||||
protected sealed override Boolean TraceFullyRealized => false;
|
||||
|
||||
public static Int32 minParameters = 1;
|
||||
public static Int32 maxParameters = 1;
|
||||
|
||||
protected sealed override Object EvaluateCore(EvaluationContext context)
|
||||
{
|
||||
// isSha1(value: string)
|
||||
String value = Parameters[0].EvaluateString(context) ?? String.Empty;
|
||||
return RegexUtility.IsMatch(value, WellKnownRegularExpressions.SHA1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public sealed class IsUrlNode : FunctionNode
|
||||
{
|
||||
protected sealed override Boolean TraceFullyRealized => false;
|
||||
|
||||
public static Int32 minParameters = 1;
|
||||
public static Int32 maxParameters = 1;
|
||||
|
||||
protected sealed override Object EvaluateCore(EvaluationContext context)
|
||||
{
|
||||
// isUrl(value: string)
|
||||
String value = Parameters[0].EvaluateString(context) ?? String.Empty;
|
||||
return RegexUtility.IsMatch(value, WellKnownRegularExpressions.Url);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public sealed class LengthNode : FunctionNode
|
||||
{
|
||||
protected sealed override Boolean TraceFullyRealized => false;
|
||||
|
||||
public static Int32 minParameters = 1;
|
||||
public static Int32 maxParameters = 1;
|
||||
|
||||
protected sealed override Object EvaluateCore(EvaluationContext context)
|
||||
{
|
||||
// Length(value: object)
|
||||
var evaluationResult = Parameters[0].Evaluate(context);
|
||||
bool kindNotSupported = false;
|
||||
Int32 length = -1;
|
||||
|
||||
switch (evaluationResult.Kind)
|
||||
{
|
||||
case ValueKind.Array:
|
||||
length = ((JArray)evaluationResult.Value).Count;
|
||||
break;
|
||||
case ValueKind.String:
|
||||
length = ((String)evaluationResult.Value).Length;
|
||||
break;
|
||||
case ValueKind.Object:
|
||||
if (evaluationResult.Value is IReadOnlyDictionary<String, Object>)
|
||||
{
|
||||
length = ((IReadOnlyDictionary<String, Object>)evaluationResult.Value).Count;
|
||||
}
|
||||
else if (evaluationResult.Value is ICollection)
|
||||
{
|
||||
length = ((ICollection)evaluationResult.Value).Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
kindNotSupported = true;
|
||||
}
|
||||
break;
|
||||
case ValueKind.Boolean:
|
||||
case ValueKind.Null:
|
||||
case ValueKind.Number:
|
||||
case ValueKind.Version:
|
||||
kindNotSupported = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (kindNotSupported)
|
||||
{
|
||||
throw new NotSupportedException(PipelineStrings.InvalidTypeForLengthFunction(evaluationResult.Kind));
|
||||
}
|
||||
|
||||
return new Decimal(length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
using GitHub.DistributedTask.WebApi;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
internal sealed class PipelineContextNode : NamedValueNode
|
||||
{
|
||||
protected override Object EvaluateCore(EvaluationContext context)
|
||||
{
|
||||
var state = context.State as IPipelineContext;
|
||||
var result = new Dictionary<String, Object>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
// startTime
|
||||
if (state.Variables.TryGetValue(WellKnownDistributedTaskVariables.PipelineStartTime, out VariableValue startTimeVariable) &&
|
||||
!String.IsNullOrEmpty(startTimeVariable.Value))
|
||||
{
|
||||
// Leverage the expression SDK to convert to datetime
|
||||
var startTimeResult = EvaluationResult.CreateIntermediateResult(context, startTimeVariable.Value, out _);
|
||||
if (startTimeResult.TryConvertToDateTime(context, out DateTimeOffset startTime))
|
||||
{
|
||||
result["startTime"] = startTime;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using GitHub.DistributedTask.Expressions;
|
||||
|
||||
namespace GitHub.DistributedTask.Pipelines.Expressions
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public sealed class VariablesContextNode : NamedValueNode
|
||||
{
|
||||
protected override Object EvaluateCore(EvaluationContext context)
|
||||
{
|
||||
var executionContext = context.State as IPipelineContext;
|
||||
return executionContext.Variables;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user