Search in sources :

Example 1 with ImageArchiveManifest

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

the class ImageArchiveUtilTest method readEmptyArchiveFromFile.

@Test
public void readEmptyArchiveFromFile() throws IOException {
    File temporaryTar = temporaryFolder.newFile();
    try (FileOutputStream fileOutput = new FileOutputStream(temporaryTar);
        TarArchiveOutputStream tarOutput = new TarArchiveOutputStream(fileOutput)) {
        tarOutput.finish();
    }
    ImageArchiveManifest manifest = ImageArchiveUtil.readManifest(temporaryTar);
    Assert.assertNull(manifest);
}
Also used : FileOutputStream(java.io.FileOutputStream) TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream) File(java.io.File) ImageArchiveManifest(io.fabric8.maven.docker.model.ImageArchiveManifest) Test(org.junit.Test)

Example 2 with ImageArchiveManifest

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

the class ImageArchiveUtilTest method findByRepoTagNonEmptyManifest.

@Test
public void findByRepoTagNonEmptyManifest() {
    ImageArchiveManifest nonEmpty = new ImageArchiveManifestAdapter(createBasicManifestJson());
    Assert.assertNull(ImageArchiveUtil.findEntryByRepoTag("anything", nonEmpty));
    // Prefix
    Assert.assertNull(ImageArchiveUtil.findEntryByRepoTag("test", nonEmpty));
    // Prefix
    Assert.assertNull(ImageArchiveUtil.findEntryByRepoTag("test/image", nonEmpty));
}
Also used : ImageArchiveManifestAdapter(io.fabric8.maven.docker.model.ImageArchiveManifestAdapter) ImageArchiveManifest(io.fabric8.maven.docker.model.ImageArchiveManifest) Test(org.junit.Test)

Example 3 with ImageArchiveManifest

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

the class ImageArchiveUtilTest method readEmptyCompressedArchive.

@Test
public void readEmptyCompressedArchive() throws IOException {
    byte[] emptyTar;
    try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
        GZIPOutputStream gzip = new GZIPOutputStream(baos);
        TarArchiveOutputStream tarOutput = new TarArchiveOutputStream(gzip)) {
        tarOutput.finish();
        gzip.finish();
        emptyTar = baos.toByteArray();
    }
    ImageArchiveManifest manifest = ImageArchiveUtil.readManifest(new ByteArrayInputStream(emptyTar));
    Assert.assertNull(manifest);
}
Also used : GZIPOutputStream(java.util.zip.GZIPOutputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream) ImageArchiveManifest(io.fabric8.maven.docker.model.ImageArchiveManifest) Test(org.junit.Test)

Example 4 with ImageArchiveManifest

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

the class ImageArchiveUtilTest method readEmptyArchiveFromStreamWithoutMarkSupport.

@Test
public void readEmptyArchiveFromStreamWithoutMarkSupport() throws IOException {
    byte[] emptyTar;
    try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
        TarArchiveOutputStream tarOutput = new TarArchiveOutputStream(baos)) {
        tarOutput.finish();
        emptyTar = baos.toByteArray();
    }
    ImageArchiveManifest manifest = ImageArchiveUtil.readManifest(new ByteArrayInputStream(emptyTar) {

        public boolean markSupported() {
            return false;
        }
    });
    Assert.assertNull(manifest);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream) ImageArchiveManifest(io.fabric8.maven.docker.model.ImageArchiveManifest) Test(org.junit.Test)

Example 5 with ImageArchiveManifest

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

the class ImageArchiveUtilTest method findEntriesByRepoTagPatternNonEmptyManifest.

@Test
public void findEntriesByRepoTagPatternNonEmptyManifest() {
    ImageArchiveManifest nonEmpty = new ImageArchiveManifestAdapter(createBasicManifestJson());
    Map<String, ImageArchiveManifestEntry> entries;
    entries = ImageArchiveUtil.findEntriesByRepoTagPattern("does/not:match", nonEmpty);
    Assert.assertNotNull(entries);
    Assert.assertTrue(entries.isEmpty());
    // Anchored pattern
    entries = ImageArchiveUtil.findEntriesByRepoTagPattern("^test/image$", nonEmpty);
    Assert.assertNotNull(entries);
    Assert.assertTrue(entries.isEmpty());
}
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)

Aggregations

ImageArchiveManifest (io.fabric8.maven.docker.model.ImageArchiveManifest)22 Test (org.junit.Test)20 ImageArchiveManifestAdapter (io.fabric8.maven.docker.model.ImageArchiveManifestAdapter)13 ImageArchiveManifestEntry (io.fabric8.maven.docker.model.ImageArchiveManifestEntry)10 TarArchiveOutputStream (org.apache.commons.compress.archivers.tar.TarArchiveOutputStream)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 TarArchiveEntry (org.apache.commons.compress.archivers.tar.TarArchiveEntry)5 JsonArray (com.google.gson.JsonArray)3 Gson (com.google.gson.Gson)2 JsonParseException (com.google.gson.JsonParseException)2 LinkedHashMap (java.util.LinkedHashMap)2 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 Matcher (java.util.regex.Matcher)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1