Skip to content

Commit

Permalink
CRYOSTAT_PLATFORM takes comma-separated list
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Azores <aazores@redhat.com>
  • Loading branch information
andrewazores committed Mar 14, 2023
1 parent 50a3d03 commit dfae9a1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Cryostat can be configured via the following environment variables:
* `CRYOSTAT_CORS_ORIGIN`: the origin for CORS to load a different cryostat-web instance. Defaults to the empty string, which disables CORS.
* `CRYOSTAT_MAX_WS_CONNECTIONS`: the maximum number of websocket client connections allowed (minimum 1, maximum `Integer.MAX_VALUE`, default `Integer.MAX_VALUE`)
* `CRYOSTAT_AUTH_MANAGER`: the authentication/authorization manager used for validating user accesses. See the `USER AUTHENTICATION / AUTHORIZATION` section for more details. Set to the fully-qualified class name of the auth manager implementation to use, ex. `io.cryostat.net.BasicAuthManager`. Defaults to an AuthManager corresponding to the selected deployment platform, whether explicit or automatic (see below).
* `CRYOSTAT_PLATFORM`: the platform client used for performing platform-specific actions, such as listing available target JVMs. If `CRYOSTAT_AUTH_MANAGER` is not specified then a default auth manager will also be selected corresponding to the platform, whether that platform is specified by the user or automatically detected. Set to the fully-qualified name of the platform detection strategy implementation to use, ex. `io.cryostat.platform.internal.KubeEnvPlatformStrategy`.
* `CRYOSTAT_PLATFORM`: the platform clients used for performing platform-specific actions, such as listing available target JVMs. If `CRYOSTAT_AUTH_MANAGER` is not specified then a default auth manager will also be selected corresponding to the highest priority platform, whether those platforms are specified by the user or automatically detected. Set to the fully-qualified names of the platform detection strategy implementations to use, ex. `io.cryostat.platform.internal.KubeEnvPlatformStrategy,io.cryostat.platform.internal.PodmanPlatformStrategy`.
* `CRYOSTAT_ENABLE_JDP_BROADCAST`: enable the Cryostat JVM to broadcast itself via JDP (Java Discovery Protocol). Defaults to `true`.
* `CRYOSTAT_JDP_ADDRESS`: the JDP multicast address to send discovery packets. Defaults to `224.0.23.178`.
* `CRYOSTAT_JDP_PORT`: the JDP multicast port to send discovery packets. Defaults to `7095`.
Expand Down
28 changes: 24 additions & 4 deletions src/main/java/io/cryostat/platform/PlatformModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
*/
package io.cryostat.platform;

import java.util.Arrays;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Set;
import java.util.SortedSet;
Expand Down Expand Up @@ -115,8 +118,9 @@ static SortedSet<PlatformDetectionStrategy<?>> provideSelectedPlatformStrategies
new TreeSet<>((a, b) -> Integer.compare(b.getPriority(), a.getPriority()));
Predicate<PlatformDetectionStrategy<?>> fn;
if (env.hasEnv(Variables.PLATFORM_STRATEGY_ENV_VAR)) {
String platform = env.getEnv(Variables.PLATFORM_STRATEGY_ENV_VAR);
fn = s -> Objects.equals(platform, s.getClass().getCanonicalName());
List<String> platforms =
Arrays.asList(env.getEnv(Variables.PLATFORM_STRATEGY_ENV_VAR).split(","));
fn = s -> platforms.contains(s.getClass().getCanonicalName());
} else if (env.hasEnv(Variables.DISABLE_BUILTIN_DISCOVERY)) {
fn = s -> false;
} else {
Expand Down Expand Up @@ -146,7 +150,23 @@ static SortedSet<PlatformDetectionStrategy<?>> provideUnselectedPlatformStrategi
@Provides
@Singleton
static PlatformDetectionStrategy<?> providePlatformStrategy(
@Named(SELECTED_PLATFORMS) SortedSet<PlatformDetectionStrategy<?>> strategies) {
return strategies.stream().findFirst().orElseThrow();
@Named(SELECTED_PLATFORMS) SortedSet<PlatformDetectionStrategy<?>> selectedStrategies,
Set<PlatformDetectionStrategy<?>> strategies) {
return selectedStrategies.stream()
.findFirst()
.orElseThrow(
() ->
new NoSuchElementException(
String.format(
"No selected platforms found. Available platforms:"
+ " %s",
strategies.stream()
.sorted(
(a, b) ->
Integer.compare(
b.getPriority(),
a.getPriority()))
.map(s -> s.getClass().getCanonicalName())
.toList())));
}
}

0 comments on commit dfae9a1

Please sign in to comment.