Skip to content

Commit

Permalink
fix: BaseGenerator retrieves runtime mode from context
Browse files Browse the repository at this point in the history
- Runtime mode was being computed from System properties that
  were never set in the first place (this is specific to ResourceMojo)
- TODO: Refactor BaseEnricher so it behaves like BaseGenerator
  (not critical because it works as the properties are there for
   enrichers)

Signed-off-by: Marc Nuri <marc@marcnuri.com>
  • Loading branch information
manusa authored and rohanKanojia committed May 13, 2020
1 parent 332c121 commit 8ef0e0c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Usage:
### 1.0.0-alpha-SNAPSHOT
* Fix #182: Assembly is never null
* Fix #198: Wildfly works in OpenShift with S2I binary build (Docker)
* Fix : BaseGenerator retrieves runtime mode from context (not from missing properties)

### 1.0.0-alpha-3 (2020-05-06)
* Fix #167: Add CMD for wildfly based applications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public String getLabel() {
* Returns true if the given maven properties indicate running in OpenShift platform mode
*/
public static boolean isOpenShiftMode(Properties properties) {
return properties == null ? false : Objects.equals(openshift.toString(), properties.getProperty(FABRIC8_EFFECTIVE_PLATFORM_MODE, ""));
return properties != null && Objects.equals(openshift.toString(), properties.getProperty(FABRIC8_EFFECTIVE_PLATFORM_MODE, ""));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected String getFromAsConfigured() {
* @param builder for the build image configuration to add the from to.
*/
protected void addFrom(BuildConfiguration.BuildConfigurationBuilder builder) {
String fromMode = getConfigWithFallback(Config.fromMode, "jkube.generator.fromMode", getFromModeDefault(context.getRuntimeMode()));
String fromMode = getConfigWithFallback(Config.fromMode, "jkube.generator.fromMode", getFromModeDefault());
String from = getConfigWithFallback(Config.from, "jkube.generator.from", null);
if ("docker".equalsIgnoreCase(fromMode)) {
String fromImage = from;
Expand Down Expand Up @@ -160,8 +160,8 @@ protected void addFrom(BuildConfiguration.BuildConfigurationBuilder builder) {
}

// Use "istag" as default for "redhat" versions of this plugin
private String getFromModeDefault(RuntimeMode mode) {
if (mode == RuntimeMode.openshift && fromSelector != null && fromSelector.isRedHat()) {
private String getFromModeDefault() {
if (context.getRuntimeMode() == RuntimeMode.openshift && fromSelector != null && fromSelector.isRedHat()) {
return "istag";
} else {
return "docker";
Expand All @@ -174,7 +174,7 @@ private String getFromModeDefault(RuntimeMode mode) {
* @return Docker image name which is never null
*/
protected String getImageName() {
if (RuntimeMode.isOpenShiftMode(getProject().getProperties())) {
if (getContext().getRuntimeMode() == RuntimeMode.openshift) {
return getConfigWithFallback(Config.name, "jkube.generator.name", "%a:%l");
} else {
return getConfigWithFallback(Config.name, "jkube.generator.name", "%g/%a:%l");
Expand All @@ -188,11 +188,11 @@ protected String getImageName() {
* @return The docker registry if configured
*/
protected String getRegistry() {
if (!RuntimeMode.isOpenShiftMode(getProject().getProperties())) {
return getConfigWithFallback(Config.registry, "jkube.generator.registry", null);
if (getContext().getRuntimeMode() == RuntimeMode.openshift &&
getContext().getStrategy() == OpenShiftBuildStrategy.s2i) {
return null;
}

return null;
return getConfigWithFallback(Config.registry, "jkube.generator.registry", null);
}

/**
Expand Down

0 comments on commit 8ef0e0c

Please sign in to comment.