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(":");
}
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());
}
Aggregations