Include the environment default profiles in the env endpoint's response

See gh-39257
This commit is contained in:
Wzy19930507
2024-01-21 22:28:55 +08:00
committed by Moritz Halbritter
parent f36b69f961
commit dae3952144
3 changed files with 27 additions and 7 deletions

View File

@@ -101,7 +101,8 @@ public class EnvironmentEndpoint {
propertyNamePredicate, showUnsanitized));
}
});
return new EnvironmentDescriptor(Arrays.asList(this.environment.getActiveProfiles()), propertySources);
return new EnvironmentDescriptor(Arrays.asList(this.environment.getActiveProfiles()),
Arrays.asList(this.environment.getDefaultProfiles()), propertySources);
}
@ReadOperation
@@ -114,7 +115,7 @@ public class EnvironmentEndpoint {
Map<String, PropertyValueDescriptor> descriptors = getPropertySourceDescriptors(propertyName, showUnsanitized);
PropertySummaryDescriptor summary = getPropertySummaryDescriptor(descriptors);
return new EnvironmentEntryDescriptor(summary, Arrays.asList(this.environment.getActiveProfiles()),
toPropertySourceDescriptors(descriptors));
Arrays.asList(this.environment.getDefaultProfiles()), toPropertySourceDescriptors(descriptors));
}
private List<PropertySourceEntryDescriptor> toPropertySourceDescriptors(
@@ -209,10 +210,14 @@ public class EnvironmentEndpoint {
private final List<String> activeProfiles;
private final List<String> defaultProfiles;
private final List<PropertySourceDescriptor> propertySources;
private EnvironmentDescriptor(List<String> activeProfiles, List<PropertySourceDescriptor> propertySources) {
private EnvironmentDescriptor(List<String> activeProfiles, List<String> defaultProfiles,
List<PropertySourceDescriptor> propertySources) {
this.activeProfiles = activeProfiles;
this.defaultProfiles = defaultProfiles;
this.propertySources = propertySources;
}
@@ -220,6 +225,10 @@ public class EnvironmentEndpoint {
return this.activeProfiles;
}
public List<String> getDefaultProfiles() {
return this.defaultProfiles;
}
public List<PropertySourceDescriptor> getPropertySources() {
return this.propertySources;
}
@@ -236,12 +245,15 @@ public class EnvironmentEndpoint {
private final List<String> activeProfiles;
private final List<String> defaultProfiles;
private final List<PropertySourceEntryDescriptor> propertySources;
EnvironmentEntryDescriptor(PropertySummaryDescriptor property, List<String> activeProfiles,
List<PropertySourceEntryDescriptor> propertySources) {
List<String> defaultProfiles, List<PropertySourceEntryDescriptor> propertySources) {
this.property = property;
this.activeProfiles = activeProfiles;
this.defaultProfiles = defaultProfiles;
this.propertySources = propertySources;
}
@@ -253,6 +265,10 @@ public class EnvironmentEndpoint {
return this.activeProfiles;
}
public List<String> getDefaultProfiles() {
return this.defaultProfiles;
}
public List<PropertySourceEntryDescriptor> getPropertySources() {
return this.propertySources;
}

View File

@@ -86,7 +86,8 @@ class EnvironmentEndpointWebExtensionTests {
private void verifyPrefixed(SecurityContext securityContext, boolean showUnsanitized) {
given(this.delegate.getEnvironmentEntryDescriptor("test", showUnsanitized))
.willReturn(new EnvironmentEntryDescriptor(null, Collections.emptyList(), Collections.emptyList()));
.willReturn(new EnvironmentEntryDescriptor(null, Collections.emptyList(), Collections.emptyList(),
Collections.emptyList()));
this.webExtension.environmentEntry(securityContext, "test");
then(this.delegate).should().getEnvironmentEntryDescriptor("test", showUnsanitized);
}