Search in sources :

Example 1 with KubernetesHelper.toItemList

use of io.fabric8.kubernetes.api.KubernetesHelper.toItemList in project fabric8-maven-plugin by fabric8io.

the class KubernetesResourceUtil method loadResources.

public static Set<HasMetadata> loadResources(File manifest) throws IOException {
    Object dto = KubernetesHelper.loadYaml(manifest, KubernetesResource.class);
    if (dto == null) {
        throw new IllegalStateException("Cannot load kubernetes YAML: " + manifest);
    }
    if (dto instanceof Template) {
        Template template = (Template) dto;
        boolean failOnMissingParameterValue = false;
        dto = Templates.processTemplatesLocally(template, failOnMissingParameterValue);
    }
    Set<KubernetesResource<?>> resources = new LinkedHashSet<>();
    Set<HasMetadata> entities = new TreeSet<>(new HasMetadataComparator());
    for (KubernetesResource<?> resource : resources) {
        entities.addAll(KubernetesHelper.toItemList(resource));
    }
    entities.addAll(KubernetesHelper.toItemList(dto));
    return entities;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) HasMetadataComparator(io.fabric8.kubernetes.internal.HasMetadataComparator) TreeSet(java.util.TreeSet) KubernetesResource(io.fabric8.kubernetes.api.model.KubernetesResource) Template(io.fabric8.openshift.api.model.Template)

Aggregations

HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)1 KubernetesResource (io.fabric8.kubernetes.api.model.KubernetesResource)1 HasMetadataComparator (io.fabric8.kubernetes.internal.HasMetadataComparator)1 Template (io.fabric8.openshift.api.model.Template)1 LinkedHashSet (java.util.LinkedHashSet)1 TreeSet (java.util.TreeSet)1