-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Allow the configprops endpoint to return properties with a particular prefix #24718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
...g/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java
Outdated
Show resolved
Hide resolved
...g/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java
Outdated
Show resolved
Hide resolved
beans.forEach((beanName, bean) -> descriptors.put(beanName, describeBean(mapper, bean))); | ||
|
||
Map<String, ConfigurationPropertiesBeanDescriptor> descriptors = beans.values().stream() | ||
.filter(beanFilterPredicate::test) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the approach of simply filtering out at the config props level and not returning a different payload for the individual api case. This differs form the /env
endpoint as it returns an XYZEntry
object instead of an XYZ
. This provided the filtering and introduced less ripple.
import static org.hamcrest.Matchers.hasSize; | ||
|
||
/** | ||
* Integration tests for {@link ConfigurationPropertiesReportEndpoint} exposed by Jersey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that we did not have @WebEndpointTest
coverage for /actuator/configprops
- this adds it.
...oot/actuate/context/properties/ConfigurationPropertiesReportEndpointWebIntegrationTests.java
Outdated
Show resolved
Hide resolved
...g/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java
Outdated
Show resolved
Hide resolved
@@ -26,3 +26,26 @@ The following table describes the structure of the response: | |||
|
|||
[cols="2,1,3"] | |||
include::{snippets}/configprops/response-fields.adoc[] | |||
|
|||
|
|||
[[configprops-retrieving-by-prefix]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wilkinsona I absolutely ❤️ what you did here w/ the endpoint doc generation - clever. It provides a consistent and accurate set of docs as well as provides some test coverage. It took a second for me to put the pieces together - but once I did, its a breeze. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's lovely to hear. Thank you!
...oot/actuate/context/properties/ConfigurationPropertiesReportEndpointWebIntegrationTests.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@WebEndpointTest | ||
void filterByNonExistentPrefix() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we return 404 in case of no prefix match? If so I need to create a web endpoint extension. Just let me know what the preference is here. Because the prefix can match multiple entries it feels more of a "List findByPrefix" than a "Object findByPrimaryKey" (if you will).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A 404 feels right to me. That's what we do in the env
endpoint for a property that doesn't exist. It too can match multiple entries as the same property may be defined in multiple property sources.
…o serve 404 when no match found
This commit improves the configprops endpoint to allow filtering properties based on a particular prefix See gh-24718
nicely done Chris. I've polished your contribution in b92bb93. The interesting bits is that we name the method differently when there is a selector so that the JMX operation (that uses the method name) can provide a bit more context as what it does compared to the general operation. Thanks again! |
Adds ability to filter by prefix for /actuator/configprops
Fixes gh-24714
No filter
Filter by prefix
(ℹ️ this was taken from v1 screenshot and url does not contain prefix param anymore)
