本文整理了Java中io.fabric8.openshift.api.model.Route.setSpec
方法的一些代码示例,展示了Route.setSpec
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Route.setSpec
方法的具体详情如下:
包路径:io.fabric8.openshift.api.model.Route
类名称: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;
}
内容来源于网络,如有侵权,请联系作者删除!