-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b51bb5f
commit c0d4042
Showing
5 changed files
with
155 additions
and
1 deletion.
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
42 changes: 42 additions & 0 deletions
42
app/src/main/java/io/seqera/wavelit/util/ConfigFileProcessor.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,42 @@ | ||
package io.seqera.wavelit.util; | ||
|
||
import io.seqera.wave.api.ContainerConfig; | ||
import io.seqera.wavelit.json.JsonHelper; | ||
|
||
import java.io.*; | ||
import java.net.URL; | ||
|
||
/** | ||
* This implements parsing and assiging the value from json config file to ContainerConfig object | ||
* | ||
* @author Munish Chouhan <[email protected]> | ||
*/ | ||
public class ConfigFileProcessor { | ||
|
||
public static ContainerConfig process(String configFile) throws IOException { | ||
String content = loadFile(configFile); | ||
ContainerConfig containerConfig = JsonHelper.fromJson(content, ContainerConfig.class); | ||
return containerConfig; | ||
} | ||
|
||
private static String loadFile(String configFile) throws IOException { | ||
InputStream inputStream; | ||
if(configFile.startsWith("http")){ | ||
URL url = new URL(configFile); | ||
inputStream = url.openStream(); | ||
} else { | ||
File inputFile = new File(configFile); | ||
inputStream = new FileInputStream(inputFile); | ||
} | ||
StringBuilder contentBuilder = new StringBuilder(); | ||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { | ||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
contentBuilder.append(line); | ||
} | ||
} finally { | ||
inputStream.close(); | ||
} | ||
return contentBuilder.toString(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"entrypoint": [ "entrypoint" ], | ||
"layers": [ | ||
{ | ||
"location": "https://location", | ||
"gzipDigest": "sha256:gzipDigest", | ||
"gzipSize": 100, | ||
"tarDigest": "sha256:tarDigest", | ||
"skipHashing": true | ||
} | ||
] | ||
} |