Disable the env info contributor by default
Closes gh-28311
This commit is contained in:
parent
f98c1e7231
commit
56b8494f15
|
@ -55,7 +55,7 @@ public class InfoContributorAutoConfiguration {
|
|||
public static final int DEFAULT_ORDER = Ordered.HIGHEST_PRECEDENCE + 10;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnEnabledInfoContributor("env")
|
||||
@ConditionalOnEnabledInfoContributor(value = "env", fallback = InfoContributorFallback.DISABLE)
|
||||
@Order(DEFAULT_ORDER)
|
||||
public EnvironmentInfoContributor envInfoContributor(ConfigurableEnvironment environment) {
|
||||
return new EnvironmentInfoContributor(environment);
|
||||
|
|
|
@ -49,22 +49,28 @@ class InfoContributorAutoConfigurationTests {
|
|||
.withConfiguration(AutoConfigurations.of(InfoContributorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void disableEnvContributor() {
|
||||
this.contextRunner.withPropertyValues("management.info.env.enabled=false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(EnvironmentInfoContributor.class));
|
||||
void envContributor() {
|
||||
this.contextRunner.withPropertyValues("management.info.env.enabled=true")
|
||||
.run((context) -> assertThat(context).hasSingleBean(EnvironmentInfoContributor.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultInfoContributorsEnabled() {
|
||||
this.contextRunner.run((context) -> {
|
||||
assertThat(context).hasSingleBean(EnvironmentInfoContributor.class);
|
||||
assertThat(context.getBeansOfType(InfoContributor.class)).hasSize(1);
|
||||
});
|
||||
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean(InfoContributor.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultInfoContributorsDisabled() {
|
||||
this.contextRunner.withPropertyValues("management.info.defaults.enabled=false")
|
||||
void defaultInfoContributorsEnabledWithPrerequisitesInPlace() {
|
||||
this.contextRunner.withUserConfiguration(GitPropertiesConfiguration.class, BuildPropertiesConfiguration.class)
|
||||
.run((context) -> assertThat(context.getBeansOfType(InfoContributor.class)).hasSize(2)
|
||||
.satisfies((contributors) -> assertThat(contributors.values())
|
||||
.hasOnlyElementsOfTypes(BuildInfoContributor.class, GitInfoContributor.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultInfoContributorsDisabledWithPrerequisitesInPlace() {
|
||||
this.contextRunner.withUserConfiguration(GitPropertiesConfiguration.class, BuildPropertiesConfiguration.class)
|
||||
.withPropertyValues("management.info.defaults.enabled=false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(InfoContributor.class));
|
||||
}
|
||||
|
||||
|
|
|
@ -1174,10 +1174,10 @@ When appropriate, Spring auto-configures the following `InfoContributor` beans:
|
|||
Whether or not an individual contributor is enabled is controlled by its `management.info.<id>.enabled` property.
|
||||
Different contributors have different defaults for this property, depending on their prerequisites and the nature of the information that they expose.
|
||||
|
||||
With no prequisites to indicate that it should be enabled, the `java` contributor is disabled by default.
|
||||
You can enable it by setting the configprop:management.info.java.enabled[] property to `true`.
|
||||
With no prequisites to indicate that they should be enabled, the `env` and `java` contributors are disabled by default.
|
||||
You can enable them by setting the configprop:management.info.env.enabled[] or configprop:management.info.java.enabled[] properties to `true`.
|
||||
|
||||
The `env`, `git`, and `build` info contributors are enabled by default.
|
||||
The `build` and `git` info contributors are enabled by default.
|
||||
Each can be disabled by setting its `management.info.<id>.enabled` property to `false`.
|
||||
Alternatively, to disable every contributor that is usually enabled by default, set the configprop:management.info.defaults.enabled[] property to `false`.
|
||||
|
||||
|
@ -1185,7 +1185,7 @@ Alternatively, to disable every contributor that is usually enabled by default,
|
|||
|
||||
[[actuator.endpoints.info.custom-application-information]]
|
||||
==== Custom Application Information
|
||||
You can customize the data exposed by the `info` endpoint by setting `+info.*+` Spring properties.
|
||||
When the `env` contributor is enabled, you can customize the data exposed by the `info` endpoint by setting `+info.*+` Spring properties.
|
||||
All `Environment` properties under the `info` key are automatically exposed.
|
||||
For example, you could add the following settings to your `application.properties` file:
|
||||
|
||||
|
|
Loading…
Reference in New Issue