Adds numberSource for correct range for external ports

This commit is contained in:
benbierens 2023-11-13 15:27:52 +01:00
parent ca350604e3
commit b82c74865e
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
2 changed files with 11 additions and 5 deletions

View File

@ -52,7 +52,7 @@ namespace KubernetesWorkflow.Recipe
protected Port AddExposedPort(string tag, PortProtocol protocol = PortProtocol.TCP)
{
return AddExposedPort(factory.CreatePort(tag, protocol));
return AddExposedPort(factory.CreateExternalPort(tag, protocol));
}
protected Port AddExposedPort(int number, string tag, PortProtocol protocol = PortProtocol.TCP)
@ -62,7 +62,7 @@ namespace KubernetesWorkflow.Recipe
protected Port AddInternalPort(string tag = "", PortProtocol protocol = PortProtocol.TCP)
{
var p = factory.CreatePort(tag, protocol);
var p = factory.CreateInternalPort(tag, protocol);
internalPorts.Add(p);
return p;
}

View File

@ -5,16 +5,22 @@ namespace KubernetesWorkflow.Recipe
{
public class RecipeComponentFactory
{
private NumberSource portNumberSource = new NumberSource(8080);
private NumberSource internalNumberSource = new NumberSource(8080);
private NumberSource externalNumberSource = new NumberSource(30000);
public Port CreatePort(int number, string tag, PortProtocol protocol)
{
return new Port(number, tag, protocol);
}
public Port CreatePort(string tag, PortProtocol protocol)
public Port CreateInternalPort(string tag, PortProtocol protocol)
{
return new Port(portNumberSource.GetNextNumber(), tag, protocol);
return new Port(internalNumberSource.GetNextNumber(), tag, protocol);
}
public Port CreateExternalPort(string tag, PortProtocol protocol)
{
return new Port(externalNumberSource.GetNextNumber(), tag, protocol);
}
public EnvVar CreateEnvVar(string name, int value)