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;
}
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);
}
}
Aggregations