cs-codex-dist-tests/KubernetesWorkflow/ResourceLimits.cs

42 lines
1005 B
C#
Raw Normal View History

2023-09-08 08:14:52 +00:00
using Utils;
namespace KubernetesWorkflow
{
public class ResourceLimits
{
public ResourceLimits(int milliCPUs, ByteSize memory)
{
MilliCPUs = milliCPUs;
Memory = memory;
}
public ResourceLimits(int milliCPUs)
: this(milliCPUs, new ByteSize(0))
{
}
public ResourceLimits(ByteSize memory)
: this(0, memory)
{
}
public ResourceLimits()
: this(0)
{
}
public int MilliCPUs { get; }
public ByteSize Memory { get; }
public override string ToString()
{
var result = new List<string>();
if (MilliCPUs == 0) result.Add("cpu: unlimited");
else result.Add($"cpu: {MilliCPUs} milliCPUs");
if (Memory.SizeInBytes == 0) result.Add("memory: unlimited");
else result.Add($"memory: {Memory}");
return string.Join(", ", result);
}
}
}