use of io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion in project quarkus-test-framework by quarkus-qe.
the class OpenShiftClient method installOperator.
public void installOperator(Service service, String name, String channel, String source, String sourceNamespace) {
if (!ENABLED_EPHEMERAL_NAMESPACES.getAsBoolean()) {
throw new UnsupportedOperationException("Operators not supported with ephemeral namespaces disabled");
}
// Install the operator group
OperatorGroup groupModel = new OperatorGroup();
groupModel.setMetadata(new ObjectMeta());
groupModel.getMetadata().setName(service.getName());
groupModel.setSpec(new OperatorGroupSpec());
groupModel.getSpec().setTargetNamespaces(Arrays.asList(currentNamespace));
client.resource(groupModel).createOrReplace();
// Install the subscription
Subscription subscriptionModel = new Subscription();
subscriptionModel.setMetadata(new ObjectMeta());
subscriptionModel.getMetadata().setName(name);
subscriptionModel.getMetadata().setNamespace(currentNamespace);
subscriptionModel.setSpec(new SubscriptionSpec());
subscriptionModel.getSpec().setChannel(channel);
subscriptionModel.getSpec().setName(name);
subscriptionModel.getSpec().setSource(source);
subscriptionModel.getSpec().setSourceNamespace(sourceNamespace);
Log.info("Installing operator... %s", service.getName());
client.operatorHub().subscriptions().create(subscriptionModel);
// Wait for the operator to be installed
untilIsTrue(() -> {
// Get Cluster Service Version
Subscription subscription = client.operatorHub().subscriptions().withName(name).get();
String installedCsv = subscription.getStatus().getInstalledCSV();
if (StringUtils.isEmpty(installedCsv)) {
return false;
}
// Check Cluster Service Version status
ClusterServiceVersion operatorService = client.operatorHub().clusterServiceVersions().withName(installedCsv).get();
return OPERATOR_PHASE_INSTALLED.equals(operatorService.getStatus().getPhase());
}, AwaitilitySettings.defaults().withService(service).usingTimeout(service.getConfiguration().getAsDuration(OPERATOR_INSTALL_TIMEOUT, TIMEOUT_DEFAULT)));
Log.info("Operator installed... %s", service.getName());
}
use of io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion in project kubernetes-client by fabric8io.
the class ClusterServiceVersionTest method testLoad.
@Test
void testLoad() {
ClusterServiceVersion clusterServiceVersion = client.operatorHub().clusterServiceVersions().load(getClass().getResourceAsStream("/test-clusterserviceversion.yml")).get();
assertThat(clusterServiceVersion).isNotNull().hasFieldOrPropertyWithValue("metadata.name", "memcached-operator.v0.0.1").hasFieldOrPropertyWithValue("spec.version", "0.0.1");
}
use of io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion 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;
}
Aggregations