io.fabric8.openshift.api.model.RouteList Java Examples

The following examples show how to use io.fabric8.openshift.api.model.RouteList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Fabric8OpenShiftServiceImpl.java    From launchpad-missioncontrol with Apache License 2.0 5 votes vote down vote up
private void applyParameterValueProperties(final OpenShiftProject project, final Template template) {
    RouteList routes = null;
    for (Parameter parameter : template.getParameters()) {
        // Find any parameters with special "fabric8-value" properties
        if (parameter.getAdditionalProperties().containsKey("fabric8-value")
                && parameter.getValue() == null) {
            String value = parameter.getAdditionalProperties().get("fabric8-value").toString();
            Matcher m = PARAM_VAR_PATTERN.matcher(value);
            StringBuffer newval = new StringBuffer();
            while (m.find()) {
                String type = m.group(1);
                String routeName = m.group(2);
                String propertyPath = m.group(3);
                String propertyValue = "";
                // We only support "route/XXX[.spec.host]" for now,
                // but we're prepared for future expansion
                if ("route".equals(type) && ".spec.host".equals(propertyPath)) {
                    // Try to find a Route with that name and use its host name
                    if (routes == null) {
                        routes = client.routes().inNamespace(project.getName()).list();
                    }
                    propertyValue = routes.getItems().stream()
                        .filter(r -> routeName.equals(r.getMetadata().getName()))
                        .map(r -> r.getSpec().getHost())
                        .filter(Objects::nonNull)
                        .findAny()
                        .orElse(propertyValue);
                }
                m.appendReplacement(newval, Matcher.quoteReplacement(propertyValue));
            }
            m.appendTail(newval);
            parameter.setValue(newval.toString());
        }
    }
}
 
Example #2
Source File: RouteCrudTest.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@Test
public void testCrud() {
  OpenShiftClient client = server.getOpenshiftClient();

  Route route1 = new RouteBuilder().withNewMetadata().withName("route1")
    .addToLabels("foo", "bar")
    .and().build();
  Route route2 = new RouteBuilder().withNewMetadata().withName("route2")
    .addToLabels("foo", "bar")
    .and().build();
  Route route3 = new RouteBuilder().withNewMetadata().withName("route3")
    .addToLabels("foo", "bar")
    .and().build();

  client.routes().inNamespace("ns1").create(route1);
  client.routes().inNamespace("ns1").create(route2);
  client.routes().inNamespace("ns2").create(route3);

  RouteList aRouteList = client.routes().list();
  assertNotNull(aRouteList);
  assertEquals(0, aRouteList.getItems().size());

  aRouteList = client.routes().inAnyNamespace().list();
  assertNotNull(aRouteList);
  assertEquals(3, aRouteList.getItems().size());

  aRouteList = client.routes().inNamespace("ns1").list();
  assertNotNull(aRouteList);
  assertEquals(2, aRouteList.getItems().size());

  aRouteList = client.routes().inAnyNamespace().withLabels(Collections.singletonMap("foo", "bar")).list();
  assertNotNull(aRouteList);
  assertEquals(3, aRouteList.getItems().size());

  boolean bDeleted = client.routes().inNamespace("ns1").delete();
  aRouteList = client.routes().inNamespace("ns1").list();
  assertTrue(bDeleted);
  assertEquals(0, aRouteList.getItems().size());
}
 
Example #3
Source File: RouteOperator.java    From strimzi-kafka-operator with Apache License 2.0 4 votes vote down vote up
@Override
protected MixedOperation<Route, RouteList, DoneableRoute, Resource<Route, DoneableRoute>> operation() {
    return client.routes();
}
 
Example #4
Source File: RouteOperatorTest.java    From strimzi-kafka-operator with Apache License 2.0 4 votes vote down vote up
@Override
protected AbstractResourceOperator<OpenShiftClient, Route, RouteList, DoneableRoute, Resource<Route, DoneableRoute>> createResourceOperations(Vertx vertx, OpenShiftClient mockClient) {
    return new RouteOperator(vertx, mockClient);
}
 
Example #5
Source File: RouteIT.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Test
public void list() {
  RouteList aRouteList = client.routes().inNamespace(currentNamespace).list();
  assertThat(aRouteList).isNotNull();
  assertEquals(2, aRouteList.getItems().size());
}
 
Example #6
Source File: DefaultOpenShiftClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public MixedOperation<Route, RouteList, DoneableRoute, Resource<Route, DoneableRoute>> routes() {
  return new RouteOperationsImpl(httpClient, OpenShiftConfig.wrap(getConfiguration()));
}