Skip to content

Commit

Permalink
Set exposed port of TLS implementation instead first found (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaehren authored Jul 15, 2022
1 parent 7c60fa1 commit d15546d
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class DockerTlsServerInstance extends DockerTlsInstance {
private final String additionalParameters;
private final boolean parallelize;
private final boolean insecureConnection;
private ExposedPort exposedImplementationPort;

public DockerTlsServerInstance(String containerName, ParameterProfile profile, ImageProperties imageProperties,
String version, boolean autoRemove, HostInfo hostInfo, String additionalParameters, boolean parallelize,
Expand Down Expand Up @@ -59,10 +60,10 @@ protected CreateContainerCmd prepareCreateContainerCmd(CreateContainerCmd cmd) {
} else {
host = hostInfo.getHostname();
}
return super.prepareCreateContainerCmd(cmd)
.withCmd(parameterProfile.toParameters(host, hostInfo.getPort(), imageProperties, additionalParameters,
parallelize, insecureConnection))
.withExposedPorts(new ExposedPort(hostInfo.getPort(), hostInfo.getType().toInternetProtocol()));
exposedImplementationPort = new ExposedPort(hostInfo.getPort(), hostInfo.getType().toInternetProtocol());
return super.prepareCreateContainerCmd(cmd).withCmd(parameterProfile.toParameters(host, hostInfo.getPort(),
imageProperties, additionalParameters, parallelize, insecureConnection))
.withExposedPorts(exposedImplementationPort);
}

@Override
Expand All @@ -84,7 +85,12 @@ public void updateInstancePort() {
throw new IllegalStateException(
"Cannot retrieve InstacePort, Network not properly configured for container with ID:" + getId());
}
Binding[] binding = networkSettings.getPorts().getBindings().values().iterator().next();
if (exposedImplementationPort == null) {
throw new IllegalStateException(
"Unable to update port - no exposed port set for container with ID:" + getId());
}

Binding[] binding = networkSettings.getPorts().getBindings().get(exposedImplementationPort);
if (binding != null) {
// only update if port mapping was necessary
port = Integer.valueOf(binding[0].getHostPortSpec());
Expand Down

0 comments on commit d15546d

Please sign in to comment.