mirror of
https://github.com/codex-storage/cs-codex-dist-tests.git
synced 2025-02-04 00:03:38 +00:00
Adds volume support to container recipe factory
This commit is contained in:
parent
a03d9cd92f
commit
aa3e500a58
@ -29,7 +29,10 @@ namespace DistTestCore.Codex
|
|||||||
AddExposedPortAndVar("CODEX_API_PORT");
|
AddExposedPortAndVar("CODEX_API_PORT");
|
||||||
AddEnvVar("CODEX_API_BINDADDR", "0.0.0.0");
|
AddEnvVar("CODEX_API_BINDADDR", "0.0.0.0");
|
||||||
|
|
||||||
AddEnvVar("CODEX_DATA_DIR", $"datadir{ContainerNumber}");
|
var dataDir = $"datadir{ContainerNumber}";
|
||||||
|
AddEnvVar("CODEX_DATA_DIR", dataDir);
|
||||||
|
AddVolume(dataDir);
|
||||||
|
|
||||||
AddInternalPortAndVar("CODEX_DISC_PORT", DiscoveryPortTag);
|
AddInternalPortAndVar("CODEX_DISC_PORT", DiscoveryPortTag);
|
||||||
AddEnvVar("CODEX_LOG_LEVEL", config.LogLevel.ToString()!.ToUpperInvariant());
|
AddEnvVar("CODEX_LOG_LEVEL", config.LogLevel.ToString()!.ToUpperInvariant());
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
public class ContainerRecipe
|
public class ContainerRecipe
|
||||||
{
|
{
|
||||||
public ContainerRecipe(int number, string image, Port[] exposedPorts, Port[] internalPorts, EnvVar[] envVars, PodLabels podLabels, PodAnnotations podAnnotations, object[] additionals)
|
public ContainerRecipe(int number, string image, Port[] exposedPorts, Port[] internalPorts, EnvVar[] envVars, PodLabels podLabels, PodAnnotations podAnnotations, VolumeMount[] volumes, object[] additionals)
|
||||||
{
|
{
|
||||||
Number = number;
|
Number = number;
|
||||||
Image = image;
|
Image = image;
|
||||||
@ -11,6 +11,7 @@
|
|||||||
EnvVars = envVars;
|
EnvVars = envVars;
|
||||||
PodLabels = podLabels;
|
PodLabels = podLabels;
|
||||||
PodAnnotations = podAnnotations;
|
PodAnnotations = podAnnotations;
|
||||||
|
Volumes = volumes;
|
||||||
Additionals = additionals;
|
Additionals = additionals;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,6 +23,7 @@
|
|||||||
public EnvVar[] EnvVars { get; }
|
public EnvVar[] EnvVars { get; }
|
||||||
public PodLabels PodLabels { get; }
|
public PodLabels PodLabels { get; }
|
||||||
public PodAnnotations PodAnnotations { get; }
|
public PodAnnotations PodAnnotations { get; }
|
||||||
|
public VolumeMount[] Volumes { get; }
|
||||||
public object[] Additionals { get; }
|
public object[] Additionals { get; }
|
||||||
|
|
||||||
public Port GetPortByTag(string tag)
|
public Port GetPortByTag(string tag)
|
||||||
@ -34,7 +36,8 @@
|
|||||||
return $"(container-recipe: {Name}, image: {Image}, " +
|
return $"(container-recipe: {Name}, image: {Image}, " +
|
||||||
$"exposedPorts: {string.Join(",", ExposedPorts.Select(p => p.Number))}, " +
|
$"exposedPorts: {string.Join(",", ExposedPorts.Select(p => p.Number))}, " +
|
||||||
$"internalPorts: {string.Join(",", InternalPorts.Select(p => p.Number))}, " +
|
$"internalPorts: {string.Join(",", InternalPorts.Select(p => p.Number))}, " +
|
||||||
$"envVars: {string.Join(",", EnvVars.Select(v => v.Name + ":" + v.Value))}, ";
|
$"envVars: {string.Join(",", EnvVars.Select(v => v.Name + ":" + v.Value))}, " +
|
||||||
|
$"volumes: {string.Join(",", Volumes.Select(v => $"'{v.MountPath}'"))}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,4 +64,16 @@
|
|||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
public string Value { get; }
|
public string Value { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class VolumeMount
|
||||||
|
{
|
||||||
|
public VolumeMount(string volumeName, string mountPath)
|
||||||
|
{
|
||||||
|
VolumeName = volumeName;
|
||||||
|
MountPath = mountPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string VolumeName { get; }
|
||||||
|
public string MountPath { get; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
private readonly List<EnvVar> envVars = new List<EnvVar>();
|
private readonly List<EnvVar> envVars = new List<EnvVar>();
|
||||||
private readonly PodLabels podLabels = new PodLabels();
|
private readonly PodLabels podLabels = new PodLabels();
|
||||||
private readonly PodAnnotations podAnnotations = new PodAnnotations();
|
private readonly PodAnnotations podAnnotations = new PodAnnotations();
|
||||||
|
private readonly List<VolumeMount> volumeMounts = new List<VolumeMount>();
|
||||||
private readonly List<object> additionals = new List<object>();
|
private readonly List<object> additionals = new List<object>();
|
||||||
private RecipeComponentFactory factory = null!;
|
private RecipeComponentFactory factory = null!;
|
||||||
|
|
||||||
@ -24,6 +25,7 @@
|
|||||||
envVars.ToArray(),
|
envVars.ToArray(),
|
||||||
podLabels.Clone(),
|
podLabels.Clone(),
|
||||||
podAnnotations.Clone(),
|
podAnnotations.Clone(),
|
||||||
|
volumeMounts.ToArray(),
|
||||||
additionals.ToArray());
|
additionals.ToArray());
|
||||||
|
|
||||||
exposedPorts.Clear();
|
exposedPorts.Clear();
|
||||||
@ -31,6 +33,7 @@
|
|||||||
envVars.Clear();
|
envVars.Clear();
|
||||||
podLabels.Clear();
|
podLabels.Clear();
|
||||||
podAnnotations.Clear();
|
podAnnotations.Clear();
|
||||||
|
volumeMounts.Clear();
|
||||||
additionals.Clear();
|
additionals.Clear();
|
||||||
this.factory = null!;
|
this.factory = null!;
|
||||||
|
|
||||||
@ -94,6 +97,13 @@
|
|||||||
podAnnotations.Add(name, value);
|
podAnnotations.Add(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void AddVolume(string mountPath)
|
||||||
|
{
|
||||||
|
volumeMounts.Add(new VolumeMount(
|
||||||
|
$"autovolume-{Guid.NewGuid().ToString().ToLowerInvariant()}",
|
||||||
|
mountPath));
|
||||||
|
}
|
||||||
|
|
||||||
protected void Additional(object userData)
|
protected void Additional(object userData)
|
||||||
{
|
{
|
||||||
additionals.Add(userData);
|
additionals.Add(userData);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user