Search in sources :

Example 11 with Container

use of io.fabric8.maven.docker.model.Container in project docker-maven-plugin by fabric8io.

the class VolumeBindingUtilTest method testResolveUserHomeVolumePath.

/**
 * Resolving arbitrary user home paths, e.g. represented as {@code ~user}, is not supported.
 */
@Test(expected = IllegalArgumentException.class)
public void testResolveUserHomeVolumePath() {
    String volumeString = format(BIND_STRING_FMT, USER_HOME, CONTAINER_PATH);
    // '~user:/path/to/container/dir' to '/home/user:/path/to/container/dir'
    String relativizedVolumeString = resolveRelativeVolumeBinding(new File("ignored"), volumeString);
}
Also used : PathTestUtil.createTmpFile(io.fabric8.maven.docker.util.PathTestUtil.createTmpFile) File(java.io.File) Test(org.junit.Test)

Example 12 with Container

use of io.fabric8.maven.docker.model.Container in project docker-maven-plugin by fabric8io.

the class VolumeBindingUtilTest method testResolveUserVolumePath.

/**
 * Insures that a host volume binding string that contains a path relative to the user's home directory resolves to
 * the user's home directory and not the supplied base directory.
 */
@Test
public void testResolveUserVolumePath() {
    String volumeString = format(BIND_STRING_FMT, USER_PATH, CONTAINER_PATH);
    // '~/rel:/path/to/container/dir' to '/user/home/rel:/path/to/container/dir'
    String relativizedVolumeString = resolveRelativeVolumeBinding(new File("ignored"), volumeString);
    String expectedBindingString = format(BIND_STRING_FMT, new File(System.getProperty("user.home"), PathTestUtil.stripLeadingTilde(USER_PATH)), CONTAINER_PATH);
    assertEquals(expectedBindingString, relativizedVolumeString);
}
Also used : PathTestUtil.createTmpFile(io.fabric8.maven.docker.util.PathTestUtil.createTmpFile) File(java.io.File) Test(org.junit.Test)

Example 13 with Container

use of io.fabric8.maven.docker.model.Container in project docker-maven-plugin by fabric8io.

the class VolumeBindingUtilTest method testResolveParentRelativeVolumePath.

/**
 * Insures that a relative path referencing the parent directory are properly resolved against a base directory.
 */
@Test
public void testResolveParentRelativeVolumePath() {
    // '../rel'
    String relativePath = DOT + RELATIVE_PATH;
    String volumeString = format(BIND_STRING_FMT, relativePath, CONTAINER_PATH);
    // '../rel:/path/to/container/dir to '/absolute/rel:/path/to/container/dir'
    String relativizedVolumeString = resolveRelativeVolumeBinding(ABS_BASEDIR, volumeString);
    String expectedBindingString = format(BIND_STRING_FMT, new File(ABS_BASEDIR.getParent(), stripLeadingPeriod(RELATIVE_PATH)), CONTAINER_PATH);
    assertEquals(expectedBindingString, relativizedVolumeString);
}
Also used : PathTestUtil.createTmpFile(io.fabric8.maven.docker.util.PathTestUtil.createTmpFile) File(java.io.File) Test(org.junit.Test)

Example 14 with Container

use of io.fabric8.maven.docker.model.Container in project docker-maven-plugin by fabric8io.

the class VolumeBindingUtilTest method testResolveRelativeVolumePath.

/**
 * Insures that a host volume binding string that contains a path relative to the current working directory is
 * resolved to the supplied base directory.
 */
@Test
public void testResolveRelativeVolumePath() {
    String volumeString = format(BIND_STRING_FMT, RELATIVE_PATH, CONTAINER_PATH);
    // './rel:/path/to/container/dir' to '/absolute/basedir/rel:/path/to/container/dir'
    String relativizedVolumeString = resolveRelativeVolumeBinding(ABS_BASEDIR, volumeString);
    String expectedBindingString = format(BIND_STRING_FMT, new File(ABS_BASEDIR, stripLeadingPeriod(RELATIVE_PATH)), CONTAINER_PATH);
    assertEquals(expectedBindingString, relativizedVolumeString);
}
Also used : PathTestUtil.createTmpFile(io.fabric8.maven.docker.util.PathTestUtil.createTmpFile) File(java.io.File) Test(org.junit.Test)

Example 15 with Container

use of io.fabric8.maven.docker.model.Container in project docker-maven-plugin by fabric8io.

the class VolumeBindingUtilTest method testResolveRelativeVolumePathWithAccessSpecifications.

/**
 * Insures that a host volume binding string that contains a path relative to the current working directory <em>and
 * </em> specifies access controls resolves to the supplied base directory <em>and</em> that the access controls are
 * preserved through the operation.
 */
@Test
public void testResolveRelativeVolumePathWithAccessSpecifications() {
    String volumeString = format(BIND_STRING_WITH_ACCESS_FMT, RELATIVE_PATH, CONTAINER_PATH, RO_ACCESS);
    // './rel:/path/to/container/dir:ro' to '/absolute/basedir/rel:/path/to/container/dir:ro'
    String relativizedVolumeString = resolveRelativeVolumeBinding(ABS_BASEDIR, volumeString);
    String expectedBindingString = format(BIND_STRING_WITH_ACCESS_FMT, new File(ABS_BASEDIR, stripLeadingPeriod(RELATIVE_PATH)), CONTAINER_PATH, RO_ACCESS);
    assertEquals(expectedBindingString, relativizedVolumeString);
}
Also used : PathTestUtil.createTmpFile(io.fabric8.maven.docker.util.PathTestUtil.createTmpFile) File(java.io.File) Test(org.junit.Test)

Aggregations

Container (io.fabric8.api.Container)139 Test (org.junit.Test)85 FabricService (io.fabric8.api.FabricService)56 Container (io.fabric8.kubernetes.api.model.Container)56 ArrayList (java.util.ArrayList)42 IOException (java.io.IOException)40 Profile (io.fabric8.api.Profile)37 HashMap (java.util.HashMap)36 Map (java.util.Map)32 FabricException (io.fabric8.api.FabricException)27 File (java.io.File)27 Pod (io.fabric8.kubernetes.api.model.Pod)24 BundleContext (org.osgi.framework.BundleContext)24 Version (io.fabric8.api.Version)23 HashSet (java.util.HashSet)20 List (java.util.List)20 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)19 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)17 LinkedList (java.util.LinkedList)17 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)16