Search in sources :

Example 26 with Context

use of io.fabric8.mockwebserver.Context in project keycloak by keycloak.

the class KeycloakController method prepareEventSources.

@Override
public List<EventSource> prepareEventSources(EventSourceContext<Keycloak> context) {
    SharedIndexInformer<Deployment> deploymentInformer = client.apps().deployments().inNamespace(context.getConfigurationService().getClientConfiguration().getNamespace()).withLabels(Constants.DEFAULT_LABELS).runnableInformer(0);
    EventSource deploymentEvent = new InformerEventSource<>(deploymentInformer, Mappers.fromOwnerReference());
    return List.of(deploymentEvent);
}
Also used : InformerEventSource(io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource) EventSource(io.javaoperatorsdk.operator.processing.event.source.EventSource) InformerEventSource(io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment)

Example 27 with Context

use of io.fabric8.mockwebserver.Context in project fabric8 by jboss-fuse.

the class ShowConfig method main.

public static void main(String... args) {
    try {
        System.out.println("Current username: " + currentUserName());
        Config config = Configs.parseConfigs();
        if (config == null) {
            System.out.println("No Config loaded!");
        } else {
            Context context = Configs.getCurrentContext(config);
            if (context != null) {
                System.out.println("context:   " + config.getCurrentContext());
                System.out.println("cluster:   " + context.getCluster());
                System.out.println("user:      " + context.getUser());
                System.out.println("namespace: " + context.getNamespace());
            } else {
                System.out.println("No current context!");
            }
        }
    } catch (Exception e) {
        System.out.println("Caught: " + e);
        e.printStackTrace();
    }
}
Also used : Context(io.fabric8.kubernetes.api.model.Context) Config(io.fabric8.kubernetes.api.model.Config)

Example 28 with Context

use of io.fabric8.mockwebserver.Context in project jbosstools-openshift by jbosstools.

the class OdoCli method createService.

@Override
public void createService(String project, String application, ServiceTemplate serviceTemplate, OperatorCRD serviceCRD, String service, ObjectNode spec, boolean wait) throws IOException {
    try {
        CustomResourceDefinitionContext context = toCustomResourceDefinitionContext(serviceCRD);
        ObjectNode payload = serviceCRD.getSample().deepCopy();
        updatePayload(payload, spec, project, service);
        client.customResource(context).create(project, JSON_MAPPER.writeValueAsString(payload));
        UsageStats.getInstance().odoCommand("service create", true);
        UsageStats.getInstance().createService(serviceTemplate.getName(), true);
    } catch (KubernetesClientException e) {
        UsageStats.getInstance().odoCommand("service create", false);
        UsageStats.getInstance().createService(serviceTemplate.getName(), false);
        throw new IOException(e.getLocalizedMessage(), e);
    } catch (IOException e) {
        UsageStats.getInstance().odoCommand("service create", false);
        UsageStats.getInstance().createService(serviceTemplate.getName(), false);
        throw e;
    }
}
Also used : CustomResourceDefinitionContext(io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) IOException(java.io.IOException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Example 29 with Context

use of io.fabric8.mockwebserver.Context in project fabric8-maven-plugin by fabric8io.

the class IconEnricher method getDefaultIconRef.

/**
 * Lets use the project and its classpath to try figure out what default icon to use
 *
 * @return the icon ref if we can detect one or return null
 */
private String getDefaultIconRef() {
    MavenProject project = getProject();
    EnricherContext context = getContext();
    if (hasClass(project, "io.fabric8.funktion.runtime.Main") || MavenUtil.hasDependencyOnAnyArtifactOfGroup(project, "io.fabric8.funktion")) {
        return "funktion";
    }
    if (hasClass(project, "org.apache.camel.CamelContext")) {
        return "camel";
    }
    if (hasPlugin(project, "org.springframework.boot:spring-boot-maven-plugin") || hasClass(project, "org.springframework.boot.SpringApplication")) {
        return "spring-boot";
    }
    if (hasClass(project, "org.springframework.core.Constants")) {
        return "spring";
    }
    if (hasClass(project, "org.vertx.java.core.Handler", "io.vertx.core.Handler")) {
        return "vertx";
    }
    if (hasPlugin(project, "org.wildfly.swarm:wildfly-swarm-plugin") || MavenUtil.hasDependencyOnAnyArtifactOfGroup(project, "org.wildfly.swarm")) {
        return "wildfly-swarm";
    }
    return null;
}
Also used : MavenProject(org.apache.maven.project.MavenProject) EnricherContext(io.fabric8.maven.enricher.api.EnricherContext)

Example 30 with Context

use of io.fabric8.mockwebserver.Context in project fabric8-maven-plugin by fabric8io.

the class AbstractSpringBootHealthCheckEnricherSupport method testSchemeWithServerPortAndServerKeystore.

@Test
public void testSchemeWithServerPortAndServerKeystore() {
    SpringBootHealthCheckEnricher enricher = new SpringBootHealthCheckEnricher(context);
    Properties props = new Properties();
    props.put(propertyHelper.getServerPortPropertyKey(), "8443");
    props.put(propertyHelper.getServerKeystorePropertyKey(), "classpath:keystore.p12");
    Probe probe = enricher.buildProbe(props, 10, null);
    assertNotNull(probe);
    assertNotNull(probe.getHttpGet());
    assertEquals("HTTPS", probe.getHttpGet().getScheme());
    assertEquals(8443, probe.getHttpGet().getPort().getIntVal().intValue());
}
Also used : Probe(io.fabric8.kubernetes.api.model.Probe) Test(org.junit.Test)

Aggregations

Test (org.junit.jupiter.api.Test)593 Checkpoint (io.vertx.junit5.Checkpoint)574 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)543 VertxTestContext (io.vertx.junit5.VertxTestContext)542 Vertx (io.vertx.core.Vertx)539 Reconciliation (io.strimzi.operator.common.Reconciliation)532 VertxExtension (io.vertx.junit5.VertxExtension)514 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)514 BeforeAll (org.junit.jupiter.api.BeforeAll)466 AfterAll (org.junit.jupiter.api.AfterAll)462 CoreMatchers.is (org.hamcrest.CoreMatchers.is)458 Future (io.vertx.core.Future)429 Mockito.when (org.mockito.Mockito.when)410 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)379 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)368 PlatformFeaturesAvailability (io.strimzi.operator.PlatformFeaturesAvailability)360 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)356 ResourceOperatorSupplier (io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier)352 List (java.util.List)352 KubernetesVersion (io.strimzi.operator.KubernetesVersion)344