Skip to content

Commit d7062a6

Browse files
committed
review comments
Signed-off-by: wind57 <[email protected]>
1 parent 459d14d commit d7062a6

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,18 @@
4949
* {@link org.springframework.beans.factory.config.YamlPropertiesFactoryBean} that takes
5050
* care to override profile-based collections and maps.
5151
*
52-
* Unlike YamlPropertiesFactoryBean, which flattens collections and maps, this one does things a bit different.
52+
* We can't use the same functionality of loading yaml files that spring-boot does :
53+
* {@link org.springframework.boot.env.YamlPropertySourceLoader} and thus OriginTrackedYamlLoader,
54+
* because spring-boot loads every single yaml document (all in a file) into a separate PropertySource.
55+
* So each yaml document ends up in a separate PropertySource. We, on the other hand, have to load all yaml documents
56+
* into a single Properties file, that ends up being a single PropertySource.
57+
* This happens because we first have to read configmaps / secrets
58+
* and only at that point do we know if a yaml contains more than one document.
59+
*
60+
* As such, we mimic the same things that spring-boot achieves by creating our own yaml reader, that is neavily based
61+
* on the YamlPropertiesFactoryBean.
62+
*
63+
* This is how it does things:
5364
*
5465
* <ul>
5566
* <li>read all the documents in a yaml file</li>
@@ -65,9 +76,9 @@
6576
*
6677
* @author wind57
6778
*/
68-
final class CustomYamlPropertiesFactoryBean {
79+
final class ProfileActivationAwareYamlPropertiesFactoryBean {
6980

70-
private static final LogAccessor LOG = new LogAccessor(LogFactory.getLog(CustomYamlPropertiesFactoryBean.class));
81+
private static final LogAccessor LOG = new LogAccessor(LogFactory.getLog(ProfileActivationAwareYamlPropertiesFactoryBean.class));
7182

7283
private List<DocumentMatcher> documentMatchers = Collections.emptyList();
7384

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private PropertySourceUtils() {
7575
*/
7676
public static Function<String, Map<String, Object>> yamlParserGenerator(Environment environment) {
7777
return source -> {
78-
CustomYamlPropertiesFactoryBean yamlFactory = new CustomYamlPropertiesFactoryBean();
78+
ProfileActivationAwareYamlPropertiesFactoryBean yamlFactory = new ProfileActivationAwareYamlPropertiesFactoryBean();
7979
yamlFactory.setDocumentMatchers(properties -> {
8080
if (environment != null) {
8181
String profiles = null;

0 commit comments

Comments
 (0)