Search in sources :

Example 1 with HTTPRouteDestination

use of me.snowdrop.istio.api.networking.v1alpha3.HTTPRouteDestination in project kubernetes by ballerinax.

the class IstioVirtualServiceHandler method populateRouteList.

/**
 * Parse an route list to a yaml map.
 *
 * @param serviceName The name of the service.
 * @param routeModels       The list of destination weights
 * @return A list of yaml maps.
 */
private List<HTTPRouteDestination> populateRouteList(String serviceName, List<IstioDestinationWeight> routeModels) {
    if (routeModels == null) {
        routeModels = new LinkedList<>();
    }
    if (routeModels.size() == 0) {
        routeModels.add(new IstioDestinationWeight());
    }
    List<HTTPRouteDestination> destinationWeightList = new LinkedList<>();
    for (IstioDestinationWeight destinationWeightModel : routeModels) {
        HTTPRouteDestination routeDestination = new HTTPRouteDestinationBuilder().withWeight(destinationWeightModel.getWeight()).withDestination(populateDestination(serviceName, destinationWeightModel.getDestination())).build();
        destinationWeightList.add(routeDestination);
    }
    return destinationWeightList;
}
Also used : HTTPRouteDestinationBuilder(me.snowdrop.istio.api.networking.v1alpha3.HTTPRouteDestinationBuilder) IstioDestinationWeight(org.ballerinax.kubernetes.models.istio.IstioDestinationWeight) HTTPRouteDestination(me.snowdrop.istio.api.networking.v1alpha3.HTTPRouteDestination) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 HTTPRouteDestination (me.snowdrop.istio.api.networking.v1alpha3.HTTPRouteDestination)1 HTTPRouteDestinationBuilder (me.snowdrop.istio.api.networking.v1alpha3.HTTPRouteDestinationBuilder)1 IstioDestinationWeight (org.ballerinax.kubernetes.models.istio.IstioDestinationWeight)1