Search in sources :

Example 56 with ImageName

use of io.fabric8.maven.docker.util.ImageName in project fabric8 by jboss-fuse.

the class SessionListener method hasRegistry.

/**
 * Checks to see if there's a registry name already provided in the image name
 *
 * Code influenced from <a href="https://github.com/rhuss/docker-maven-plugin/blob/master/src/main/java/org/jolokia/docker/maven/util/ImageName.java">docker-maven-plugin</a>
 * @param imageName
 * @return true if the image name contains a registry
 */
public static boolean hasRegistry(String imageName) {
    if (imageName == null) {
        throw new NullPointerException("Image name must not be null");
    }
    Pattern tagPattern = Pattern.compile("^(.+?)(?::([^:/]+))?$");
    Matcher matcher = tagPattern.matcher(imageName);
    if (!matcher.matches()) {
        throw new IllegalArgumentException(imageName + " is not a proper image name ([registry/][repo][:port]");
    }
    String rest = matcher.group(1);
    String[] parts = rest.split("\\s*/\\s*");
    String part = parts[0];
    return part.contains(".") || part.contains(":");
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Util.readAsString(io.fabric8.arquillian.utils.Util.readAsString)

Example 57 with ImageName

use of io.fabric8.maven.docker.util.ImageName in project kubernetes by ballerinax.

the class KubernetesDeploymentGeneratorTests method testGeneratedYAML.

private void testGeneratedYAML(File yamlFile) throws IOException {
    Deployment deployment = Utils.loadYaml(yamlFile);
    Assert.assertEquals(deploymentName, deployment.getMetadata().getName());
    Assert.assertEquals(selector, deployment.getMetadata().getLabels().get(KubernetesConstants.KUBERNETES_SELECTOR_KEY));
    Assert.assertEquals(replicas, deployment.getSpec().getReplicas().intValue());
    Assert.assertEquals(1, deployment.getSpec().getTemplate().getSpec().getContainers().size());
    Container container = deployment.getSpec().getTemplate().getSpec().getContainers().get(0);
    Assert.assertEquals(imageName, container.getImage());
    Assert.assertEquals(imagePullPolicy, container.getImagePullPolicy());
    Assert.assertEquals(3, container.getPorts().size());
    Assert.assertEquals(5, container.getLivenessProbe().getPeriodSeconds().intValue());
    Assert.assertEquals(10, container.getLivenessProbe().getInitialDelaySeconds().intValue());
    Assert.assertEquals(1, container.getEnv().size());
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment)

Aggregations

ImageName (io.fabric8.maven.docker.util.ImageName)20 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)11 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)10 File (java.io.File)9 IOException (java.io.IOException)7 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)7 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)6 Container (io.fabric8.kubernetes.api.model.Container)5 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)4 CopyConfiguration (io.fabric8.maven.docker.config.CopyConfiguration)4 Container (io.fabric8.maven.docker.model.Container)4 Test (org.junit.Test)4 DockerClient (io.fabric8.docker.client.DockerClient)3 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)3 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)3 RunImageConfiguration (io.fabric8.maven.docker.config.RunImageConfiguration)3 ArrayList (java.util.ArrayList)3 Matcher (java.util.regex.Matcher)3 Util.readAsString (io.fabric8.arquillian.utils.Util.readAsString)2 Controller (io.fabric8.kubernetes.api.Controller)2