-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
add namespaces check in synchronization configuration feature #5192
add namespaces check in synchronization configuration feature #5192
Conversation
WalkthroughThe recent changes enhance the synchronization validation logic within the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java (1 hunks)
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceSyncModel.java (1 hunks)
@@ -195,7 +195,7 @@ public List<ItemDiffs> diff(@RequestBody NamespaceSyncModel model) { | |||
@PutMapping(value = "/apps/{appId}/namespaces/{namespaceName}/items", consumes = {"application/json"}) | |||
public ResponseEntity<Void> update(@PathVariable String appId, @PathVariable String namespaceName, | |||
@RequestBody NamespaceSyncModel model) { | |||
checkModel(!model.isInvalid()); | |||
checkModel(!model.isInvalid() && model.syncToNamespacesValid(appId, namespaceName)); |
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.
LGTM! Add unit tests to verify the new validation logic.
The code changes are approved. Ensure to add unit tests to verify the new validation logic in the update
method.
Do you want me to generate the unit testing code or open a GitHub issue to track this task?
a71a904
to
621c151
Compare
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.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java (1 hunks)
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceSyncModel.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java
public boolean syncToNamespacesValid(String appId, String namespaceName) { | ||
for (NamespaceIdentifier namespaceIdentifier : syncToNamespaces) { | ||
if (appId.equals(namespaceIdentifier.getAppId()) && namespaceName.equals( | ||
namespaceIdentifier.getNamespaceName())) { | ||
continue; | ||
} | ||
return false; | ||
} | ||
return true; |
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.
Consider using stream
and allMatch
for better readability.
The current implementation is functional but can be improved for readability and conciseness.
public boolean syncToNamespacesValid(String appId, String namespaceName) {
return syncToNamespaces.stream()
.allMatch(namespaceIdentifier -> appId.equals(namespaceIdentifier.getAppId()) && namespaceName.equals(namespaceIdentifier.getNamespaceName()));
}
What's the purpose of this PR
add namespaces check in synchronization configuration feature
Follow this checklist to help us incorporate your contribution quickly and easily:
mvn clean test
to make sure this pull request doesn't break anything.CHANGES
log.Summary by CodeRabbit
New Features
Bug Fixes