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

io.quarkus.test.utils.ImageUtil Maven / Gradle / Ivy

There is a newer version: 1.6.0.Beta15
Show newest version
package io.quarkus.test.utils;

import java.util.HashMap;
import java.util.Map;

public final class ImageUtil {

    private static final String COLON = ":";
    private static final Map PROPERTY_TO_IMAGE = new HashMap<>();

    private ImageUtil() {
        // util class
    }

    public static String getImageVersion(String imageProperty) {
        return getImage(imageProperty)[1];
    }

    public static String getImageName(String imageProperty) {
        return getImage(imageProperty)[0];
    }

    private static String[] getImage(String imageProperty) {
        return PROPERTY_TO_IMAGE.computeIfAbsent(imageProperty, ip -> {
            final String image = System.getProperty(imageProperty);
            if (image == null) {
                throw new IllegalStateException(String.format("System property '%s' is missing.", imageProperty));
            }
            if (!image.contains(COLON)) {
                throw new IllegalStateException(String.format("'%s' is not valid Docker image", image));
            }
            return image.split(COLON);
        });
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy