Search in sources :

Example 6 with GroupArtifactVersion

use of org.eclipse.jkube.kit.config.resource.GroupArtifactVersion in project jkube by eclipse.

the class ContainerHandlerTest method getContainerWithGroupArtifactTest.

@Test
public void getContainerWithGroupArtifactTest() {
    project.setArtifactId("test-artifact");
    project.setGroupId("test-group");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    ContainerHandler handler = new ContainerHandler(project.getProperties(), new GroupArtifactVersion("test-group", "test-artifact", "0"), probeHandler);
    // container name with group id and aritact id without alias and user
    final BuildConfiguration buildImageConfiguration = BuildConfiguration.builder().ports(ports).from("fabric8/").cleanup("try").tags(tags).compressionString("gzip").dockerFile("testFile").build();
    ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("test").build(buildImageConfiguration).registry("docker.io").build();
    images.clear();
    images.add(imageConfiguration);
    containers = handler.getContainers(config, images);
    assertNotNull(containers);
    assertEquals("test-group-test-artifact", containers.get(0).getName());
    assertEquals("docker.io/test:latest", containers.get(0).getImage());
    assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) GroupArtifactVersion(org.eclipse.jkube.kit.config.resource.GroupArtifactVersion) Test(org.junit.Test)

Example 7 with GroupArtifactVersion

use of org.eclipse.jkube.kit.config.resource.GroupArtifactVersion in project jkube by eclipse.

the class ProjectLabelEnricherTest method setupExpectations.

@Before
public void setupExpectations() {
    projectLabelEnricher = new ProjectLabelEnricher(context);
    properties = new Properties();
    // @formatter:off
    new Expectations() {

        {
            context.getProperties();
            result = properties;
            context.getGav();
            result = new GroupArtifactVersion("groupId", "artifactId", "version");
        }
    };
// @formatter:on
}
Also used : Expectations(mockit.Expectations) GroupArtifactVersion(org.eclipse.jkube.kit.config.resource.GroupArtifactVersion) Properties(java.util.Properties) Before(org.junit.Before)

Example 8 with GroupArtifactVersion

use of org.eclipse.jkube.kit.config.resource.GroupArtifactVersion in project jkube by eclipse.

the class ContainerHandlerTest method imagePullPolicyWithoutPolicySetTest.

@Test
public void imagePullPolicyWithoutPolicySetTest() {
    // project with version and ending in SNAPSHOT
    project1.setVersion("3.5-SNAPSHOT");
    // project with version but not ending in SNAPSHOT
    project2.setVersion("3.5-NEW");
    // creating container Handler for two
    ContainerHandler handler1 = new ContainerHandler(project1.getProperties(), new GroupArtifactVersion("g", "a", "3.5-SNAPSHOT"), probeHandler);
    ContainerHandler handler2 = new ContainerHandler(project2.getProperties(), new GroupArtifactVersion("g", "a", "3.5-NEW"), probeHandler);
    // project without version
    ContainerHandler handler3 = createContainerHandler(project);
    images.clear();
    images.add(imageConfiguration1);
    // check if policy is not set then both in case of version is set or not
    ResourceConfig config2 = ResourceConfig.builder().imagePullPolicy("").build();
    containers = handler1.getContainers(config2, images);
    assertEquals("PullAlways", containers.get(0).getImagePullPolicy());
    containers = handler2.getContainers(config2, images);
    assertEquals("", containers.get(0).getImagePullPolicy());
    containers = handler3.getContainers(config2, images);
    assertEquals("", containers.get(0).getImagePullPolicy());
}
Also used : GroupArtifactVersion(org.eclipse.jkube.kit.config.resource.GroupArtifactVersion) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) Test(org.junit.Test)

Example 9 with GroupArtifactVersion

use of org.eclipse.jkube.kit.config.resource.GroupArtifactVersion in project jkube by eclipse.

the class ContainerHandlerTest method getContainersWithAliasTest.

@Test
public void getContainersWithAliasTest() {
    project.setArtifactId("test-artifact");
    project.setGroupId("test-group");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    ContainerHandler handler = new ContainerHandler(project.getProperties(), new GroupArtifactVersion("test-group", "test-artifact", "0"), probeHandler);
    // container name with alias
    final BuildConfiguration buildImageConfiguration = BuildConfiguration.builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compressionString("gzip").build();
    ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("docker.io/test/test-app:1.2").alias("test-app").build(buildImageConfiguration).registry("docker-alternate.io").build();
    images.clear();
    images.add(imageConfiguration);
    containers = handler.getContainers(config, images);
    assertNotNull(containers);
    assertEquals("test-app", containers.get(0).getName());
    assertEquals("docker.io/test/test-app:1.2", containers.get(0).getImage());
    assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) GroupArtifactVersion(org.eclipse.jkube.kit.config.resource.GroupArtifactVersion) Test(org.junit.Test)

Example 10 with GroupArtifactVersion

use of org.eclipse.jkube.kit.config.resource.GroupArtifactVersion in project jkube by eclipse.

the class ContainerHandlerTest method getContainerTestWithUser.

@Test
public void getContainerTestWithUser() {
    project.setArtifactId("test-artifact");
    project.setGroupId("test-group");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    // container name with user and image with tag
    ContainerHandler handler = new ContainerHandler(project.getProperties(), new GroupArtifactVersion("test-group", "test-artifact", "0"), probeHandler);
    final BuildConfiguration buildImageConfiguration = BuildConfiguration.builder().ports(ports).from("fabric8/").cleanup("try").tags(tags).compressionString("gzip").dockerFile("testFile").build();
    ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("user/test:latest").build(buildImageConfiguration).registry("docker.io").build();
    images.clear();
    images.add(imageConfiguration);
    containers = handler.getContainers(config, images);
    assertNotNull(containers);
    assertEquals("user-test-artifact", containers.get(0).getName());
    assertEquals("docker.io/user/test:latest", containers.get(0).getImage());
    assertEquals("IfNotPresent", containers.get(0).getImagePullPolicy());
}
Also used : BuildConfiguration(org.eclipse.jkube.kit.config.image.build.BuildConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) GroupArtifactVersion(org.eclipse.jkube.kit.config.resource.GroupArtifactVersion) Test(org.junit.Test)

Aggregations

GroupArtifactVersion (org.eclipse.jkube.kit.config.resource.GroupArtifactVersion)16 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)11 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)9 Before (org.junit.Before)8 Test (org.junit.Test)7 VolumeConfig (org.eclipse.jkube.kit.config.resource.VolumeConfig)6 Expectations (mockit.Expectations)2 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 ResourceConfig (org.eclipse.jkube.kit.config.resource.ResourceConfig)1