Search in sources :

Example 1 with RoutePort

use of io.fabric8.openshift.api.model.RoutePort in project fabric8-maven-plugin by fabric8io.

the class OpenShiftRouteEnricher method createRoutePort.

private RoutePort createRoutePort(ServiceBuilder serviceBuilder) {
    RoutePort routePort = null;
    ServiceSpec spec = serviceBuilder.getSpec();
    if (spec != null) {
        List<ServicePort> ports = spec.getPorts();
        if (ports != null && ports.size() > 0) {
            ServicePort servicePort = ports.get(0);
            if (servicePort != null) {
                IntOrString targetPort = servicePort.getTargetPort();
                if (targetPort != null) {
                    routePort = new RoutePort();
                    routePort.setTargetPort(targetPort);
                }
            }
        }
    }
    return routePort;
}
Also used : ServicePort(io.fabric8.kubernetes.api.model.ServicePort) RoutePort(io.fabric8.openshift.api.model.RoutePort) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) ServiceSpec(io.fabric8.kubernetes.api.model.ServiceSpec)

Example 2 with RoutePort

use of io.fabric8.openshift.api.model.RoutePort in project kie-wb-common by kiegroup.

the class OpenShiftClient method getRuntimeEndpoint.

public OpenShiftRuntimeEndpoint getRuntimeEndpoint(String id) throws OpenShiftClientException {
    try {
        OpenShiftRuntimeId runtimeId = OpenShiftRuntimeId.fromString(id);
        String prjName = runtimeId.project();
        String svcName = runtimeId.service();
        OpenShiftRuntimeEndpoint endpoint = new OpenShiftRuntimeEndpoint();
        Route route = delegate.routes().inNamespace(prjName).withName(svcName).get();
        if (route != null) {
            RouteSpec routeSpec = route.getSpec();
            endpoint.setProtocol(routeSpec.getTls() != null ? "https" : "http");
            endpoint.setHost(routeSpec.getHost());
            RoutePort routePort = routeSpec.getPort();
            if (routePort != null) {
                IntOrString targetPort = routePort.getTargetPort();
                if (targetPort != null) {
                    endpoint.setPort(targetPort.getIntVal());
                }
            }
        }
        return endpoint;
    } catch (Throwable t) {
        throw new OpenShiftClientException(t.getMessage(), t);
    }
}
Also used : RoutePort(io.fabric8.openshift.api.model.RoutePort) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) OpenShiftClientException(org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) RouteSpec(io.fabric8.openshift.api.model.RouteSpec) OpenShiftRuntimeEndpoint(org.guvnor.ala.openshift.model.OpenShiftRuntimeEndpoint) Route(io.fabric8.openshift.api.model.Route)

Aggregations

IntOrString (io.fabric8.kubernetes.api.model.IntOrString)2 RoutePort (io.fabric8.openshift.api.model.RoutePort)2 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)1 ServiceSpec (io.fabric8.kubernetes.api.model.ServiceSpec)1 Route (io.fabric8.openshift.api.model.Route)1 RouteSpec (io.fabric8.openshift.api.model.RouteSpec)1 OpenShiftClientException (org.guvnor.ala.openshift.access.exceptions.OpenShiftClientException)1 OpenShiftRuntimeEndpoint (org.guvnor.ala.openshift.model.OpenShiftRuntimeEndpoint)1