Skip to content
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

DGS-8783 Add rulesToMerge/rulesToRemove to tags API #2789

Merged
merged 3 commits into from Oct 14, 2023

Conversation

rayokota
Copy link
Member

@rayokota rayokota commented Oct 13, 2023

Add rulesToMerge/rulesToRemove to tags API

@rayokota rayokota requested a review from a team as a code owner October 13, 2023 18:29
Copy link
Member

@karthikeyanas karthikeyanas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rayokota.

Map<String, String> headerProperties = requestHeaderBuilder.buildRequestHeaders(
headers, schemaRegistry.config().whitelistHeaders());
RegisterSchemaResponse registerSchemaResponse;
try {
RuleSet ruleSet = request.getRuleSet();
if (request.getRulesToMerge() != null || request.getRulesToRemove() != null) {
int oldVersion = request.getNewVersion() != null ? request.getNewVersion() - 1 : -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does -1 mean latest version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

}

@JsonProperty("rulesToMerge")
public void setRulesToMerge(RuleSet rulesToMerge) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not take List as a parameter? Or should we call it setRuleSetToMerge?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member Author

@rayokota rayokota Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rulesToMerge takes a RuleSet, and rulesToRemove takes a list of rule names. By "rules" I'm referring to the object semantically, not to the data structure that is passed in. I'd rather not call it ruleSetToMerge and ruleNamesToRemove

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO I think rulesToRemove is better than ruleNamesToRemove. But I think ruleSetToMerge might better than rulesToMerge. However, it seems like the field that the customer sets is rulesToMerge. What do you think about changing that json field to ruleSetToMerge since it has the same attributes as the existing ruleSet field?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep it rulesToMerge. In any case, this API may be temporary.

// Use the previous ruleSet instead of the passed in one
ruleSet = oldSchema != null ? oldSchema.getRuleSet() : null;
if (request.getRulesToMerge() != null) {
ruleSet = mergeRuleSets(ruleSet, request.getRulesToMerge());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change the ordering of the rules? If so does that matter? I remember you mentioning that the order of the ruse matter.

It seems like merging the rules would remove any existing role that has the same name as any rule in rulesToMerge, then add rulesToMerge at the end of the rules list.

Copy link
Member Author

@rayokota rayokota Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this code will prefer the order of the rulesToAdd ruleSet over the existing ruleSet. I think this is fine for encryption rules, which is what this API is meant to be used for currently.

Copy link
Member

@karthikeyanas karthikeyanas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rayokota

@rayokota rayokota merged commit fa5db1b into confluentinc:7.4.x Oct 14, 2023
4 checks passed
@rayokota rayokota deleted the DGS-8783 branch October 14, 2023 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants