Skip to content

Commit 10002a8

Browse files
committed
Merge branch 'main' into fix-1715-drop-profiles-support
2 parents 0ab7e41 + 0355d7a commit 10002a8

File tree

20 files changed

+129
-91
lines changed

20 files changed

+129
-91
lines changed

docs/modules/ROOT/pages/property-source-config/propertysource-reload.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
= `PropertySource` Reload
33

44
WARNING: This functionality has been deprecated in the 2020.0 release. Please see
5-
the xref:spring-cloud-kubernetes-configuration-watcher.adoc#spring-cloud-kubernetes-configuration-watcher[null] controller for an alternative way
6-
to achieve the same functionality.
5+
the xref:spring-cloud-kubernetes-configuration-watcher.adoc#spring-cloud-kubernetes-configuration-watcher[Spring Cloud Kubernetes Configuration Watcher]
6+
controller for an alternative way to achieve the same functionality.
77

88
Some applications may need to detect changes on external property sources and update their internal status to reflect the new configuration.
99
The reload feature of Spring Cloud Kubernetes is able to trigger an application reload when a related `ConfigMap` or

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"dependencies": {
33
"antora": "3.2.0-alpha.4",
44
"@antora/atlas-extension": "1.0.0-alpha.2",
5-
"@antora/collector-extension": "1.0.0-beta.3",
5+
"@antora/collector-extension": "1.0.0-beta.4",
66
"@asciidoctor/tabs": "1.0.0-beta.6",
77
"@springio/antora-extensions": "1.11.1",
88
"@springio/asciidoctor-extensions": "1.0.0-alpha.14"

spring-cloud-kubernetes-client-config/src/main/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private static List<StrippedSourceContainer> strippedConfigMaps(CoreV1Api coreV1
143143
private static List<StrippedSourceContainer> strippedSecrets(CoreV1Api coreV1Api, String namespace) {
144144
List<StrippedSourceContainer> strippedSecrets = KubernetesClientSecretsCache.byNamespace(coreV1Api, namespace);
145145
if (strippedSecrets.isEmpty()) {
146-
LOG.debug("No configmaps in namespace '" + namespace + "'");
146+
LOG.debug("No secrets in namespace '" + namespace + "'");
147147
}
148148
return strippedSecrets;
149149
}

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapPropertySourceLocator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ public PropertySource<?> locate(Environment environment) {
8282
if (this.properties.enableApi()) {
8383
Set<NormalizedSource> sources = new LinkedHashSet<>(this.properties.determineSources(environment));
8484
LOG.debug("Config Map normalized sources : " + sources);
85-
sources.forEach(s -> composite.addFirstPropertySource(getMapPropertySource(s, env)));
85+
sources.forEach(s -> {
86+
MapPropertySource propertySource = getMapPropertySource(s, env);
87+
LOG.debug("Adding config map property source " + propertySource.getName());
88+
composite.addFirstPropertySource(propertySource);
89+
});
8690
}
8791

8892
addPropertySourcesFromPaths(environment, composite);

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtils.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public final class ConfigUtils {
5959
|| sourceName.endsWith("-" + activeProfile + ".yaml")
6060
|| sourceName.endsWith("-" + activeProfile + ".properties");
6161

62-
private static final ApplicationListener<?> NO_OP = (e) -> { };
62+
private static final ApplicationListener<?> NO_OP = (e) -> {
63+
};
6364

6465
private ConfigUtils() {
6566
}
@@ -207,7 +208,7 @@ public static MultipleSourcesContainer processNamedData(List<StrippedSourceConta
207208
sourceNames.forEach(sourceName -> {
208209
StrippedSourceContainer stripped = hashByName.get(sourceName);
209210
if (stripped != null) {
210-
LOG.debug("Found source with name : '" + sourceName + " in namespace: '" + namespace + "'");
211+
LOG.debug("Found source with name : '" + sourceName + "' in namespace: '" + namespace + "'");
211212
foundSourceNames.add(sourceName);
212213
// see if data is a single yaml/properties file and if it needs decoding
213214
Map<String, String> rawData = stripped.data();
@@ -226,6 +227,9 @@ public static MultipleSourcesContainer processNamedData(List<StrippedSourceConta
226227
environment, includeDefaultProfileData));
227228
}
228229
}
230+
else {
231+
LOG.warn("sourceName : " + sourceName + " was requested, but not found in namespace : " + namespace);
232+
}
229233
});
230234

231235
return new MultipleSourcesContainer(foundSourceNames, data);

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/LabeledSourceData.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ public final SourceData compute(Map<String, String> labels, ConfigUtils.Prefix p
3939
data = dataSupplier(labels);
4040

4141
// need this check because when there is no data, the name of the property
42-
// source
43-
// is using provided labels,
42+
// source is using provided labels,
4443
// unlike when the data is present: when we use secret names
4544
if (data.names().isEmpty()) {
4645
String names = labels.keySet()

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedSourceData.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
package org.springframework.cloud.kubernetes.commons.config;
1818

1919
import java.util.LinkedHashSet;
20-
import java.util.Map;
2120
import java.util.stream.Collectors;
2221

22+
import org.apache.commons.logging.Log;
23+
import org.apache.commons.logging.LogFactory;
24+
2325
import static org.springframework.cloud.kubernetes.commons.config.ConfigUtils.onException;
2426
import static org.springframework.cloud.kubernetes.commons.config.Constants.PROPERTY_SOURCE_NAME_SEPARATOR;
2527

@@ -31,6 +33,8 @@
3133
*/
3234
public abstract class NamedSourceData {
3335

36+
private static final Log LOG = LogFactory.getLog(NamedSourceData.class);
37+
3438
public final SourceData compute(String sourceName, ConfigUtils.Prefix prefix, String target, boolean profileSources,
3539
boolean failFast, String namespace, String[] activeProfiles) {
3640

@@ -51,7 +55,9 @@ public final SourceData compute(String sourceName, ConfigUtils.Prefix prefix, St
5155
data = dataSupplier(sourceNames);
5256

5357
if (data.names().isEmpty()) {
54-
return new SourceData(ConfigUtils.sourceName(target, sourceName, namespace), Map.of());
58+
String emptySourceName = ConfigUtils.sourceName(target, sourceName, namespace);
59+
LOG.debug("Will return empty source with name : " + emptySourceName);
60+
return SourceData.emptyRecord(emptySourceName);
5561
}
5662

5763
if (prefix != ConfigUtils.Prefix.DEFAULT) {

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.springframework.core.env.CompositePropertySource;
4343
import org.springframework.core.env.ConfigurableEnvironment;
4444
import org.springframework.core.env.Environment;
45+
import org.springframework.core.env.MapPropertySource;
4546
import org.springframework.core.env.PropertySource;
4647

4748
/**
@@ -87,8 +88,11 @@ public PropertySource<?> locate(Environment environment) {
8788
putPathConfig(composite);
8889

8990
if (this.properties.enableApi()) {
90-
uniqueSources
91-
.forEach(s -> composite.addPropertySource(getSecretsPropertySourceForSingleSecret(env, s)));
91+
uniqueSources.forEach(s -> {
92+
MapPropertySource propertySource = getSecretsPropertySourceForSingleSecret(env, s);
93+
LOG.debug("Adding secret property source " + propertySource.getName());
94+
composite.addFirstPropertySource(propertySource);
95+
});
9296
}
9397

9498
cache.discardAll();

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceData.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.cloud.kubernetes.commons.config;
1818

19-
import java.util.Collections;
2019
import java.util.Map;
2120

2221
/**
@@ -25,10 +24,10 @@
2524
*
2625
* @author wind57
2726
*/
28-
public final record SourceData(String sourceName, Map<String, Object> sourceData) {
27+
public record SourceData(String sourceName, Map<String, Object> sourceData) {
2928

3029
public static SourceData emptyRecord(String sourceName) {
31-
return new SourceData(sourceName, Collections.emptyMap());
30+
return new SourceData(sourceName, Map.of());
3231
}
3332

3433
}

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class SourceDataEntriesProcessor extends MapPropertySource {
4848

4949
private static final Log LOG = LogFactory.getLog(SourceDataEntriesProcessor.class);
5050

51-
private static Predicate<String> ENDS_IN_EXTENSION = x -> x.endsWith(".yml") || x.endsWith(".yaml")
51+
private static final Predicate<String> ENDS_IN_EXTENSION = x -> x.endsWith(".yml") || x.endsWith(".yaml")
5252
|| x.endsWith(".properties");
5353

5454
public SourceDataEntriesProcessor(SourceData sourceData) {

0 commit comments

Comments
 (0)