delegate reload to common code (#1061)
* fix * simplify labels * fix * fix test * trigger
This commit is contained in:
@@ -79,7 +79,7 @@ public abstract class ConfigMapWatcherChangeDetector extends KubernetesClientEve
|
||||
else {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Not publishing event. ConfigMap " + configMap.getMetadata().getName()
|
||||
+ " does not contain the label " + k8SConfigurationProperties.getConfigLabel());
|
||||
+ " does not contain the label " + ConfigurationWatcherConfigurationProperties.CONFIG_LABEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,8 +88,8 @@ public abstract class ConfigMapWatcherChangeDetector extends KubernetesClientEve
|
||||
if (configMap.getMetadata() == null || configMap.getMetadata().getLabels() == null) {
|
||||
return false;
|
||||
}
|
||||
return Boolean.parseBoolean(
|
||||
configMap.getMetadata().getLabels().getOrDefault(k8SConfigurationProperties.getConfigLabel(), "false"));
|
||||
return Boolean.parseBoolean(configMap.getMetadata().getLabels()
|
||||
.getOrDefault(ConfigurationWatcherConfigurationProperties.CONFIG_LABEL, "false"));
|
||||
}
|
||||
|
||||
protected abstract Mono<Void> triggerRefresh(V1ConfigMap configMap);
|
||||
|
||||
@@ -28,6 +28,16 @@ import org.springframework.boot.convert.DurationUnit;
|
||||
@ConfigurationProperties("spring.cloud.kubernetes.configuration.watcher")
|
||||
public class ConfigurationWatcherConfigurationProperties {
|
||||
|
||||
/**
|
||||
* label to enable refresh/restart when using configmaps.
|
||||
*/
|
||||
public static final String CONFIG_LABEL = "spring.cloud.kubernetes.config";
|
||||
|
||||
/**
|
||||
* label to enable refresh/restart when using secrets.
|
||||
*/
|
||||
public static final String SECRET_LABEL = "spring.cloud.kubernetes.secret";
|
||||
|
||||
/**
|
||||
* Amount of time to delay the posting of the event to allow the app volume to update
|
||||
* data.
|
||||
@@ -37,10 +47,6 @@ public class ConfigurationWatcherConfigurationProperties {
|
||||
|
||||
private int threadPoolSize = 1;
|
||||
|
||||
private String configLabel = "spring.cloud.kubernetes.config";
|
||||
|
||||
private String secretLabel = "spring.cloud.kubernetes.secret";
|
||||
|
||||
private String actuatorPath = "/actuator";
|
||||
|
||||
private Integer actuatorPort = -1;
|
||||
@@ -68,22 +74,6 @@ public class ConfigurationWatcherConfigurationProperties {
|
||||
this.actuatorPort = actuatorPort;
|
||||
}
|
||||
|
||||
public String getSecretLabel() {
|
||||
return secretLabel;
|
||||
}
|
||||
|
||||
public void setSecretLabel(String secretLabel) {
|
||||
this.secretLabel = secretLabel;
|
||||
}
|
||||
|
||||
public String getConfigLabel() {
|
||||
return configLabel;
|
||||
}
|
||||
|
||||
public void setConfigLabel(String configLabel) {
|
||||
this.configLabel = configLabel;
|
||||
}
|
||||
|
||||
public Duration getRefreshDelay() {
|
||||
return refreshDelay;
|
||||
}
|
||||
|
||||
@@ -62,8 +62,8 @@ public abstract class SecretsWatcherChangeDetector extends KubernetesClientEvent
|
||||
if (secret.getMetadata() == null || secret.getMetadata().getLabels() == null) {
|
||||
return false;
|
||||
}
|
||||
return Boolean.parseBoolean(
|
||||
secret.getMetadata().getLabels().getOrDefault(k8SConfigurationProperties.getSecretLabel(), "false"));
|
||||
return Boolean.parseBoolean(secret.getMetadata().getLabels()
|
||||
.getOrDefault(ConfigurationWatcherConfigurationProperties.SECRET_LABEL, "false"));
|
||||
}
|
||||
|
||||
protected abstract Mono<Void> triggerRefresh(V1Secret secret);
|
||||
@@ -88,7 +88,7 @@ public abstract class SecretsWatcherChangeDetector extends KubernetesClientEvent
|
||||
else {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Not publishing event. Secret " + secret.getMetadata().getName()
|
||||
+ " does not contain the label " + k8SConfigurationProperties.getSecretLabel());
|
||||
+ " does not contain the label " + ConfigurationWatcherConfigurationProperties.SECRET_LABEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user