forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#5496 from iocanel/docker-build
Add support for building and deploying container to Kubernetes
- Loading branch information
Showing
107 changed files
with
4,199 additions
and
87 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
26 changes: 26 additions & 0 deletions
26
...ployment/src/main/java/io/quarkus/deployment/pkg/builditem/DeploymentResultBuildItem.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,26 @@ | ||
|
||
package io.quarkus.deployment.pkg.builditem; | ||
|
||
import java.util.Map; | ||
|
||
import io.quarkus.builder.item.SimpleBuildItem; | ||
|
||
public final class DeploymentResultBuildItem extends SimpleBuildItem { | ||
|
||
private final String name; | ||
private final Map<String, String> labels; | ||
|
||
public DeploymentResultBuildItem(String name, Map<String, String> labels) { | ||
this.name = name; | ||
this.labels = labels; | ||
} | ||
|
||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
public Map<String, String> getLabels() { | ||
return this.labels; | ||
} | ||
|
||
} |
130 changes: 130 additions & 0 deletions
130
core/deployment/src/main/java/io/quarkus/deployment/util/ExecUtil.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,130 @@ | ||
|
||
package io.quarkus.deployment.util; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.function.Function; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
public class ExecUtil { | ||
|
||
private static final Logger LOG = Logger.getLogger(ExecUtil.class); | ||
|
||
private static final Function<InputStream, Runnable> PRINT_OUTPUT = i -> new HandleOutput(i); | ||
private static final Function<InputStream, Runnable> SILENT = i -> new HandleOutput(i, false); | ||
|
||
private static class HandleOutput implements Runnable { | ||
|
||
private final InputStream is; | ||
private final Boolean logEnabled; | ||
|
||
HandleOutput(InputStream is) { | ||
this(is, true); | ||
} | ||
|
||
HandleOutput(InputStream is, Boolean logEnabled) { | ||
this.is = is; | ||
this.logEnabled = logEnabled; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try (InputStreamReader isr = new InputStreamReader(is); | ||
BufferedReader reader = new BufferedReader(isr)) { | ||
|
||
for (String line = reader.readLine(); line != null; line = reader.readLine()) { | ||
if (logEnabled) { | ||
LOG.info(line); | ||
} | ||
} | ||
} catch (IOException e) { | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Execute the specified command from within the current directory. | ||
* | ||
* @param command The command | ||
* @param args The command arguments | ||
* @return true if commands where executed successfully | ||
*/ | ||
public static boolean exec(String command, String... args) { | ||
return exec(new File("."), command, args); | ||
} | ||
|
||
/** | ||
* Execute the specified command from within the current directory and hide the output. | ||
* | ||
* @param command The command | ||
* @param args The command arguments | ||
* @return true if commands where executed successfully | ||
*/ | ||
public static boolean execSilent(String command, String... args) { | ||
return execSilent(new File("."), command, args); | ||
} | ||
|
||
/** | ||
* Execute the specified command from within the specified directory. | ||
* | ||
* @param directory The directory | ||
* @param command The command | ||
* @param args The command arguments | ||
* @return true if commands where executed successfully | ||
*/ | ||
public static boolean exec(File directory, String command, String... args) { | ||
return exec(directory, PRINT_OUTPUT, command, args); | ||
} | ||
|
||
/** | ||
* Execute the specified command from within the specified directory and hide the output. | ||
* | ||
* @param directory The directory | ||
* @param command The command | ||
* @param args The command arguments | ||
* @return true if commands where executed successfully | ||
*/ | ||
public static boolean execSilent(File directory, String command, String... args) { | ||
return exec(directory, SILENT, command, args); | ||
} | ||
|
||
/** | ||
* Execute the specified command from within the specified directory. | ||
* The method allows specifying an output filter that processes the command output. | ||
* | ||
* @param directory The directory | ||
* @param outputFilterFunction A {@link Function} that gets an {@link InputStream} and returns an outputFilter. | ||
* @param command The command | ||
* @param args The command arguments | ||
* @return true if commands where executed successfully | ||
*/ | ||
public static boolean exec(File directory, Function<InputStream, Runnable> outputFilterFunction, String command, | ||
String... args) { | ||
Process process = null; | ||
try { | ||
String[] cmd = new String[args.length + 1]; | ||
cmd[0] = command; | ||
if (args.length > 0) { | ||
System.arraycopy(args, 0, cmd, 1, args.length); | ||
} | ||
process = new ProcessBuilder() | ||
.directory(directory) | ||
.command(cmd) | ||
.redirectErrorStream(true) | ||
.start(); | ||
|
||
outputFilterFunction.apply(process.getInputStream()).run(); | ||
process.waitFor(); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Input/Output error while executing command.", e); | ||
} catch (InterruptedException e) { | ||
return false; | ||
} | ||
return process != null && process.exitValue() == 0; | ||
} | ||
|
||
} |
Oops, something went wrong.