2023-03-19 11:18:56 +01:00
|
|
|
|
using k8s.Models;
|
|
|
|
|
|
2023-03-26 08:52:53 +02:00
|
|
|
|
namespace CodexDistTestCore.Config
|
2023-03-19 11:18:56 +01:00
|
|
|
|
{
|
|
|
|
|
public class CodexDockerImage
|
|
|
|
|
{
|
|
|
|
|
public string GetImageTag()
|
|
|
|
|
{
|
2023-03-21 08:30:40 +01:00
|
|
|
|
return "thatbenbierens/nim-codex:sha-b204837";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetExpectedImageRevision()
|
|
|
|
|
{
|
|
|
|
|
return "b20483";
|
2023-03-19 11:18:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 15:17:48 +01:00
|
|
|
|
public List<V1EnvVar> CreateEnvironmentVariables(OfflineCodexNodes node, CodexNodeContainer environment)
|
2023-03-19 11:18:56 +01:00
|
|
|
|
{
|
|
|
|
|
var formatter = new EnvFormatter();
|
2023-03-21 15:17:48 +01:00
|
|
|
|
formatter.Create(node, environment);
|
2023-03-19 11:18:56 +01:00
|
|
|
|
return formatter.Result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class EnvFormatter
|
|
|
|
|
{
|
|
|
|
|
public List<V1EnvVar> Result { get; } = new List<V1EnvVar>();
|
|
|
|
|
|
2023-03-27 10:27:08 +02:00
|
|
|
|
public void Create(OfflineCodexNodes node, CodexNodeContainer container)
|
2023-03-19 11:18:56 +01:00
|
|
|
|
{
|
2023-03-27 10:27:08 +02:00
|
|
|
|
AddVar("API_PORT", container.ApiPort.ToString());
|
|
|
|
|
AddVar("DATA_DIR", container.DataDir);
|
|
|
|
|
AddVar("DISC_PORT", container.DiscoveryPort.ToString());
|
|
|
|
|
AddVar("LISTEN_ADDRS", $"/ip4/0.0.0.0/tcp/{container.ListenPort}");
|
2023-03-21 15:17:48 +01:00
|
|
|
|
|
2023-03-19 11:18:56 +01:00
|
|
|
|
if (node.BootstrapNode != null)
|
|
|
|
|
{
|
|
|
|
|
var debugInfo = node.BootstrapNode.GetDebugInfo();
|
|
|
|
|
AddVar("BOOTSTRAP_SPR", debugInfo.spr);
|
|
|
|
|
}
|
|
|
|
|
if (node.LogLevel != null)
|
|
|
|
|
{
|
|
|
|
|
AddVar("LOG_LEVEL", node.LogLevel.ToString()!.ToUpperInvariant());
|
|
|
|
|
}
|
|
|
|
|
if (node.StorageQuota != null)
|
|
|
|
|
{
|
2023-03-21 09:20:09 +01:00
|
|
|
|
AddVar("STORAGE_QUOTA", node.StorageQuota.SizeInBytes.ToString()!);
|
2023-03-19 11:18:56 +01:00
|
|
|
|
}
|
2023-03-27 10:27:08 +02:00
|
|
|
|
if (node.MetricsEnabled)
|
|
|
|
|
{
|
|
|
|
|
AddVar("METRICS_ADDR", "0.0.0.0");
|
|
|
|
|
AddVar("METRICS_PORT", container.MetricsPort.ToString());
|
|
|
|
|
}
|
2023-03-19 11:18:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddVar(string key, string value)
|
|
|
|
|
{
|
|
|
|
|
Result.Add(new V1EnvVar
|
|
|
|
|
{
|
|
|
|
|
Name = key,
|
|
|
|
|
Value = value
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|