mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-02 21:43:08 +00:00
47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using Core;
|
|
using KubernetesWorkflow.Types;
|
|
using Logging;
|
|
using Utils;
|
|
|
|
namespace CodexPlugin
|
|
{
|
|
public static class CodexInstanceContainerExtension
|
|
{
|
|
public static ICodexInstance CreateFromPod(RunningPod pod)
|
|
{
|
|
var container = pod.Containers.Single();
|
|
|
|
return new CodexInstance(
|
|
name: container.Name,
|
|
imageName: container.Recipe.Image,
|
|
startUtc: container.Recipe.RecipeCreatedUtc,
|
|
discoveryEndpoint: container.GetInternalAddress(CodexContainerRecipe.DiscoveryPortTag),
|
|
apiEndpoint: container.GetAddress(CodexContainerRecipe.ApiPortTag),
|
|
listenEndpoint: container.GetInternalAddress(CodexContainerRecipe.ListenPortTag),
|
|
ethAccount: container.Recipe.Additionals.Get<EthAccount>(),
|
|
metricsEndpoint: GetMetricsEndpoint(container)
|
|
);
|
|
}
|
|
|
|
// todo: is this needed for the discovery address??
|
|
//var info = codexAccess.GetPodInfo();
|
|
//return new Address(
|
|
// logName: $"{GetName()}:DiscoveryPort",
|
|
// host: info.Ip,
|
|
// port: Container.Recipe.GetPortByTag(CodexContainerRecipe.DiscoveryPortTag)!.Number
|
|
//);
|
|
|
|
private static Address? GetMetricsEndpoint(RunningContainer container)
|
|
{
|
|
try
|
|
{
|
|
return container.GetInternalAddress(CodexContainerRecipe.MetricsPortTag);
|
|
}
|
|
catch
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|