Search in sources :

Example 1 with Template

use of io.kaoto.backend.model.deployment.kamelet.Template in project kaoto-backend by KaotoIO.

the class KamelPopulator method populateKamelet.

public void populateKamelet(final Kamelet kamelet, final Map<String, Object> metadata, final List<Step> steps) {
    kamelet.setSpec(new KameletSpec());
    kamelet.getSpec().setTemplate(new Template());
    kamelet.getSpec().getTemplate().setFrom(getFlow(steps));
    kamelet.setMetadata(new ObjectMeta());
    populateLabels(kamelet, (Map<String, String>) metadata.getOrDefault("labels", Collections.emptyMap()));
    populateAdditionalProperties(kamelet, (Map<String, String>) metadata.getOrDefault("additionalProperties", Collections.emptyMap()));
    populateAnnotations(kamelet, (Map<String, String>) metadata.getOrDefault("annotations", Collections.emptyMap()));
    // override in case this is outdated from the graphic side
    Type type = defineType(steps);
    kamelet.getMetadata().getLabels().put(group + "/kamelet.type", type.name());
    // consistent naming for kamelets
    String name = metadata.getOrDefault(NAME, "").toString();
    if (!name.endsWith(type.name())) {
        name = name + "-" + type.name();
    }
    kamelet.getMetadata().setName(name);
    // do we have an icon?
    if (kamelet.getMetadata().getAnnotations().getOrDefault(CAMEL_APACHE_ORG_KAMELET_ICON, "").isBlank()) {
        kamelet.getMetadata().getAnnotations().put(CAMEL_APACHE_ORG_KAMELET_ICON, metadata.getOrDefault("icon", "").toString());
    }
}
Also used : ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) KameletSpec(io.kaoto.backend.model.deployment.kamelet.KameletSpec) Template(io.kaoto.backend.model.deployment.kamelet.Template)

Aggregations

ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)1 KameletSpec (io.kaoto.backend.model.deployment.kamelet.KameletSpec)1 Template (io.kaoto.backend.model.deployment.kamelet.Template)1