Search in sources :

Example 1 with EndpointsListBuilder

use of io.fabric8.kubernetes.api.model.EndpointsListBuilder in project fabric8 by fabric8io.

the class MockConfigurer method configure.

public static void configure() {
    Service service1 = new ServiceBuilder().withNewMetadata().withName("service1").endMetadata().withNewSpec().addNewPort().withProtocol("TCP").withPort(80).withNewTargetPort(9090).endPort().endSpec().build();
    Service service2 = new ServiceBuilder().withNewMetadata().withName("service2").endMetadata().withNewSpec().addNewPort().withProtocol("TCP").withPort(80).withNewTargetPort(8080).endPort().endSpec().build();
    Service service3 = new ServiceBuilder().withNewMetadata().withName("service3").endMetadata().withNewSpec().addNewPort().withProtocol("TCP").withPort(443).withNewTargetPort(443).endPort().withClusterIP("172.30.17.2").endSpec().build();
    Service multiport = new ServiceBuilder().withNewMetadata().withName("multiport").endMetadata().withNewSpec().addNewPort().withName("port1").withProtocol("TCP").withPort(8081).withNewTargetPort(8081).endPort().addNewPort().withName("port2").withProtocol("TCP").withPort(8082).withNewTargetPort(8082).endPort().addNewPort().withName("port3").withProtocol("TCP").withPort(8083).withNewTargetPort(8083).endPort().withClusterIP("172.30.17.2").endSpec().build();
    MOCK.expect().get().withPath("/api/v1/namespaces/default/services/service1").andReturn(200, service1).always();
    MOCK.expect().get().withPath("/api/v1/namespaces/default/services/service2").andReturn(200, service2).always();
    MOCK.expect().get().withPath("/api/v1/namespaces/default/services/service3").andReturn(200, service3).always();
    MOCK.expect().get().withPath("/api/v1/namespaces/default/services/multiport").andReturn(200, multiport).always();
    MOCK.expect().get().withPath("/api/v1/namespaces/default/services").andReturn(200, new ServiceListBuilder().withItems(service1, service2, service3, multiport).build()).always();
    MOCK.expect().get().withPath("/api/v1/namespaces/default/endpoints").andReturn(200, new EndpointsListBuilder().build()).always();
    MOCK.expect().get().withPath("/oapi/v1/namespaces/default/routes").andReturn(200, new RouteBuilder().build()).always();
    String masterUrl = MOCK.getServer().url("/").toString();
    System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, masterUrl);
}
Also used : ServiceListBuilder(io.fabric8.kubernetes.api.model.ServiceListBuilder) RouteBuilder(io.fabric8.openshift.api.model.RouteBuilder) Service(io.fabric8.kubernetes.api.model.Service) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) EndpointsListBuilder(io.fabric8.kubernetes.api.model.EndpointsListBuilder)

Example 2 with EndpointsListBuilder

use of io.fabric8.kubernetes.api.model.EndpointsListBuilder in project fabric8 by fabric8io.

the class MockConfigurer method configure.

public static void configure() {
    Service service1 = new ServiceBuilder().withNewMetadata().withName("service1").endMetadata().withNewSpec().addNewPort().withProtocol("TCP").withPort(80).withNewTargetPort(9090).endPort().endSpec().build();
    Service service2 = new ServiceBuilder().withNewMetadata().withName("service2").endMetadata().withNewSpec().addNewPort().withProtocol("TCP").withPort(80).withNewTargetPort(8080).endPort().endSpec().build();
    Service service3 = new ServiceBuilder().withNewMetadata().withName("service3").endMetadata().withNewSpec().addNewPort().withProtocol("TCP").withPort(443).withNewTargetPort(443).endPort().withClusterIP("172.30.17.2").endSpec().build();
    Service multiport = new ServiceBuilder().withNewMetadata().withName("multiport").endMetadata().withNewSpec().addNewPort().withName("port1").withProtocol("TCP").withPort(8081).withNewTargetPort(8081).endPort().addNewPort().withName("port2").withProtocol("TCP").withPort(8082).withNewTargetPort(8082).endPort().addNewPort().withName("port3").withProtocol("TCP").withPort(8083).withNewTargetPort(8083).endPort().withClusterIP("172.30.17.2").endSpec().build();
    MOCK.expect().get().withPath("/api/v1/namespaces/default/services/service1").andReturn(200, service1).always();
    MOCK.expect().get().withPath("/api/v1/namespaces/default/services/service2").andReturn(200, service2).always();
    MOCK.expect().get().withPath("/api/v1/namespaces/default/services/service3").andReturn(200, service3).always();
    MOCK.expect().get().withPath("/api/v1/namespaces/default/services/multiport").andReturn(200, multiport).always();
    MOCK.expect().get().withPath("/api/v1/namespaces/default/services").andReturn(200, new ServiceListBuilder().withItems(service1, service2, service3, multiport).build()).always();
    MOCK.expect().get().withPath("/api/v1/namespaces/default/endpoints").andReturn(200, new EndpointsListBuilder().build()).always();
    MOCK.expect().get().withPath("/oapi/v1/namespaces/default/routes").andReturn(200, new RouteBuilder().build()).always();
    String masterUrl = MOCK.getServer().url("/").toString();
    System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, masterUrl);
}
Also used : ServiceListBuilder(io.fabric8.kubernetes.api.model.ServiceListBuilder) RouteBuilder(io.fabric8.openshift.api.model.RouteBuilder) Service(io.fabric8.kubernetes.api.model.Service) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) EndpointsListBuilder(io.fabric8.kubernetes.api.model.EndpointsListBuilder)

Aggregations

EndpointsListBuilder (io.fabric8.kubernetes.api.model.EndpointsListBuilder)2 Service (io.fabric8.kubernetes.api.model.Service)2 ServiceBuilder (io.fabric8.kubernetes.api.model.ServiceBuilder)2 ServiceListBuilder (io.fabric8.kubernetes.api.model.ServiceListBuilder)2 RouteBuilder (io.fabric8.openshift.api.model.RouteBuilder)2