use of io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription 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.Subscription in project camel-kafka-connector by apache.
the class GooglePubEasy method createSubscription.
public void createSubscription(String subscriptionName, String topicName) throws IOException {
TopicName googleTopic = TopicName.of(project, topicName);
projectSubscriptionName = ProjectSubscriptionName.of(project, subscriptionName);
SubscriptionAdminSettings adminSettings = SubscriptionAdminSettings.newBuilder().setCredentialsProvider(NoCredentialsProvider.create()).setTransportChannelProvider(channelProvider).build();
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create(adminSettings)) {
Subscription subscription = subscriptionAdminClient.createSubscription(projectSubscriptionName, googleTopic, PushConfig.getDefaultInstance(), 10);
}
}
use of io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription in project kubernetes-client by fabric8io.
the class SubscriptionTest method builderShouldCreateObject.
@Test
void builderShouldCreateObject() {
// Given
SubscriptionBuilder subscriptionBuilder = new SubscriptionBuilder().withNewMetadata().addToLabels("vendor", "OpenShift").withName("sample_subscription").addToAnnotations("apps.open-cluster-management.io/git-path", "apps/sample/").addToAnnotations("apps.open-cluster-management.io/git-branch", "sample_branch").endMetadata().withNewSpec().withChannel("channel_namespace/sample_channel").addNewPackageOverride().withPackageName("my-sample-application").withPackageAlias("the-sample-app").endPackageOverride().endSpec();
// When
Subscription subscription = subscriptionBuilder.build();
// Then
assertNotNull(subscription);
assertEquals("sample_subscription", subscription.getMetadata().getName());
assertEquals(1, subscription.getMetadata().getLabels().size());
assertEquals(2, subscription.getMetadata().getAnnotations().size());
assertEquals("channel_namespace/sample_channel", subscription.getSpec().getChannel());
assertEquals(1, subscription.getSpec().getPackageOverrides().size());
}
use of io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription in project kubernetes-client by fabric8io.
the class SubscriptionTest method deserializationAndSerializationShouldWorkAsExpected.
@Test
void deserializationAndSerializationShouldWorkAsExpected() throws IOException {
// Given
String originalJson = new Scanner(getClass().getResourceAsStream("/valid-subscription.json")).useDelimiter("\\A").next();
// When
final Subscription subscription = mapper.readValue(originalJson, Subscription.class);
final String serializedJson = mapper.writeValueAsString(subscription);
final Subscription subscriptionFromSerializedJson = mapper.readValue(serializedJson, Subscription.class);
// Then
assertNotNull(subscription);
assertNotNull(serializedJson);
assertNotNull(subscriptionFromSerializedJson);
assertEquals(subscription.getMetadata().getName(), subscriptionFromSerializedJson.getMetadata().getName());
assertEquals("channel_namespace/sample_channel", subscription.getSpec().getChannel());
assertEquals(1, subscription.getSpec().getPackageOverrides().size());
assertEquals(1, subscription.getSpec().getPackageOverrides().get(0).getPackageOverrides().size());
assertEquals("PlacementRule", subscription.getSpec().getPlacement().getPlacementRef().getKind());
assertEquals("demo-clusters", subscription.getSpec().getPlacement().getPlacementRef().getName());
}
use of io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription in project kubernetes-client by fabric8io.
the class SubscriptionTest method create.
@Test
void create() {
// Given
Subscription subscription = getSubscription();
server.expect().post().withPath("/apis/operators.coreos.com/v1alpha1/namespaces/ns1/subscriptions").andReturn(HttpURLConnection.HTTP_OK, subscription).once();
// When
subscription = client.operatorHub().subscriptions().inNamespace("ns1").create(subscription);
// Then
assertNotNull(subscription);
assertEquals("foo", subscription.getMetadata().getName());
}
Aggregations