This repository has been archived by the owner on Sep 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(k8s): copy files from pods using shared folder instead of api…
… calls fixes: #445
- Loading branch information
1 parent
714f87c
commit 9b8854b
Showing
10 changed files
with
191 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/de/zalando/ep/zalenium/streams/DefaultInputStreamDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package de.zalando.ep.zalenium.streams; | ||
|
||
import java.io.InputStream; | ||
|
||
public final class DefaultInputStreamDescriptor implements InputStreamDescriptor{ | ||
private final InputStream is; | ||
private final String name; | ||
|
||
public DefaultInputStreamDescriptor(InputStream is, String name) { | ||
this.is = is; | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public InputStream get() { | ||
return is; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return name; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/de/zalando/ep/zalenium/streams/InputStreamDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package de.zalando.ep.zalenium.streams; | ||
|
||
import java.io.InputStream; | ||
|
||
public interface InputStreamDescriptor { | ||
|
||
InputStream get(); | ||
String name(); | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/de/zalando/ep/zalenium/streams/InputStreamGroupIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package de.zalando.ep.zalenium.streams; | ||
|
||
import java.io.IOException; | ||
|
||
public interface InputStreamGroupIterator { | ||
|
||
InputStreamDescriptor next() throws IOException; | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/de/zalando/ep/zalenium/streams/MapInputStreamAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package de.zalando.ep.zalenium.streams; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.util.Iterator; | ||
import java.io.File; | ||
import java.util.Map; | ||
|
||
public class MapInputStreamAdapter implements InputStreamGroupIterator{ | ||
|
||
Iterator<Map.Entry<String, File>> streams; | ||
|
||
public MapInputStreamAdapter(Map<String, File> files) { | ||
streams = files.entrySet().stream() | ||
.iterator(); | ||
} | ||
|
||
@Override | ||
public InputStreamDescriptor next() throws IOException { | ||
return streams.hasNext() ? getNextDescriptor() : null; | ||
} | ||
|
||
private InputStreamDescriptor getNextDescriptor() throws IOException { | ||
Map.Entry<String, File> entry = streams.next(); | ||
return new DefaultInputStreamDescriptor(new FileInputStream(entry.getValue()), entry.getKey()); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/de/zalando/ep/zalenium/streams/TarInputStreamGroupWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package de.zalando.ep.zalenium.streams; | ||
|
||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; | ||
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; | ||
|
||
import java.io.IOException; | ||
|
||
public class TarInputStreamGroupWrapper implements InputStreamGroupIterator{ | ||
|
||
private final TarArchiveInputStream stream; | ||
private TarArchiveEntry currentTarEntry; | ||
private boolean started = false; | ||
|
||
public TarInputStreamGroupWrapper(TarArchiveInputStream stream) { | ||
if(stream == null) { | ||
throw new RuntimeException("Stream cannot be null"); | ||
} | ||
|
||
this.stream = stream; | ||
} | ||
|
||
@Override | ||
public InputStreamDescriptor next() throws IOException { | ||
while(!started || (currentTarEntry != null && currentTarEntry.isDirectory())) { | ||
started = true; | ||
currentTarEntry = stream.getNextTarEntry(); | ||
} | ||
return currentTarEntry == null ? null : new DefaultInputStreamDescriptor(stream, currentTarEntry.getName()); | ||
} | ||
|
||
|
||
} |