All Downloads are FREE. Search and download functionalities are using the official Maven repository.

stio-model.1.1.0-Alpha1.source-code.istio-mappings-provider.vm Maven / Gradle / Ivy

package me.snowdrop.istio.api.model;

import io.fabric8.kubernetes.api.KubernetesResourceMappingProvider;
import io.fabric8.kubernetes.api.model.KubernetesResource;
import java.util.HashMap;
import java.util.Map;

#foreach ($key in ${model.keySet()})
#set ($spec = $key)
#set ($length = $spec.length())
#set ($tindex = $length - 4)
#set ($resource = $spec.substring(0, $tindex))
import $resource;
#end

public class IstioResourceMappingsProvider implements KubernetesResourceMappingProvider {

    public final Map> mappings = new HashMap<>();

    public IstioResourceMappingsProvider () {

#foreach ($key in ${model.keySet()})
#set ($spec = $key)
#set ($length = $spec.length())
#set ($tindex = $length - 4)
#set ($resource = $spec.substring(0, $tindex))
#set ($dindex = $resource.lastIndexOf(".")+1)
#set ($c = $resource.substring($dindex))
#set ($version = "unknown")
#set ($kind = "unknown")
#set ($annotations = $model.get($key).annotations)
#foreach ($annotation in $annotations)
#if ($annotation.getClassRef().getName().equals("IstioApiVersion"))
#set ($version = $annotation.getParameters().get("value"))
#end
#if ($annotation.getClassRef().getName().equals("IstioKind"))
#set ($kind = $annotation.getParameters().get("name"))
#end
#end
        mappings.put("$version#$kind", ${c}.class);
#end
    }

    public Map> getMappings() {
        return mappings;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy