Pod labels hook for containers deployed with CodexNetDeployer.

This commit is contained in:
benbierens 2023-09-22 11:10:22 +02:00
parent b8b59508aa
commit e78659690b
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
2 changed files with 32 additions and 0 deletions

View File

@ -85,6 +85,8 @@ namespace CodexNetDeployer
retryDelay: TimeSpan.FromSeconds(3),
kubernetesNamespace: config.KubeNamespace);
configuration.Hooks = new K8sHook(config.TestsTypePodLabel);
return new EntryPoint(log, configuration, string.Empty);
}

View File

@ -0,0 +1,30 @@
using DistTestCore;
using KubernetesWorkflow;
namespace CodexNetDeployer
{
public class K8sHook : IK8sHooks
{
private readonly string testsTypeLabel;
public K8sHook(string testsTypeLabel)
{
this.testsTypeLabel = testsTypeLabel;
}
public void OnContainersStarted(RunningContainers rc)
{
}
public void OnContainersStopped(RunningContainers rc)
{
}
public void OnContainerRecipeCreated(ContainerRecipe recipe)
{
recipe.PodLabels.Add("tests-type", testsTypeLabel);
recipe.PodLabels.Add("runid", NameUtils.GetRunId());
recipe.PodLabels.Add("testid", NameUtils.GetTestId());
}
}
}