Search in sources :

Example 11 with ImageArchiveManifestAdapter

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

the class ImageArchiveUtilTest method mapEntriesByIdSuccessfully.

@Test
public void mapEntriesByIdSuccessfully() {
    ImageArchiveManifest nonEmpty = new ImageArchiveManifestAdapter(createBasicManifestJson());
    Map<String, ImageArchiveManifestEntry> entries = ImageArchiveUtil.mapEntriesById(nonEmpty.getEntries());
    Assert.assertNotNull(entries);
    Assert.assertEquals(1, entries.size());
    Assert.assertNotNull(entries.get("image-id-sha256"));
    Assert.assertTrue(entries.get("image-id-sha256").getRepoTags().contains("test/image:latest"));
}
Also used : ImageArchiveManifestAdapter(io.fabric8.maven.docker.model.ImageArchiveManifestAdapter) ImageArchiveManifest(io.fabric8.maven.docker.model.ImageArchiveManifest) ImageArchiveManifestEntry(io.fabric8.maven.docker.model.ImageArchiveManifestEntry) Test(org.junit.Test)

Example 12 with ImageArchiveManifestAdapter

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

the class ImageArchiveUtilTest method findByRepoTagPatternSuccessfully.

@Test
public void findByRepoTagPatternSuccessfully() {
    ImageArchiveManifest nonEmpty = new ImageArchiveManifestAdapter(createBasicManifestJson());
    Pair<String, ImageArchiveManifestEntry> found;
    // Complete match
    found = ImageArchiveUtil.findEntryByRepoTagPattern("test/image:latest", nonEmpty);
    Assert.assertNotNull(found);
    Assert.assertEquals("test/image:latest", found.getLeft());
    Assert.assertNotNull(found.getRight());
    Assert.assertTrue(found.getRight().getRepoTags().contains("test/image:latest"));
    // Unanchored match
    found = ImageArchiveUtil.findEntryByRepoTagPattern("test/image", nonEmpty);
    Assert.assertNotNull(found);
    Assert.assertEquals("test/image:latest", found.getLeft());
    Assert.assertNotNull(found.getRight());
    Assert.assertTrue(found.getRight().getRepoTags().contains("test/image:latest"));
    // Initial anchor
    found = ImageArchiveUtil.findEntryByRepoTagPattern("^test/image", nonEmpty);
    Assert.assertNotNull(found);
    Assert.assertEquals("test/image:latest", found.getLeft());
    Assert.assertNotNull(found.getRight());
    Assert.assertTrue(found.getRight().getRepoTags().contains("test/image:latest"));
}
Also used : ImageArchiveManifestAdapter(io.fabric8.maven.docker.model.ImageArchiveManifestAdapter) ImageArchiveManifest(io.fabric8.maven.docker.model.ImageArchiveManifest) ImageArchiveManifestEntry(io.fabric8.maven.docker.model.ImageArchiveManifestEntry) Test(org.junit.Test)

Example 13 with ImageArchiveManifestAdapter

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

the class ImageArchiveUtilTest method findEntriesByRepoTagPatternEmptyManifest.

@Test
public void findEntriesByRepoTagPatternEmptyManifest() {
    ImageArchiveManifest empty = new ImageArchiveManifestAdapter(new JsonArray());
    Map<String, ImageArchiveManifestEntry> entries;
    entries = ImageArchiveUtil.findEntriesByRepoTagPattern((String) null, null);
    Assert.assertNotNull(entries);
    Assert.assertTrue(entries.isEmpty());
    entries = ImageArchiveUtil.findEntriesByRepoTagPattern(".*", null);
    Assert.assertNotNull(entries);
    Assert.assertTrue(entries.isEmpty());
    entries = ImageArchiveUtil.findEntriesByRepoTagPattern((String) null, empty);
    Assert.assertNotNull(entries);
    Assert.assertTrue(entries.isEmpty());
    entries = ImageArchiveUtil.findEntriesByRepoTagPattern(".*", empty);
    Assert.assertNotNull(entries);
    Assert.assertTrue(entries.isEmpty());
}
Also used : ImageArchiveManifestAdapter(io.fabric8.maven.docker.model.ImageArchiveManifestAdapter) JsonArray(com.google.gson.JsonArray) ImageArchiveManifest(io.fabric8.maven.docker.model.ImageArchiveManifest) ImageArchiveManifestEntry(io.fabric8.maven.docker.model.ImageArchiveManifestEntry) Test(org.junit.Test)

Aggregations

ImageArchiveManifestAdapter (io.fabric8.maven.docker.model.ImageArchiveManifestAdapter)13 ImageArchiveManifest (io.fabric8.maven.docker.model.ImageArchiveManifest)12 Test (org.junit.Test)12 ImageArchiveManifestEntry (io.fabric8.maven.docker.model.ImageArchiveManifestEntry)7 JsonArray (com.google.gson.JsonArray)3 Gson (com.google.gson.Gson)1 JsonElement (com.google.gson.JsonElement)1 JsonParseException (com.google.gson.JsonParseException)1 InputStreamReader (java.io.InputStreamReader)1 LinkedHashMap (java.util.LinkedHashMap)1 TarArchiveEntry (org.apache.commons.compress.archivers.tar.TarArchiveEntry)1 TarArchiveInputStream (org.apache.commons.compress.archivers.tar.TarArchiveInputStream)1