use of io.stackgres.operator.customresource.prometheus.PrometheusConfig in project stackgres by ongres.
the class ClusterRequiredResourcesGenerator method getPrometheus.
public Optional<Prometheus> getPrometheus(StackGresCluster cluster) {
boolean isAutobindAllowed = operatorContext.getBoolean(OperatorProperty.PROMETHEUS_AUTOBIND);
boolean isPrometheusAutobindEnabled = Optional.ofNullable(cluster.getSpec().getPrometheusAutobind()).orElse(false);
if (isAutobindAllowed && isPrometheusAutobindEnabled) {
LOGGER.trace("Prometheus auto bind enabled, looking for prometheus installations");
final Optional<List<PrometheusConfig>> prometheusConfigsOpt = prometheusScanner.findResources();
return prometheusConfigsOpt.map(prometheusConfigs -> prometheusConfigs.stream().map(ClusterRequiredResourcesGenerator::toPrometheusInstallation).collect(Collectors.toUnmodifiableList())).map(installations -> new Prometheus(!installations.isEmpty(), installations));
} else {
return Optional.of(new Prometheus(false, null));
}
}
Aggregations