Skip to content

Commit

Permalink
kie-kogito-apps-issues-2083: Add the possibility of disabling the def…
Browse files Browse the repository at this point in the history
…ault data-index-url calculation in the data-index-addon (#2084)
  • Loading branch information
wmedvede authored Aug 2, 2024
1 parent ae8aff8 commit a0812e4
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,28 @@ public abstract class AbstractKogitoAddonsQuarkusDataIndexProcessor extends OneO
private static final String QUARKUS_HTTP_PORT = "quarkus.http.port";
private static final String KOGITO_SERVICE_URL_PROP = "kogito.service.url";
private static final String KOGITO_DATA_INDEX_PROP = "kogito.data-index.url";
/**
* Skips the setting of the default kogito.data-index.url from the runtime url.
* This is convenient in scenarios like the dev-ui executing in k8s where want it to set this url using window
* location instead. Must be explicitly set to true to take effect.
*/
private static final String SKIP_DEFAULT_DATA_INDEX_URL_PROP = "kogito.data-index-addons.skip-default-data-index-url";

AbstractKogitoAddonsQuarkusDataIndexProcessor() {
super(KogitoCapability.SERVERLESS_WORKFLOW, KogitoCapability.PROCESSES);
}

@BuildStep(onlyIf = IsDevelopment.class)
public void buildDefaultDataIndexURLSystemProperty(BuildProducer<SystemPropertyBuildItem> systemProperties) {
// Setting a default `kogito.data-index.url` accordingly to the runtime url.
String dataIndexUrl = ConfigProvider.getConfig().getOptionalValue(KOGITO_SERVICE_URL_PROP, String.class).orElseGet(() -> {
Integer port = ConfigProvider.getConfig().getOptionalValue(QUARKUS_HTTP_PORT, Integer.class).orElse(8080);
return "http://localhost:" + port;
});
systemProperties.produce(new SystemPropertyBuildItem(KOGITO_DATA_INDEX_PROP, dataIndexUrl));
boolean skipDefaultDataIndexUrl = ConfigProvider.getConfig().getOptionalValue(SKIP_DEFAULT_DATA_INDEX_URL_PROP, Boolean.class).orElse(false);
if (!skipDefaultDataIndexUrl) {
// Setting a default `kogito.data-index.url` accordingly to the runtime url.
String dataIndexUrl = ConfigProvider.getConfig().getOptionalValue(KOGITO_SERVICE_URL_PROP, String.class).orElseGet(() -> {
Integer port = ConfigProvider.getConfig().getOptionalValue(QUARKUS_HTTP_PORT, Integer.class).orElse(8080);
return "http://localhost:" + port;
});
systemProperties.produce(new SystemPropertyBuildItem(KOGITO_DATA_INDEX_PROP, dataIndexUrl));
}
}

@BuildStep(onlyIf = IsDevelopment.class)
Expand Down

0 comments on commit a0812e4

Please sign in to comment.