Search in sources :

Example 1 with DurationBuilder

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;
}
Also used : HTTPRoute(me.snowdrop.istio.api.networking.v1alpha3.HTTPRoute) Duration(me.snowdrop.istio.api.Duration) IstioHttpRoute(org.ballerinax.kubernetes.models.istio.IstioHttpRoute) LinkedList(java.util.LinkedList) HTTPRouteBuilder(me.snowdrop.istio.api.networking.v1alpha3.HTTPRouteBuilder) DurationBuilder(me.snowdrop.istio.api.DurationBuilder)

Aggregations

LinkedList (java.util.LinkedList)1 Duration (me.snowdrop.istio.api.Duration)1 DurationBuilder (me.snowdrop.istio.api.DurationBuilder)1 HTTPRoute (me.snowdrop.istio.api.networking.v1alpha3.HTTPRoute)1 HTTPRouteBuilder (me.snowdrop.istio.api.networking.v1alpha3.HTTPRouteBuilder)1 IstioHttpRoute (org.ballerinax.kubernetes.models.istio.IstioHttpRoute)1