Handle negated profiles in S3 bucket multi-document YAML files#3225
Open
ryanjbaxter wants to merge 2 commits into
Open
Handle negated profiles in S3 bucket multi-document YAML files#3225ryanjbaxter wants to merge 2 commits into
ryanjbaxter wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses #3224 by restoring parity between the S3 backend and other backends (native/git) for multi-document YAML handling when spring.config.activate.on-profile uses negation and more complex profile expressions. It extends the S3 YAML document selection logic so documents activated by profile expressions (e.g., !my-profile, profile1 & !profile2) can be included/excluded correctly, and adds regression tests for these scenarios.
Changes:
- Add S3 YAML document matching support for negated/complex
spring.config.activate.on-profileexpressions usingorg.springframework.core.env.Profiles. - Add new AWS S3 repository tests covering negated profiles, multiple negated documents, and complex expressions (including application-directory layout variants).
- Add test YAML fixtures representing multi-document inputs with negated and complex profile expressions.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepository.java |
Adds expression-based YAML document matching for S3-backed multi-document YAML. |
spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepositoryTests.java |
Adds regression tests validating inclusion/exclusion for negated and complex profile expressions. |
spring-cloud-config-server/src/test/resources/awss3/application-with-negated-profile.yaml |
Fixture: base + !my-profile activated document. |
spring-cloud-config-server/src/test/resources/awss3/application-with-two-negated-profiles.yaml |
Fixture: base + two negated-profile documents. |
spring-cloud-config-server/src/test/resources/awss3/application-with-complex-profile-expressions.yaml |
Fixture: base + multiple complex profile expressions (&, ` |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+190
to
+194
| catch (Exception e) { | ||
| if (LOG.isDebugEnabled()) { | ||
| LOG.debug("Did not find negated profile yaml document in non-profile specific file using application <" | ||
| + application + "> label <" + label + ">."); | ||
| } |
|
|
||
| private static boolean isSimpleProfileName(String expression) { | ||
| return !expression.contains("!") && !expression.contains("&") && !expression.contains("|") | ||
| && !expression.contains("("); |
Comment on lines
+177
to
+187
| // null profiles → no active profiles → "!my-profile" should always match | ||
| final Environment env = envRepo.findOne("application", null, null); | ||
|
|
||
| List<PropertySource> propertySources = env.getPropertySources(); | ||
| Optional<PropertySource> negatedProfileSource = propertySources.stream() | ||
| .filter(ps -> ps.getSource().containsKey("demo.negatedProfileMarker")) | ||
| .findFirst(); | ||
| assertThat(negatedProfileSource).as("negated profile document should be present when no profiles are active") | ||
| .isPresent(); | ||
| assertThat(negatedProfileSource.get().getSource().get("demo.negatedProfileMarker")) | ||
| .isEqualTo("present-when-my-profile-is-not-active"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3224