Use boot config data api to determine resource and location.
Previously the resource name and location needed to be parsed. This change updates NativeEnvironmentRepository to pass a ConfigDataEnvironmentUpdateListener to ConfigDataEnvironmentPostProcessor.applyTo() and match PropertySources to location and resource. PassthruEnvironmentRepository is updated to attach the original PropertySource to use later in the clean() method to retrieve the location and resource avoiding parsing. Fixes gh-1875
This commit is contained in:
@@ -147,6 +147,10 @@ public class ConfigServerConfigDataLoader implements ConfigDataLoader<ConfigServ
|
||||
List<Option> options = new ArrayList<>();
|
||||
options.add(Option.IGNORE_IMPORTS);
|
||||
options.add(Option.IGNORE_PROFILES);
|
||||
// TODO: the profile is now available on the backend
|
||||
// in a future minor, add the profile associated with a
|
||||
// PropertySource see
|
||||
// https://github.com/spring-cloud/spring-cloud-config/issues/1874
|
||||
for (String profile : resource.getAcceptedProfiles()) {
|
||||
// TODO: switch to match
|
||||
if (propertySourceName.contains("-" + profile + ".")) {
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.cloud.config.environment;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
@@ -34,12 +35,22 @@ public class PropertySource {
|
||||
|
||||
private Map<?, ?> source;
|
||||
|
||||
private org.springframework.core.env.PropertySource<?> originalPropertySource;
|
||||
|
||||
@JsonCreator
|
||||
public PropertySource(@JsonProperty("name") String name, @JsonProperty("source") Map<?, ?> source) {
|
||||
this.name = name;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public PropertySource(String name, Map<?, ?> source,
|
||||
org.springframework.core.env.PropertySource<?> originalPropertySource) {
|
||||
this.name = name;
|
||||
this.source = source;
|
||||
this.originalPropertySource = originalPropertySource;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
@@ -48,6 +59,11 @@ public class PropertySource {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public org.springframework.core.env.PropertySource<?> getOriginalPropertySource() {
|
||||
return this.originalPropertySource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PropertySource [name=" + this.name + "]";
|
||||
|
||||
Reference in New Issue
Block a user