io.fabric8.openshift.api.model.Route.setSpec()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中io.fabric8.openshift.api.model.Route.setSpec方法的一些代码示例,展示了Route.setSpec的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Route.setSpec方法的具体详情如下:
包路径:io.fabric8.openshift.api.model.Route
类名称:Route
方法名:setSpec

Route.setSpec介绍

暂无

代码示例

代码示例来源:origin: fabric8io/fabric8-maven-plugin

private Route createRouteForService(String routeDomainPostfix, String namespace, Service service) {
  Route route = null;
  String id = KubernetesHelper.getName(service);
  if (StringUtils.isNotBlank(id) && hasExactlyOneService(service, id)) {
    route = new Route();
    ObjectMeta routeMeta = KubernetesHelper.getOrCreateMetadata(route);
    routeMeta.setName(id);
    routeMeta.setNamespace(namespace);
    RouteSpec routeSpec = new RouteSpec();
    RouteTargetReference objectRef = new RouteTargetReferenceBuilder().withName(id).build();
    //objectRef.setNamespace(namespace);
    routeSpec.setTo(objectRef);
    if (StringUtils.isNotBlank(routeDomainPostfix)) {
      routeSpec.setHost(prepareHostForRoute(routeDomainPostfix, id));
    } else {
      routeSpec.setHost("");
    }
    route.setSpec(routeSpec);
    String json;
    try {
      json = ResourceUtil.toJson(route);
    } catch (JsonProcessingException e) {
      json = e.getMessage() + ". object: " + route;
    }
    log.debug("Created route: " + json);
  }
  return route;
}

代码示例来源:origin: io.fabric8/fabric8-arquillian

public static Route createRouteForService(String routeDomainPostfix, String namespace, Service service, Logger log) {
  Route route = null;
  String id = KubernetesHelper.getName(service);
  if (Strings.isNotBlank(id) && shouldCreateRouteForService(log, service, id)) {
    route = new Route();
    String routeId = id;
    KubernetesHelper.setName(route, namespace, routeId);
    RouteSpec routeSpec = new RouteSpec();
    RouteTargetReference objectRef = new RouteTargetReferenceBuilder().withName(id).build();
    //objectRef.setNamespace(namespace);
    routeSpec.setTo(objectRef);
    if (Strings.isNotBlank(routeDomainPostfix)) {
      // Let Openshift determine the route host when the domain is not set
      String host = Strings.stripSuffix(Strings.stripSuffix(id, "-service"), ".");
      String namespaceSuffix = "-" + namespace;
      routeSpec.setHost(host + namespaceSuffix + "." + Strings.stripPrefix(routeDomainPostfix, "."));
    }
    route.setSpec(routeSpec);
    String json = null;
    try {
      json = KubernetesHelper.toJson(route);
    } catch (JsonProcessingException e) {
      json = e.getMessage() + ". object: " + route;
    }
  }
  return route;
}

相关文章