Search in sources :

Example 1 with Subscription

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());
}
Also used : ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) OperatorGroupSpec(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroupSpec) ClusterServiceVersion(io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion) Subscription(io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription) OperatorGroup(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup) SubscriptionSpec(io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionSpec)

Example 2 with Subscription

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);
    }
}
Also used : SubscriptionAdminSettings(com.google.cloud.pubsub.v1.SubscriptionAdminSettings) SubscriptionAdminClient(com.google.cloud.pubsub.v1.SubscriptionAdminClient) Subscription(com.google.pubsub.v1.Subscription) TopicName(com.google.pubsub.v1.TopicName)

Example 3 with Subscription

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());
}
Also used : SubscriptionBuilder(io.fabric8.openclustermanagement.api.model.multicloudoperatorssubscription.apps.v1.SubscriptionBuilder) Subscription(io.fabric8.openclustermanagement.api.model.multicloudoperatorssubscription.apps.v1.Subscription) Test(org.junit.jupiter.api.Test)

Example 4 with Subscription

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());
}
Also used : Scanner(java.util.Scanner) Subscription(io.fabric8.openclustermanagement.api.model.multicloudoperatorssubscription.apps.v1.Subscription) Test(org.junit.jupiter.api.Test)

Example 5 with Subscription

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());
}
Also used : Subscription(io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription) Test(org.junit.jupiter.api.Test)

Aggregations

Subscription (com.google.pubsub.v1.Subscription)83 SubscriptionAdminClient (com.google.cloud.pubsub.v1.SubscriptionAdminClient)40 Test (org.junit.Test)24 TopicName (com.google.pubsub.v1.TopicName)23 Test (org.junit.jupiter.api.Test)23 PushConfig (com.google.pubsub.v1.PushConfig)20 ProjectSubscriptionName (com.google.pubsub.v1.ProjectSubscriptionName)19 Subscription (io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription)19 AbstractMessage (com.google.protobuf.AbstractMessage)18 SubscriptionName (com.google.pubsub.v1.SubscriptionName)18 HashMap (java.util.HashMap)16 ProjectTopicName (com.google.pubsub.v1.ProjectTopicName)15 ByteString (com.google.protobuf.ByteString)14 QuarkusTest (io.quarkus.test.junit.QuarkusTest)11 ListSubscriptionsRequest (com.google.pubsub.v1.ListSubscriptionsRequest)10 GetSubscriptionRequest (com.google.pubsub.v1.GetSubscriptionRequest)8 UpdateSubscriptionRequest (com.google.pubsub.v1.UpdateSubscriptionRequest)8 ListSubscriptionsResponse (com.google.pubsub.v1.ListSubscriptionsResponse)7 ProjectName (com.google.pubsub.v1.ProjectName)6 DeadLetterPolicy (com.google.pubsub.v1.DeadLetterPolicy)5