Search in sources :

Example 1 with SubscriptionCatalogHealth

use of io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionCatalogHealth in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class OlmBasedStrimziOperatorManager method isSubscriptionInstalled.

private boolean isSubscriptionInstalled() {
    OpenShiftClient client = kubeClient.client().adapt(OpenShiftClient.class);
    Subscription s = client.operatorHub().subscriptions().inNamespace(namespace).withName(OLM_SUBSCRIPTION_NAME).get();
    if (s != null && s.getStatus() != null && !s.getStatus().getCatalogHealth().isEmpty()) {
        List<SubscriptionCatalogHealth> healths = s.getStatus().getCatalogHealth();
        boolean result = !healths.stream().filter(h -> h.getHealthy()).map(ref -> ref.getCatalogSourceRef()).filter(h -> h.getName().equals(CATALOG_SOURCE_NAME)).collect(Collectors.toList()).isEmpty();
        if (result) {
            String currentCsv = s.getStatus().getCurrentCSV();
            if (currentCsv == null) {
                return false;
            }
            ClusterServiceVersion csv = client.operatorHub().clusterServiceVersions().inNamespace(namespace).withName(currentCsv).get();
            if (csv == null) {
                return false;
            }
            versions = csv.getSpec().getInstall().getSpec().getDeployments().stream().map(sds -> sds.getName()).filter(version -> version.startsWith("strimzi-cluster-operator.")).collect(Collectors.toList());
        }
        return result;
    }
    return false;
}
Also used : CatalogSource(io.fabric8.openshift.api.model.operatorhub.v1alpha1.CatalogSource) StrimziOperatorManager(org.bf2.systemtest.operator.StrimziOperatorManager) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) OperatorGroupBuilder(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroupBuilder) CatalogSourceBuilder(io.fabric8.openshift.api.model.operatorhub.v1alpha1.CatalogSourceBuilder) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Collectors(java.util.stream.Collectors) SubscriptionBuilder(io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionBuilder) List(java.util.List) OperatorGroup(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup) Subscription(io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription) Logger(org.apache.logging.log4j.Logger) KubeClient(org.bf2.test.k8s.KubeClient) SubscriptionCatalogHealth(io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionCatalogHealth) Map(java.util.Map) NamespaceBuilder(io.fabric8.kubernetes.api.model.NamespaceBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) ClusterServiceVersion(io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion) ClusterServiceVersion(io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Subscription(io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription) SubscriptionCatalogHealth(io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionCatalogHealth)

Aggregations

NamespaceBuilder (io.fabric8.kubernetes.api.model.NamespaceBuilder)1 OperatorGroup (io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup)1 OperatorGroupBuilder (io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroupBuilder)1 CatalogSource (io.fabric8.openshift.api.model.operatorhub.v1alpha1.CatalogSource)1 CatalogSourceBuilder (io.fabric8.openshift.api.model.operatorhub.v1alpha1.CatalogSourceBuilder)1 ClusterServiceVersion (io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion)1 Subscription (io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription)1 SubscriptionBuilder (io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionBuilder)1 SubscriptionCatalogHealth (io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionCatalogHealth)1 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)1 Kafka (io.strimzi.api.kafka.model.Kafka)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Collectors (java.util.stream.Collectors)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 StrimziOperatorManager (org.bf2.systemtest.operator.StrimziOperatorManager)1