diff --git a/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmProcessor.java b/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmProcessor.java index 49f61e6..0546d31 100644 --- a/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmProcessor.java @@ -15,6 +15,7 @@ import java.util.Locale; import java.util.Map; import java.util.Optional; +import java.util.Scanner; import java.util.Set; import java.util.stream.Collectors; @@ -49,6 +50,7 @@ public class HelmProcessor { private static final Logger LOGGER = Logger.getLogger(HelmProcessor.class); private static final String NAME_FORMAT_REG_EXP = "[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*"; + private static final String BUILD_TIME_PROPERTIES = "/build-time-list"; private static final String QUARKUS_KUBERNETES_NAME = "quarkus.kubernetes.name"; private static final String QUARKUS_KNATIVE_NAME = "quarkus.knative.name"; @@ -60,18 +62,21 @@ public class HelmProcessor { private static final String PROPERTIES_CONFIG_SOURCE = "PropertiesConfigSource"; private static final String SYSTEM_PROPERTY_START = "${"; private static final String SYSTEM_PROPERTY_END = "}"; + // Lazy loaded when calling `isBuildTimeProperty(xxx)`. + private static Set buildProperties; @BuildStep(onlyIf = { HelmEnabled.class, IsNormal.class }) void mapSystemPropertiesIfEnabled(Capabilities capabilities, ApplicationInfoBuildItem info, HelmChartConfig helmConfig, BuildProducer decorators) { if (helmConfig.mapSystemProperties) { String deploymentName = getDeploymentName(capabilities, info); - Config config = ConfigProvider.getConfig(); - config.getPropertyNames().forEach(propName -> { + for (String propName : config.getPropertyNames()) { ConfigValue propValue = config.getConfigValue(propName); String rawValue = propValue.getRawValue(); - if (isPropertiesConfigSource(propValue.getSourceName()) && isSystemProperty(rawValue)) { + if (isPropertiesConfigSource(propValue.getSourceName()) + && isSystemProperty(rawValue) + && !isBuildTimeProperty(propValue.getName())) { while (isSystemProperty(rawValue)) { int start = rawValue.indexOf(SYSTEM_PROPERTY_START); int end = rawValue.indexOf(SYSTEM_PROPERTY_END, start); @@ -89,7 +94,7 @@ void mapSystemPropertiesIfEnabled(Capabilities capabilities, ApplicationInfoBuil rawValue = rawValue.substring(end + SYSTEM_PROPERTY_END.length()); } } - }); + } } } @@ -415,6 +420,26 @@ private boolean isPropertiesConfigSource(String sourceName) { return Strings.isNotNullOrEmpty(sourceName) && sourceName.startsWith(PROPERTIES_CONFIG_SOURCE); } + private boolean isBuildTimeProperty(String name) { + if (buildProperties == null) { + buildProperties = new HashSet<>(); + try { + Scanner scanner = new Scanner(new File(HelmProcessor.class.getResource(BUILD_TIME_PROPERTIES).getFile())); + while (scanner.hasNextLine()) { + buildProperties.add(scanner.nextLine()); + } + } catch (Exception e) { + LOGGER.debugf("Can't read the build time properties file at '%s'. Caused by: %s", + BUILD_TIME_PROPERTIES, + e.getMessage()); + } + } + + return buildProperties.stream().anyMatch(build -> name.matches(build) // It's a regular expression + || (build.endsWith(".") && name.startsWith(build)) // contains with + || name.equals(build)); // or it's equal to + } + private boolean isSystemProperty(String rawValue) { return Strings.isNotNullOrEmpty(rawValue) && rawValue.contains(SYSTEM_PROPERTY_START); } diff --git a/deployment/src/main/resources/build-time-list b/deployment/src/main/resources/build-time-list new file mode 100644 index 0000000..b405e98 --- /dev/null +++ b/deployment/src/main/resources/build-time-list @@ -0,0 +1,97 @@ +# List of properties that will trigger a full build of a Quarkus application +# regular expression or start with +quarkus.amqp.devservices.enabled +quarkus.apicurio-registry.devservices.enabled +quarkus.artemis.health.enabled +quarkus.cache.enabled +quarkus.datasource.db-kind +quarkus.datasource.devservices.enabled +quarkus.datasource.devservices.image-name +quarkus.datasource.devservices.port +quarkus.datasource.devservices.properties +quarkus.datasource.health-exclude +quarkus.datasource.jdbc +quarkus.datasource.jdbc.driver +quarkus.datasource.jdbc.enable-metrics +quarkus.datasource.jdbc.transactions +quarkus.datasource.reactive +quarkus.datasource.(.+).db-kind +quarkus.datasource.(.+).devservices.enabled +quarkus.datasource.(.+).devservices.image-name +quarkus.datasource.(.+).devservices.port +quarkus.datasource.(.+).devservices.properties +quarkus.datasource.(.+).health-exclude +quarkus.datasource.(.+).jdbc +quarkus.datasource.(.+).jdbc.driver +quarkus.datasource.(.+).jdbc.enable-metrics +quarkus.datasource.(.+).jdbc.transactions +quarkus.datasource.(.+).reactive +quarkus.elasticsearch.health.enabled +quarkus.grpc.metrics.enabled +quarkus.grpc.server.grpc-health.enabled +quarkus.grpc.server.health.enabled +quarkus.health.extensions.enabled +quarkus.hibernate-orm. +quarkus.hibernate-orm.metrics.enabled +quarkus.http.auth.form.enabled +quarkus.http.auth.permission.(.+).enabled +quarkus.http.non-application-root-path +quarkus.http.redirect-to-non-application-root-path +quarkus.http.root-path +quarkus.http.ssl.client-auth +quarkus.jaeger.enabled +quarkus.jaeger.metrics.enabled +quarkus.kafka-streams.health.enabled +quarkus.kafka.devservices.enabled +quarkus.kafka.health.enabled +quarkus.kafka.snappy.enabled +quarkus.keycloak.devservices.enabled +quarkus.kubernetes-config.secrets.enabled +quarkus.kubernetes. +quarkus.micrometer.binder.http-client.enabled +quarkus.micrometer.binder.http-server.enabled +quarkus.micrometer.binder.kafka.enabled +quarkus.micrometer.binder.mp-metrics.enabled +quarkus.micrometer.binder.vertx.enabled +quarkus.micrometer.enabled +quarkus.micrometer.export.json.enabled +quarkus.micrometer.export.prometheus.enabled +quarkus.mongodb.devservices.enabled +quarkus.mongodb.health.enabled +quarkus.mongodb.metrics.enabled +quarkus.mongodb.tracing.enabled +quarkus.native.debug.enabled +quarkus.neo4j.health.enabled +quarkus.oauth2.enabled +quarkus.oidc-client.enabled +quarkus.oidc-token-propagation.enabled +quarkus.oidc.enabled +quarkus.openshift. +quarkus.opentelemetry.enabled +quarkus.opentelemetry.tracer.enabled +quarkus.opentelemetry.tracer.exporter.jaeger.enabled +quarkus.opentelemetry.tracer.exporter.otlp.enabled +quarkus.package.type +quarkus.reactive-messaging.health.enabled +quarkus.reactive-messaging.kafka.serializer-autodetection.enabled +quarkus.reactive-messaging.metrics.enabled +quarkus.redis.devservices.enabled +quarkus.redis.health.enabled +quarkus.resteasy.gzip.enabled +quarkus.resteasy.metrics.enabled +quarkus.security.jdbc.enabled +quarkus.security.ldap.enabled +quarkus.security.users.embedded.enabled +quarkus.security.users.file.enabled +quarkus.smallrye-graphql.events.enabled +quarkus.smallrye-graphql.http.get.enabled +quarkus.smallrye-graphql.http.post.queryparameters.enabled +quarkus.smallrye-graphql.metrics.enabled +quarkus.smallrye-graphql.tracing.enabled +quarkus.smallrye-graphql.validation.enabled +quarkus.smallrye-jwt.enabled +quarkus.smallrye-metrics.extensions.enabled +quarkus.smallrye-metrics.jaxrs.enabled +quarkus.ssl.native +quarkus.vault.devservices.enabled +quarkus.vault.health.enabled \ No newline at end of file diff --git a/docs/modules/ROOT/pages/includes/attributes.adoc b/docs/modules/ROOT/pages/includes/attributes.adoc index c63f74a..dad7b7e 100644 --- a/docs/modules/ROOT/pages/includes/attributes.adoc +++ b/docs/modules/ROOT/pages/includes/attributes.adoc @@ -1,4 +1,4 @@ -:quarkus-version: 2.16.2.Final +:quarkus-version: 2.16.3.Final :quarkus-helm-version: 0.2.6 :maven-version: 3.8.1+ diff --git a/integration-tests/helm-kubernetes-full/src/main/resources/application.properties b/integration-tests/helm-kubernetes-full/src/main/resources/application.properties index 87f0785..1adb8ca 100644 --- a/integration-tests/helm-kubernetes-full/src/main/resources/application.properties +++ b/integration-tests/helm-kubernetes-full/src/main/resources/application.properties @@ -37,4 +37,6 @@ quarkus.helm.values.host.value=override-host-in-helm # Resteasy Reactive quarkus.resteasy-reactive.path=${OVERRIDE_PATH} quarkus.host.port=${OVERRIDE_PORT:8080} -quarkus.host.name=something:${OVERRIDE_PART1}-${OVERRIDE_PART2:default} \ No newline at end of file +quarkus.host.name=something:${OVERRIDE_PART1}-${OVERRIDE_PART2:default} +## this should be ignored +quarkus.kubernetes.annotations.\"app.quarkus.io/vcs-url\"=${BUILD_TIME_PROPERTY} \ No newline at end of file diff --git a/integration-tests/helm-kubernetes-full/src/test/java/io/quarkiverse/helm/tests/kubernetes/KubernetesFullIT.java b/integration-tests/helm-kubernetes-full/src/test/java/io/quarkiverse/helm/tests/kubernetes/KubernetesFullIT.java index 4f6dda7..4bb98c2 100644 --- a/integration-tests/helm-kubernetes-full/src/test/java/io/quarkiverse/helm/tests/kubernetes/KubernetesFullIT.java +++ b/integration-tests/helm-kubernetes-full/src/test/java/io/quarkiverse/helm/tests/kubernetes/KubernetesFullIT.java @@ -78,6 +78,8 @@ public void valuesShouldContainExpectedData() throws IOException { // Should contain system property OVERRIDE_PORT which value is specified // using "quarkus.kubernetes.env.vars.OVERRIDE_PORT=8081" assertEquals("8081", envs.get("OVERRIDE_PORT")); + // Build time properties should not be mapped + assertNull(envs.get("BUILD_TIME_PROPERTY")); } @Test