2023-11-06 13:33:47 +00:00
|
|
|
|
using k8s;
|
|
|
|
|
using k8s.Models;
|
2023-11-12 09:07:23 +00:00
|
|
|
|
using KubernetesWorkflow.Recipe;
|
|
|
|
|
using KubernetesWorkflow.Types;
|
2023-11-06 13:33:47 +00:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
namespace KubernetesWorkflow
|
2023-04-12 11:53:55 +00:00
|
|
|
|
{
|
2023-11-06 13:33:47 +00:00
|
|
|
|
public class StartResult
|
|
|
|
|
{
|
|
|
|
|
public StartResult(
|
|
|
|
|
K8sCluster cluster,
|
|
|
|
|
ContainerRecipe[] containerRecipes,
|
|
|
|
|
RunningDeployment deployment,
|
|
|
|
|
RunningService? internalService,
|
|
|
|
|
RunningService? externalService)
|
|
|
|
|
{
|
|
|
|
|
Cluster = cluster;
|
|
|
|
|
ContainerRecipes = containerRecipes;
|
|
|
|
|
Deployment = deployment;
|
|
|
|
|
InternalService = internalService;
|
|
|
|
|
ExternalService = externalService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public K8sCluster Cluster { get; }
|
|
|
|
|
public ContainerRecipe[] ContainerRecipes { get; }
|
|
|
|
|
public RunningDeployment Deployment { get; }
|
|
|
|
|
public RunningService? InternalService { get; }
|
|
|
|
|
public RunningService? ExternalService { get; }
|
|
|
|
|
|
2023-11-06 15:52:55 +00:00
|
|
|
|
public Port GetInternalServicePorts(ContainerRecipe recipe, string tag)
|
2023-11-06 13:33:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (InternalService != null)
|
|
|
|
|
{
|
|
|
|
|
var p = InternalService.GetServicePortForRecipeAndTag(recipe, tag);
|
|
|
|
|
if (p != null) return p;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-06 15:52:55 +00:00
|
|
|
|
throw new Exception($"Unable to find internal port by tag '{tag}' for recipe '{recipe.Name}'.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Port GetExternalServicePorts(ContainerRecipe recipe, string tag)
|
|
|
|
|
{
|
2023-11-06 13:33:47 +00:00
|
|
|
|
if (ExternalService != null)
|
|
|
|
|
{
|
|
|
|
|
var p = ExternalService.GetServicePortForRecipeAndTag(recipe, tag);
|
|
|
|
|
if (p != null) return p;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-06 15:52:55 +00:00
|
|
|
|
throw new Exception($"Unable to find external port by tag '{tag}' for recipe '{recipe.Name}'.");
|
2023-11-06 13:33:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Port[] GetServicePortsForContainer(ContainerRecipe recipe)
|
|
|
|
|
{
|
|
|
|
|
if (InternalService != null)
|
|
|
|
|
{
|
|
|
|
|
var p = InternalService.GetServicePortsForRecipe(recipe);
|
|
|
|
|
if (p.Any()) return p;
|
|
|
|
|
}
|
|
|
|
|
if (ExternalService != null)
|
|
|
|
|
{
|
|
|
|
|
var p = ExternalService.GetServicePortsForRecipe(recipe);
|
|
|
|
|
if (p.Any()) return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Array.Empty<Port>();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-12 11:53:55 +00:00
|
|
|
|
}
|