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

feat: add field annotations merging functionality #83

Merged
merged 2 commits into from
Apr 13, 2022

Conversation

vam-google
Copy link
Collaborator

No description provided.

@vam-google vam-google requested review from a team as code owners April 13, 2022 02:06
Copy link
Collaborator

@vchudnov-g vchudnov-g left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for implementing this!

// - Missing field in a new proto file
// - Missing values in enums
// - Mismatching service method google.api.method_signature option values
// - missing field in a new proto file;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Aren't these all "old overwrites new"? Maybe we should just have a mention right before the list: "carrying over elements from the old version of the proto into the new version when doing a pure conversion would result in those elements being missing or mismatched"

newMessage.getFields().add(copyField(null, oldField, newMessages));
} else {
Field newField = newFieldsMap.get(oldField.getName());
// Copy missing options if a new field has less options than old field.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitty nits: s/less/fewer/; s/new field/newField/ s/old field/oldField/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a very nitty nit =)

} else {
Field newField = newFieldsMap.get(oldField.getName());
// Copy missing options if a new field has less options than old field.
// This is a very primitive merge logic. Add a proper merge logic if ever needed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider making this comment a TODO.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The merger is basically written (and it matches the comment at the top of the merger class), that it merges only what is required and there are many potentially missing functions, which are expected to be added if needed. This specific case is not special compared to others, that is why I guess having todo for this one but not having for others would be weird.

@@ -327,7 +327,7 @@ message DeleteAddressRequest {
// For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments.
//
// The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).
optional string request_id = 37109963;
optional string request_id = 37109963 [(google.api.field_behavior) = REQUIRED];
Copy link
Collaborator

Choose a reason for hiding this comment

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

I made the mistake of not removing the proto3_optional label in my original PR, and had to fix it here googleapis/googleapis#712. Can we exclude such a label if the field_behavior is REQUIRED?

Copy link
Collaborator

Choose a reason for hiding this comment

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

(totally meant to send this comment this morning but didn't press the button)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This logic just preserves the old situation - if it was optional, then it will remain optional, if it idid not have optional, it will remain non-optional. This specific thing is just a test. I modified the test data to represent better the actual case in GCE.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Awesome, thanks!

@vam-google vam-google merged commit c47a76d into googleapis:main Apr 13, 2022
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.

3 participants