/ ProjectPlugins / DeployAndRunPlugin / DeployAndRunContainerRecipe.cs
DeployAndRunContainerRecipe.cs
 1  using KubernetesWorkflow;
 2  using KubernetesWorkflow.Recipe;
 3  
 4  namespace DeployAndRunPlugin
 5  {
 6      public class DeployAndRunContainerRecipe : ContainerRecipeFactory
 7      {
 8          public override string AppName => "deploy-and-run";
 9          public override string Image => "thatbenbierens/dist-tests-deployandrun:initial";
10  
11          protected override void Initialize(StartupConfig config)
12          {
13              var setup = config.Get<RunConfig>();
14  
15              if (setup.CodexImageOverride != null)
16              {
17                  AddEnvVar("CODEXDOCKERIMAGE", setup.CodexImageOverride);
18              }
19  
20              AddEnvVar("DNR_REP", setup.Replications.ToString());
21              AddEnvVar("DNR_NAME", setup.Name);
22              AddEnvVar("DNR_FILTER", setup.Filter);
23              AddEnvVar("DNR_DURATION", setup.Duration.TotalSeconds.ToString());
24  
25              AddEnvVar("KUBECONFIG", "/opt/kubeconfig.yaml");
26              AddEnvVar("LOGPATH", "/var/log/codex-continuous-tests");
27  
28              AddVolume(name: "kubeconfig", mountPath: "/opt/kubeconfig.yaml", subPath: "kubeconfig.yaml", secret: "codex-dist-tests-app-kubeconfig");
29              AddVolume(name: "logs", mountPath: "/var/log/codex-continuous-tests", hostPath: "/var/log/codex-continuous-tests");
30          }
31      }
32  
33      public class RunConfig
34      {
35          public RunConfig(string name, string filter, TimeSpan duration, int replications, string? codexImageOverride = null)
36          {
37              Name = name;
38              Filter = filter;
39              Duration = duration;
40              Replications = replications;
41              CodexImageOverride = codexImageOverride;
42          }
43  
44          public string Name { get; }
45          public string Filter { get; }
46          public TimeSpan Duration { get; }
47          public int Replications { get; }
48          public string? CodexImageOverride { get; }
49      }
50  }