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

com.swisscom.cloud.sb.broker.services.kubernetes.templates.KubernetesTemplateManager.groovy Maven / Gradle / Ivy

package com.swisscom.cloud.sb.broker.services.kubernetes.templates

import com.swisscom.cloud.sb.broker.services.kubernetes.config.AbstractKubernetesServiceConfig
import com.swisscom.cloud.sb.broker.services.kubernetes.config.TemplateConfig
import groovy.transform.CompileStatic
import groovy.util.logging.Log4j
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Log4j
@Component
@CompileStatic
class KubernetesTemplateManager {
    private final TemplateConfig templateConfig

    @Autowired
    KubernetesTemplateManager(TemplateConfig templateConfig) {
        this.templateConfig = templateConfig
    }

    List getTemplates(String templateUniqueIdentifier) {
        return splitTemplatesFromYamlDoucments(templateConfig.getTemplateForServiceKey(templateUniqueIdentifier))
    }

    List getTemplates(String templateUniqueIdentifier, String templateVersion) {
        return splitTemplatesFromYamlDoucments(templateConfig.getTemplateForServiceKey(templateUniqueIdentifier, templateVersion))
    }

    private List splitTemplatesFromYamlDoucments(List templates) {
        def deploymentTemplates = templates.collect{it.split("---")}.flatten()
        return deploymentTemplates.collect{new KubernetesTemplate(it as String)}
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy