Commit e6eb0260 authored by Phillip Webb's avatar Phillip Webb

Polish 'Inherit show-details property in health groups'

Rework the inheritance so that the property metadata JSON more
accurately reflects the default value.

See gh-22022
parent 10de8888
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -33,11 +33,25 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -33,11 +33,25 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("management.endpoint.health") @ConfigurationProperties("management.endpoint.health")
public class HealthEndpointProperties extends HealthProperties { public class HealthEndpointProperties extends HealthProperties {
/**
* When to show full health details.
*/
private Show showDetails = Show.NEVER;
/** /**
* Health endpoint groups. * Health endpoint groups.
*/ */
private Map<String, Group> group = new LinkedHashMap<>(); private Map<String, Group> group = new LinkedHashMap<>();
@Override
public Show getShowDetails() {
return this.showDetails;
}
public void setShowDetails(Show showDetails) {
this.showDetails = showDetails;
}
public Map<String, Group> getGroup() { public Map<String, Group> getGroup() {
return this.group; return this.group;
} }
...@@ -58,7 +72,8 @@ public class HealthEndpointProperties extends HealthProperties { ...@@ -58,7 +72,8 @@ public class HealthEndpointProperties extends HealthProperties {
private Set<String> exclude; private Set<String> exclude;
/** /**
* The default value of this field should be null for group. * When to show full health details. Defaults to the value of
* 'management.endpoint.health.show-details'.
*/ */
private Show showDetails; private Show showDetails;
...@@ -83,7 +98,6 @@ public class HealthEndpointProperties extends HealthProperties { ...@@ -83,7 +98,6 @@ public class HealthEndpointProperties extends HealthProperties {
return this.showDetails; return this.showDetails;
} }
@Override
public void setShowDetails(Show showDetails) { public void setShowDetails(Show showDetails) {
this.showDetails = showDetails; this.showDetails = showDetails;
} }
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -43,11 +43,6 @@ public abstract class HealthProperties { ...@@ -43,11 +43,6 @@ public abstract class HealthProperties {
*/ */
private Show showComponents; private Show showComponents;
/**
* When to show full health details.
*/
private Show showDetails = Show.NEVER;
/** /**
* Roles used to determine whether or not a user is authorized to be shown details. * Roles used to determine whether or not a user is authorized to be shown details.
* When empty, all authenticated users are authorized. * When empty, all authenticated users are authorized.
...@@ -66,13 +61,7 @@ public abstract class HealthProperties { ...@@ -66,13 +61,7 @@ public abstract class HealthProperties {
this.showComponents = showComponents; this.showComponents = showComponents;
} }
public Show getShowDetails() { public abstract Show getShowDetails();
return this.showDetails;
}
public void setShowDetails(Show showDetails) {
this.showDetails = showDetails;
}
public Set<String> getRoles() { public Set<String> getRoles() {
return this.roles; return this.roles;
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -310,7 +310,7 @@ class AutoConfiguredHealthEndpointGroupsTests { ...@@ -310,7 +310,7 @@ class AutoConfiguredHealthEndpointGroupsTests {
} }
@Test @Test
void createWhenNoDefinedGroupsShowDetails() { void createWhenGroupWithNoShowDetailsOverrideInheritsShowDetails() {
this.contextRunner.withPropertyValues("management.endpoint.health.show-details=always", this.contextRunner.withPropertyValues("management.endpoint.health.show-details=always",
"management.endpoint.health.group.a.include=*").run((context) -> { "management.endpoint.health.group.a.include=*").run((context) -> {
HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class); HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment