cs-codex-dist-tests/CodexDistTestCore/CodexDockerImage.cs

61 lines
1.9 KiB
C#
Raw Normal View History

2023-03-19 10:18:56 +00:00
using k8s.Models;
2023-03-21 12:20:21 +00:00
namespace CodexDistTestCore
2023-03-19 10:18:56 +00:00
{
public class CodexDockerImage
{
public string GetImageTag()
{
return "thatbenbierens/nim-codex:sha-b204837";
}
public string GetExpectedImageRevision()
{
return "b20483";
2023-03-19 10:18:56 +00:00
}
2023-03-21 14:17:48 +00:00
public List<V1EnvVar> CreateEnvironmentVariables(OfflineCodexNodes node, CodexNodeContainer environment)
2023-03-19 10:18:56 +00:00
{
var formatter = new EnvFormatter();
2023-03-21 14:17:48 +00:00
formatter.Create(node, environment);
2023-03-19 10:18:56 +00:00
return formatter.Result;
}
private class EnvFormatter
{
public List<V1EnvVar> Result { get; } = new List<V1EnvVar>();
2023-03-21 14:17:48 +00:00
public void Create(OfflineCodexNodes node, CodexNodeContainer environment)
2023-03-19 10:18:56 +00:00
{
2023-03-21 14:17:48 +00:00
AddVar("API_PORT", environment.ApiPort.ToString());
AddVar("DATA_DIR", environment.DataDir);
AddVar("DISC_PORT", environment.DiscoveryPort.ToString());
AddVar("LISTEN_ADDRS", $"/ip4/0.0.0.0/tcp/{environment.ListenPort}");
2023-03-19 10:18:56 +00: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)
{
AddVar("STORAGE_QUOTA", node.StorageQuota.SizeInBytes.ToString()!);
2023-03-19 10:18:56 +00:00
}
}
private void AddVar(string key, string value)
{
Result.Add(new V1EnvVar
{
Name = key,
Value = value
});
}
}
}
}