Search in sources :

Example 21 with ImageName

use of org.eclipse.jkube.kit.config.image.ImageName in project jkube by eclipse.

the class BaseGenerator method addFrom.

/**
 * Add the base image either from configuration or from a given selector
 *
 * @param builder for the build image configuration to add the from to.
 */
protected void addFrom(BuildConfiguration.BuildConfigurationBuilder builder) {
    String fromMode = getConfigWithFallback(Config.FROM_MODE, "jkube.generator.fromMode", "docker");
    String from = getFromAsConfigured();
    if ("docker".equalsIgnoreCase(fromMode)) {
        String fromImage = from;
        if (fromImage == null) {
            fromImage = fromSelector != null ? fromSelector.getFrom() : null;
        }
        builder.from(fromImage);
        log.info("Using Docker image %s as base / builder", fromImage);
    } else if ("istag".equalsIgnoreCase(fromMode)) {
        Map<String, String> fromExt = new HashMap<>();
        if (from != null) {
            ImageName iName = new ImageName(from);
            // user/project is considered to be the namespace
            String tag = iName.getTag();
            if (StringUtils.isBlank(tag)) {
                tag = "latest";
            }
            fromExt.put(JKubeBuildStrategy.SourceStrategy.name.key(), iName.getSimpleName() + ":" + tag);
            if (iName.getUser() != null) {
                fromExt.put(JKubeBuildStrategy.SourceStrategy.namespace.key(), iName.getUser());
            }
            fromExt.put(JKubeBuildStrategy.SourceStrategy.kind.key(), "ImageStreamTag");
        } else {
            fromExt = fromSelector != null ? fromSelector.getImageStreamTagFromExt() : null;
        }
        if (fromExt != null) {
            String namespace = fromExt.get(JKubeBuildStrategy.SourceStrategy.namespace.key());
            if (namespace != null) {
                log.info("Using ImageStreamTag '%s' from namespace '%s' as builder image", fromExt.get(JKubeBuildStrategy.SourceStrategy.name.key()), namespace);
            } else {
                log.info("Using ImageStreamTag '%s' as builder image", fromExt.get(JKubeBuildStrategy.SourceStrategy.name.key()));
            }
            builder.fromExt(fromExt);
        }
    } else {
        throw new IllegalArgumentException(String.format("Invalid 'fromMode' in generator configuration for '%s'", getName()));
    }
}
Also used : ImageName(org.eclipse.jkube.kit.config.image.ImageName) HashMap(java.util.HashMap) Map(java.util.Map)

Example 22 with ImageName

use of org.eclipse.jkube.kit.config.image.ImageName in project jkube by eclipse.

the class JibServiceUtil method getAllImageTags.

static Set<String> getAllImageTags(List<String> tags, String imageName) {
    ImageName tempImage = new ImageName(imageName);
    Set<String> tagSet = tags.stream().filter(Objects::nonNull).collect(Collectors.toSet());
    if (!tempImage.getTag().isEmpty()) {
        tagSet.add(tempImage.getTag());
    }
    return tagSet;
}
Also used : ImageName(org.eclipse.jkube.kit.config.image.ImageName)

Aggregations

ImageName (org.eclipse.jkube.kit.config.image.ImageName)22 BuildServiceConfig (org.eclipse.jkube.kit.config.service.BuildServiceConfig)6 Test (org.junit.Test)6 IOException (java.io.IOException)5 BuildOutput (io.fabric8.openshift.api.model.BuildOutput)4 OpenShiftBuildServiceUtils.createBuildOutput (org.eclipse.jkube.kit.config.service.openshift.OpenShiftBuildServiceUtils.createBuildOutput)4 AuthConfig (org.eclipse.jkube.kit.build.api.auth.AuthConfig)3 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)2 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)2 WatcherException (io.fabric8.kubernetes.client.WatcherException)2 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)2 BuildConfigSpec (io.fabric8.openshift.api.model.BuildConfigSpec)2 BuildStrategy (io.fabric8.openshift.api.model.BuildStrategy)2 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)2 File (java.io.File)2 Map (java.util.Map)2 DockerAccessException (org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException)2 AuthConfigFactory (org.eclipse.jkube.kit.build.service.docker.auth.AuthConfigFactory)2 OpenShiftBuildServiceUtils.createBuildStrategy (org.eclipse.jkube.kit.config.service.openshift.OpenShiftBuildServiceUtils.createBuildStrategy)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1