Skip to content

Commit

Permalink
[XENOPS-979] Handle empty registrator variables as not existing
Browse files Browse the repository at this point in the history
  • Loading branch information
vierbergenlars committed Dec 21, 2021
1 parent 45012d5 commit 011663e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ private Optional<String> findValue(ConfigKind configKind, ServiceBinding service
String configKey = "SERVICE"
+serviceBinding.getPort().map(port -> "_"+port).orElse("")
+configKind.getEnvVarSuffix();
if(configuration.getOrDefault(configKey, "").isBlank()) {
return Optional.empty();
}
return Optional.ofNullable(configuration.get(configKey));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,25 @@ public void withHostname() {
.build()
), services);
}

@Test
void emptyServiceName() {
var redis = SimpleContainerMetadata.builder()
.imageName("docker.io/progrium/redis")
.environment("SERVICE_NAME", "")
.internalPortBinding(ServiceBinding.fromPort(8000))
.build();

var services = configurationParser.toServiceConfigurations(redis);

assertEquals(Collections.singleton(
PlatformServiceConfiguration.builder()
.serviceName("redis")
.serviceBinding(ServiceBinding.fromPort(8000))
.build()
), services);

}
}

@Nested
Expand Down

0 comments on commit 011663e

Please sign in to comment.