diff --git a/README.md b/README.md index 9a044f8e..edf5e797 100644 --- a/README.md +++ b/README.md @@ -249,6 +249,10 @@ and how it advertises itself to a Cryostat server instance. Properties that requ - [ ] `cryostat.agent.harvester.max-size-b` [`long`]: the JFR `maxsize` setting, specified in bytes, to apply to periodic uploads during the application lifecycle. Defaults to `0`, which means `unlimited`. - [ ] `cryostat.agent.smart-trigger.definitions` [`String[]`]: a comma-separated list of Smart Trigger definitions to load at startup. Defaults to the empty string: no Smart Triggers. - [ ] `cryostat.agent.smart-trigger.evaluation.period-ms` [`long`]: the length of time between Smart Trigger evaluations. Default `1000`. +- [ ] `cryostat.agent.callback.scheme` [`String`]: An override for the scheme portion of the `cryostat.agent.callback` URL (e.g. `https`). +- [ ] `cryostat.agent.callback.host-name` [`String[]`]: An override for the host portion of the `cryostat.agent.callback` URL. Supports multiple possible host names. The first host name to resolve when paired with `cryostat.agent.callback.domain-name` will be selected. Supports an optional CEL expression that can be used to transform a provided host name. Only the host name is subject to the provided CEL expression, the domain name is not included. Syntax: `` or `[cel-expression]`, the latter evaluates the following CEL expression and uses the result as a host name candidate: `''.cel-expression`. Example: `host1, hostx[replace("x"\\, "2")]`, the agent will try to resolve host1, followed by host2. +- [ ] `cryostat.agent.callback.domain-name` [`String`]: An override for the domain portion of the `cryostat.agent.callback` URL. This will be appended to a resolvable host name to form the callback URL. +- [ ] `cryostat.agent.callback.port` [`int`]: An override for the port portion of the `cryostat.agent.callback` URL. - [ ] `rht.insights.java.opt-out` [`boolean`]: for the Red Hat build of Cryostat, set this to true to disable data collection for Red Hat Insights. Defaults to `false`. Red Hat Insights data collection is always disabled for community builds of Cryostat. - [ ] `rht.insights.java.debug` [`boolean`]: for the Red Hat build of Cryostat, set this to true to enable debug logging for the Red Hat Insights Java Agent. Defaults to `false`. Red Hat Insights data collection is always disabled for community builds of Cryostat. diff --git a/src/main/java/io/cryostat/agent/ConfigModule.java b/src/main/java/io/cryostat/agent/ConfigModule.java index e2bb4675..744ae960 100644 --- a/src/main/java/io/cryostat/agent/ConfigModule.java +++ b/src/main/java/io/cryostat/agent/ConfigModule.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.net.InetAddress; import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; import java.net.UnknownHostException; @@ -49,8 +50,13 @@ import dagger.Module; import dagger.Provides; +import org.apache.http.client.utils.URIBuilder; import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigProvider; +import org.projectnessie.cel.extension.StringsLib; +import org.projectnessie.cel.tools.Script; +import org.projectnessie.cel.tools.ScriptException; +import org.projectnessie.cel.tools.ScriptHost; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -208,9 +214,20 @@ public abstract class ConfigModule { public static final String CRYOSTAT_AGENT_SMART_TRIGGER_EVALUATION_PERIOD_MS = "cryostat.agent.smart-trigger.evaluation.period-ms"; + public static final String CRYOSTAT_AGENT_CALLBACK_SCHEME = "cryostat.agent.callback.scheme"; + public static final String CRYOSTAT_AGENT_CALLBACK_HOST_NAME = + "cryostat.agent.callback.host-name"; + public static final String CRYOSTAT_AGENT_CALLBACK_DOMAIN_NAME = + "cryostat.agent.callback.domain-name"; + public static final String CRYOSTAT_AGENT_CALLBACK_PORT = "cryostat.agent.callback.port"; + public static final String CRYOSTAT_AGENT_API_WRITES_ENABLED = "cryostat.agent.api.writes-enabled"; + private static final String HOST_SCRIPT_PATTERN_STRING = + "(?[A-Za-z0-9-.]+)(?:\\[(?