cs-codex-dist-tests/Framework/KubernetesWorkflow/RunningContainers.cs

71 lines
2.2 KiB
C#
Raw Normal View History

2023-08-15 09:01:18 +00:00
using Newtonsoft.Json;
using Utils;
namespace KubernetesWorkflow
2023-04-12 11:53:55 +00:00
{
public class RunningContainers
{
public RunningContainers(StartupConfig startupConfig, RunningPod runningPod, RunningContainer[] containers)
{
StartupConfig = startupConfig;
RunningPod = runningPod;
Containers = containers;
}
public StartupConfig StartupConfig { get; }
public RunningPod RunningPod { get; }
public RunningContainer[] Containers { get; }
2023-04-13 12:36:17 +00:00
public string Describe()
{
return string.Join(",", Containers.Select(c => c.Name));
2023-04-13 12:36:17 +00:00
}
2023-04-12 11:53:55 +00:00
}
public class RunningContainer
{
public RunningContainer(RunningPod pod, ContainerRecipe recipe, Port[] servicePorts, string name, Address clusterExternalAddress, Address clusterInternalAddress)
2023-04-12 11:53:55 +00:00
{
Pod = pod;
Recipe = recipe;
ServicePorts = servicePorts;
Name = name;
ClusterExternalAddress = clusterExternalAddress;
ClusterInternalAddress = clusterInternalAddress;
2023-04-12 11:53:55 +00:00
}
public string Name { get; }
2023-04-12 11:53:55 +00:00
public RunningPod Pod { get; }
public ContainerRecipe Recipe { get; }
public Port[] ServicePorts { get; }
public Address ClusterExternalAddress { get; }
public Address ClusterInternalAddress { get; }
2023-08-15 09:01:18 +00:00
2023-09-11 14:57:57 +00:00
[JsonIgnore]
public Address Address
{
get
{
if (RunnerLocationUtils.DetermineRunnerLocation(this) == RunnerLocation.InternalToCluster)
{
return ClusterInternalAddress;
}
return ClusterExternalAddress;
}
}
2023-04-12 11:53:55 +00:00
}
public static class RunningContainersExtensions
{
public static RunningContainer[] Containers(this RunningContainers[] runningContainers)
{
return runningContainers.SelectMany(c => c.Containers).ToArray();
}
public static string Describe(this RunningContainers[] runningContainers)
{
return string.Join(",", runningContainers.Select(c => c.Describe()));
}
}
2023-04-12 11:53:55 +00:00
}