-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move flyway/liquibase init to job resources
- Loading branch information
Showing
16 changed files
with
598 additions
and
47 deletions.
There are no files selected for viewing
119 changes: 119 additions & 0 deletions
119
core/deployment/src/main/java/io/quarkus/deployment/builditem/InitTaskBuildItem.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,119 @@ | ||
package io.quarkus.deployment.builditem; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
/** | ||
* Represents an initalization task for the application. | ||
* Often extension perform some short of initialization as part of the application startup. | ||
* There are cases where we we want to externalize the initialization (e.g. in a pipeline). | ||
* | ||
* Often the task is run using the same artifact as the application but using a different command or | ||
* arguments. In the later case it might be deseriable to pass addtinal environment variable to both the | ||
* init tasks (to enable init) and the application (to disable the init). | ||
*/ | ||
public final class InitTaskBuildItem extends MultiBuildItem { | ||
|
||
private final String name; | ||
private final Optional<String> image; | ||
private final List<String> command; | ||
private final List<String> arguments; | ||
private final Map<String, String> taskEnvVars; | ||
private final Map<String, String> appEnvVars; | ||
private final boolean sharedEnvironment; | ||
private final boolean sharedFilesystem; | ||
|
||
public static InitTaskBuildItem create() { | ||
return new InitTaskBuildItem("init", Optional.empty(), Collections.emptyList(), Collections.emptyList(), | ||
Collections.emptyMap(), Collections.emptyMap(), false, false); | ||
} | ||
|
||
public InitTaskBuildItem(String name, Optional<String> image, List<String> command, List<String> arguments, | ||
Map<String, String> taskEnvVars, Map<String, String> appEnvVars, boolean sharedEnvironment, | ||
boolean sharedFilesystem) { | ||
this.name = name; | ||
this.image = image; | ||
this.command = command; | ||
this.arguments = arguments; | ||
this.taskEnvVars = taskEnvVars; | ||
this.appEnvVars = appEnvVars; | ||
this.sharedEnvironment = sharedEnvironment; | ||
this.sharedFilesystem = sharedFilesystem; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public InitTaskBuildItem withName(String name) { | ||
return new InitTaskBuildItem(name, image, command, arguments, taskEnvVars, appEnvVars, sharedEnvironment, | ||
sharedFilesystem); | ||
} | ||
|
||
public Optional<String> getImage() { | ||
return image; | ||
} | ||
|
||
public InitTaskBuildItem withImage(String image) { | ||
return new InitTaskBuildItem(name, Optional.of(image), command, arguments, taskEnvVars, appEnvVars, sharedEnvironment, | ||
sharedFilesystem); | ||
} | ||
|
||
public List<String> getCommand() { | ||
return command; | ||
} | ||
|
||
public InitTaskBuildItem withCommand(List<String> command) { | ||
return new InitTaskBuildItem(name, image, command, arguments, taskEnvVars, appEnvVars, sharedEnvironment, | ||
sharedFilesystem); | ||
} | ||
|
||
public List<String> getArguments() { | ||
return arguments; | ||
} | ||
|
||
public InitTaskBuildItem withArguments(List<String> arguments) { | ||
return new InitTaskBuildItem(name, image, command, arguments, taskEnvVars, appEnvVars, sharedEnvironment, | ||
sharedFilesystem); | ||
} | ||
|
||
public Map<String, String> getTaskEnvVars() { | ||
return taskEnvVars; | ||
} | ||
|
||
public InitTaskBuildItem withTaskEnvVars(Map<String, String> taskEnvVars) { | ||
return new InitTaskBuildItem(name, image, command, arguments, taskEnvVars, appEnvVars, sharedEnvironment, | ||
sharedFilesystem); | ||
} | ||
|
||
public Map<String, String> getAppEnvVars() { | ||
return appEnvVars; | ||
} | ||
|
||
public InitTaskBuildItem withAppEnvVars(Map<String, String> appEnvVars) { | ||
return new InitTaskBuildItem(name, image, command, arguments, taskEnvVars, appEnvVars, sharedEnvironment, | ||
sharedFilesystem); | ||
} | ||
|
||
public boolean isSharedEnvironment() { | ||
return sharedEnvironment; | ||
} | ||
|
||
public InitTaskBuildItem withSharedEnvironment(boolean sharedEnvironment) { | ||
return new InitTaskBuildItem(name, image, command, arguments, taskEnvVars, appEnvVars, sharedEnvironment, | ||
sharedFilesystem); | ||
} | ||
|
||
public boolean isSharedFilesystem() { | ||
return sharedFilesystem; | ||
} | ||
|
||
public InitTaskBuildItem withSharedFilesystem(boolean sharedFilesystem) { | ||
return new InitTaskBuildItem(name, image, command, arguments, taskEnvVars, appEnvVars, sharedEnvironment, | ||
sharedFilesystem); | ||
} | ||
} |
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
97 changes: 97 additions & 0 deletions
97
...nsions/kubernetes/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesJobBuildItem.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,97 @@ | ||
package io.quarkus.kubernetes.spi; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
/** | ||
* A built item for generating init containers. | ||
* The generated container will have the specified fields | ||
* and may optionally inherit env vars and volumes from the app container. | ||
* | ||
* Env vars specified through this build item, will take precedence over inherited ones. | ||
*/ | ||
public final class KubernetesJobBuildItem extends MultiBuildItem { | ||
|
||
private final String name; | ||
private final String image; | ||
private final List<String> command; | ||
private final List<String> arguments; | ||
private final Map<String, String> envVars; | ||
private final boolean sharedEnvironment; | ||
private final boolean sharedFilesystem; | ||
|
||
public static KubernetesJobBuildItem create(String image) { | ||
return new KubernetesJobBuildItem("init", image, Collections.emptyList(), Collections.emptyList(), | ||
Collections.emptyMap(), false, false); | ||
} | ||
|
||
public KubernetesJobBuildItem(String name, String image, List<String> command, List<String> arguments, | ||
Map<String, String> envVars, boolean sharedEnvironment, boolean sharedFilesystem) { | ||
this.name = name; | ||
this.image = image; | ||
this.command = command; | ||
this.arguments = arguments; | ||
this.envVars = envVars; | ||
this.sharedEnvironment = sharedEnvironment; | ||
this.sharedFilesystem = sharedFilesystem; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public KubernetesJobBuildItem withName(String name) { | ||
return new KubernetesJobBuildItem(name, image, command, arguments, envVars, sharedEnvironment, sharedFilesystem); | ||
} | ||
|
||
public String getImage() { | ||
return image; | ||
} | ||
|
||
public KubernetesJobBuildItem withImage(String image) { | ||
return new KubernetesJobBuildItem(name, image, command, arguments, envVars, sharedEnvironment, sharedFilesystem); | ||
} | ||
|
||
public List<String> getCommand() { | ||
return command; | ||
} | ||
|
||
public KubernetesJobBuildItem withCommand(List<String> command) { | ||
return new KubernetesJobBuildItem(name, image, command, arguments, envVars, sharedEnvironment, sharedFilesystem); | ||
} | ||
|
||
public List<String> getArguments() { | ||
return arguments; | ||
} | ||
|
||
public KubernetesJobBuildItem withArguments(List<String> arguments) { | ||
return new KubernetesJobBuildItem(name, image, command, arguments, envVars, sharedEnvironment, sharedFilesystem); | ||
} | ||
|
||
public Map<String, String> getEnvVars() { | ||
return envVars; | ||
} | ||
|
||
public KubernetesJobBuildItem withEnvVars(Map<String, String> envVars) { | ||
return new KubernetesJobBuildItem(name, image, command, arguments, envVars, sharedEnvironment, sharedFilesystem); | ||
} | ||
|
||
public boolean isSharedEnvironment() { | ||
return sharedEnvironment; | ||
} | ||
|
||
public KubernetesJobBuildItem withSharedEnvironment(boolean sharedEnvironment) { | ||
return new KubernetesJobBuildItem(name, image, command, arguments, envVars, sharedEnvironment, sharedFilesystem); | ||
} | ||
|
||
public boolean isSharedFilesystem() { | ||
return sharedFilesystem; | ||
} | ||
|
||
public KubernetesJobBuildItem withSharedFilesystem(boolean sharedFilesystem) { | ||
return new KubernetesJobBuildItem(name, image, command, arguments, envVars, sharedEnvironment, sharedFilesystem); | ||
} | ||
} |
Oops, something went wrong.