-
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: port mgmt from kube to ext publishing the
build items
- Loading branch information
Showing
8 changed files
with
169 additions
and
123 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
46 changes: 46 additions & 0 deletions
46
extensions/kubernetes/spi/src/main/java/io/quarkus/kubernetes/spi/Property.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,46 @@ | ||
package io.quarkus.kubernetes.spi; | ||
|
||
import java.util.Optional; | ||
|
||
import org.eclipse.microprofile.config.ConfigProvider; | ||
|
||
public class Property<T> { | ||
|
||
private final String name; | ||
private final Class<T> type; | ||
private final Optional<T> value; | ||
private final T defaultValue; | ||
private final boolean runtime; | ||
|
||
public Property(String name, Class<T> type, Optional<T> value, T defaultValue, boolean runtime) { | ||
this.name = name; | ||
this.type = type; | ||
this.value = value; | ||
this.defaultValue = defaultValue; | ||
this.runtime = runtime; | ||
} | ||
|
||
public static <T> Property<T> fromRuntimeConfiguration(String name, Class<T> type, T defaultValue) { | ||
return new Property<T>(name, type, ConfigProvider.getConfig().getOptionalValue(name, type), defaultValue, true); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public Class<T> getType() { | ||
return type; | ||
} | ||
|
||
public Optional<T> getValue() { | ||
return value; | ||
} | ||
|
||
public T getDefaultValue() { | ||
return defaultValue; | ||
} | ||
|
||
public boolean isRuntime() { | ||
return runtime; | ||
} | ||
} |
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
50 changes: 50 additions & 0 deletions
50
...netes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/PropertyUtil.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,50 @@ | ||
package io.quarkus.kubernetes.deployment; | ||
|
||
import java.util.HashSet; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
import io.quarkus.kubernetes.spi.Property; | ||
|
||
public class PropertyUtil { | ||
|
||
private static final Set<String> VISITED_EXTENSION_PROPERTIES = new HashSet<>(); | ||
private static final Logger LOG = Logger.getLogger(PropertyUtil.class); | ||
|
||
public static <T> void printMessages(String usage, String platform, Property<T> kubernetesProperty, | ||
Optional<Property<T>> extensionProperty) { | ||
extensionProperty.ifPresent(p -> { | ||
printMessages(usage, platform, kubernetesProperty, p); | ||
}); | ||
} | ||
|
||
public static <T> void printMessages(String usage, String platform, Property<T> kubernetesProperty, | ||
Property<T> extensionProperty) { | ||
if (!VISITED_EXTENSION_PROPERTIES.add(extensionProperty.getName())) { | ||
return; | ||
} | ||
|
||
String platformCapitalized = platform.substring(0, 1).toUpperCase() + platform.substring(1); | ||
T kubernetesValue = kubernetesProperty.getValue().orElse(null); | ||
if (kubernetesValue == null) { | ||
// If no kubernetes property is provided, this will be used instead. | ||
String defaultOrProvided = extensionProperty.getValue().isPresent() ? "provided" : "default"; | ||
String stringValue = String.valueOf(extensionProperty.getValue().orElse(extensionProperty.getDefaultValue())); | ||
LOG.infof("%s manifests are generated with '%s' having %s value '%s'. " | ||
+ "The app and manifests will get out of sync if the property '%s' is changed at runtime.", | ||
platformCapitalized, usage, defaultOrProvided, stringValue, extensionProperty.getName()); | ||
|
||
} else if (extensionProperty.getValue().filter(v -> !v.equals(kubernetesValue)).isPresent()) { | ||
// We have conflicting properties that need to be aligned. Maybe warn? | ||
String runtimeOrBuildTime = extensionProperty.isRuntime() ? "runtime" : "buildtime"; | ||
LOG.debugf( | ||
"%s property '%s' has been set with value '%s' while %s property '%s' is set with '%s'. %s will be set using the former.", | ||
platformCapitalized, kubernetesProperty.getName(), kubernetesProperty.getValue().get(), runtimeOrBuildTime, | ||
extensionProperty.getName(), extensionProperty.getValue().get(), usage); | ||
} else { | ||
// Both proeprties are present and aligned. | ||
} | ||
} | ||
} |
84 changes: 0 additions & 84 deletions
84
...illa/deployment/src/main/java/io/quarkus/kubernetes/deployment/RuntimePropertiesUtil.java
This file was deleted.
Oops, something went wrong.
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