Search in sources :

Example 1 with DockerImage

use of org.opentosca.toscana.plugins.kubernetes.docker.mapper.model.DockerImage in project TOSCAna by StuPro-TOSCAna.

the class BaseImageMapper method addImagesForType.

/**
 *     Internal method used for converting the Data received from docker to the data model described
 *     in the <code>model</code> package
 */
private void addImagesForType(DockerBaseImages baseImage, List<ImageTags> pages) {
    List<DockerImageTag> tagList = new ArrayList<>();
    for (ImageTags page : pages) {
        for (ImageTag imageTag : page.getImageTags()) {
            Set<String> architectures = new HashSet<>();
            for (Image image : imageTag.getImages()) {
                // is amd64 in that case.
                if (image.getArchitecture() == null) {
                    architectures.add("amd64");
                } else {
                    architectures.add(image.getArchitecture());
                }
            }
            DockerImageTag tag = new DockerImageTag(imageTag.getName(), architectures);
            tagList.add(tag);
        }
    }
    tagStorage.put(baseImage.name().toLowerCase(), new DockerImage(baseImage, tagList));
}
Also used : ImageTag(org.opentosca.toscana.plugins.kubernetes.docker.mapper.api.model.ImageTag) DockerImageTag(org.opentosca.toscana.plugins.kubernetes.docker.mapper.model.DockerImageTag) ArrayList(java.util.ArrayList) DockerImage(org.opentosca.toscana.plugins.kubernetes.docker.mapper.model.DockerImage) DockerImageTag(org.opentosca.toscana.plugins.kubernetes.docker.mapper.model.DockerImageTag) DockerImage(org.opentosca.toscana.plugins.kubernetes.docker.mapper.model.DockerImage) Image(org.opentosca.toscana.plugins.kubernetes.docker.mapper.api.model.Image) ImageTags(org.opentosca.toscana.plugins.kubernetes.docker.mapper.api.model.ImageTags) HashSet(java.util.HashSet)

Example 2 with DockerImage

use of org.opentosca.toscana.plugins.kubernetes.docker.mapper.model.DockerImage in project TOSCAna by StuPro-TOSCAna.

the class MapperEngine method performMapping.

/**
 *     Perfoms the mapping to the base image
 */
private String performMapping(OsCapability capability, String tag, String distro) {
    DockerImage img = tagStorage.get(distro);
    String architecture = getCapabilityArchitecture(capability).orElseThrow(() -> new UnsupportedOperationException("Architecture not supported!"));
    DockerImageTag imgTag = img.findTagByName(tag).get();
    if (imgTag.isSupported(architecture)) {
        return img.getUsername() + "/" + img.getRepository() + ":" + imgTag.getName();
    } else {
        throw new UnsupportedOperationException("Could not map to base image. " + "The image '" + img.getUsername() + "/" + img.getRepository() + ":" + tag + "' " + "does not support the architecture " + architecture);
    }
}
Also used : DockerImage(org.opentosca.toscana.plugins.kubernetes.docker.mapper.model.DockerImage) DockerImageTag(org.opentosca.toscana.plugins.kubernetes.docker.mapper.model.DockerImageTag)

Example 3 with DockerImage

use of org.opentosca.toscana.plugins.kubernetes.docker.mapper.model.DockerImage in project TOSCAna by StuPro-TOSCAna.

the class MapperEngine method hasKnownDistributionName.

private boolean hasKnownDistributionName(OsCapability capability) {
    if (capability.getDistribution().isPresent()) {
        String distroName = convertDistributionName(capability);
        DockerImage image = tagStorage.get(distroName);
        return image != null;
    }
    return false;
}
Also used : DockerImage(org.opentosca.toscana.plugins.kubernetes.docker.mapper.model.DockerImage)

Aggregations

DockerImage (org.opentosca.toscana.plugins.kubernetes.docker.mapper.model.DockerImage)3 DockerImageTag (org.opentosca.toscana.plugins.kubernetes.docker.mapper.model.DockerImageTag)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Image (org.opentosca.toscana.plugins.kubernetes.docker.mapper.api.model.Image)1 ImageTag (org.opentosca.toscana.plugins.kubernetes.docker.mapper.api.model.ImageTag)1 ImageTags (org.opentosca.toscana.plugins.kubernetes.docker.mapper.api.model.ImageTags)1