Skip to content

Commit

Permalink
Fix nightly failures
Browse files Browse the repository at this point in the history
Before that change we used quarkus CLI properties as environment
variables in openshift manifests (which we should not have do) and
for some reason it worked (which it should not have do).
When this behaviour was changed upstream, our jobs started to fail,
this change should fix that.

See quarkusio/quarkus#36359 for details
  • Loading branch information
fedinskiy committed Oct 12, 2023
1 parent a24be04 commit f7ab4de
Showing 1 changed file with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,10 @@ private String enrichTemplate(Service service, String template, Map<String, Stri

// add env var properties
Map<String, String> enrichProperties = enrichProperties(service.getProperties(), dc);
enrichProperties.putAll(extraTemplateProperties);
Map<String, String> environmentVariables = convertPropertiesToEnvironment(enrichProperties);
environmentVariables.putAll(extraTemplateProperties);
dc.getSpec().getTemplate().getSpec().getContainers()
.forEach(container -> enrichProperties.entrySet().forEach(
.forEach(container -> environmentVariables.entrySet().forEach(
property -> {
String key = property.getKey();
EnvVar envVar = getEnvVarByKey(key, container);
Expand All @@ -740,6 +741,28 @@ private String enrichTemplate(Service service, String template, Map<String, Stri
return template;
}

/**
*
* Converts names of Quarkus properties to names of environment variables,
* eg. quarkus.consul-config.agent.host-port->QUARKUS_CONSUL_CONFIG_AGENT_HOST_PORT
*
* see https://quarkus.io/guides/config-reference#environment-variables for details
*/
private static Map<String, String> convertPropertiesToEnvironment(Map<String, String> properties) {
HashMap<String, String> environment = new HashMap<>(properties.size());
properties.forEach((property, value) -> {
String variable;
if (property.startsWith("quarkus.")) {
variable = property.toUpperCase()
.replaceAll("[^\\p{Alnum}]{1}", "_");
} else {
variable = property;
}
environment.put(variable, value);
});
return environment;
}

private EnvVar getEnvVarByKey(String key, Container container) {
return container.getEnv().stream().filter(env -> StringUtils.equals(key, env.getName())).findFirst().orElse(null);
}
Expand Down

0 comments on commit f7ab4de

Please sign in to comment.