use of me.snowdrop.istio.api.DurationBuilder in project kubernetes by ballerinax.
the class IstioVirtualServiceHandler method populateHttp.
/**
* Parsing a list of http routes to yaml maps.
*
* @param serviceName The name of the service where to route to.
* @param httpRouteModels The list of http routes.
* @return A list of yaml maps.
*/
private List<HTTPRoute> populateHttp(String serviceName, List<IstioHttpRoute> httpRouteModels) {
if (null == httpRouteModels) {
httpRouteModels = new LinkedList<>();
}
if (httpRouteModels.size() == 0) {
httpRouteModels.add(new IstioHttpRoute());
}
List<HTTPRoute> httpRoutes = new LinkedList<>();
for (IstioHttpRoute httpRouteModel : httpRouteModels) {
Duration timoutDuration = null;
if (-1 != httpRouteModel.getTimeout()) {
timoutDuration = new DurationBuilder().withSeconds(httpRouteModel.getTimeout()).build();
}
HTTPRoute httpRoute = new HTTPRouteBuilder().withRoute(populateRouteList(serviceName, httpRouteModel.getRoute())).withTimeout(timoutDuration).withAppendHeaders(httpRouteModel.getAppendHeaders()).build();
httpRoutes.add(httpRoute);
}
return httpRoutes;
}
Aggregations