-
Notifications
You must be signed in to change notification settings - Fork 235
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
tool: add update-types sync
command to synchronize go types with proto definitions
#3401
Open
jingyih
wants to merge
5
commits into
GoogleCloudPlatform:master
Choose a base branch
from
jingyih:type_updater_sync_tool
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0cdc551
chore: rename type updater to field inserter
jingyih e2b46e2
tool: make insert field a subcommand of update-types
jingyih 62b4ee0
tool: add update-types sync command to sync existing types with proto
jingyih 8543448
chore: run update-types sync for BigQueryDataTransferConfig
jingyih 6973b19
chore: make ready-pr
jingyih File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package codegen | ||
|
||
import "strings" | ||
|
||
const ( | ||
// KCCProtoMessageAnnotation is used for go structs that map to proto messages | ||
KCCProtoMessageAnnotation = "+kcc:proto" | ||
|
||
// KCCProtoFieldAnnotation is used for go struct fields that map to proto fields | ||
KCCProtoFieldAnnotation = "+kcc:proto:field" | ||
|
||
// KCCProtoIgnoreAnnotation is used for go struct fields that are ignored | ||
KCCProtoIgnoreAnnotation = "+kcc:proto:ignore" | ||
) | ||
|
||
// special-case proto messages that are currently not mapped to KRM Go structs | ||
var protoMessagesNotMappedToGoStruct = map[string]string{ | ||
"google.protobuf.Timestamp": "string", | ||
"google.protobuf.Duration": "string", | ||
"google.protobuf.Int64Value": "int64", | ||
"google.protobuf.StringValue": "string", | ||
"google.protobuf.Struct": "map[string]string", | ||
} | ||
|
||
var Acronyms = []string{ | ||
"ID", "HTML", "URL", "HTTP", "HTTPS", "SSH", | ||
"IP", "GB", "FS", "PD", "KMS", "GCE", "VTPM", | ||
} | ||
|
||
// IsAcronym returns true if the given string is an acronym | ||
func IsAcronym(s string) bool { | ||
for _, acronym := range Acronyms { | ||
if strings.EqualFold(s, acronym) { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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 previously added the
scheduleOptionsV2
field manually using the field comments from [1]. However, the correct field comments is [2]. Only a slight difference between the two.[1] https://github.com/googleapis/googleapis/blob/f4b02617cbc3db919fa05c5ad782ef211dd90889/google/cloud/bigquery/datatransfer/v1/transfer.proto#L101-L104
[2] https://github.com/googleapis/googleapis/blob/f4b02617cbc3db919fa05c5ad782ef211dd90889/google/cloud/bigquery/datatransfer/v1/transfer.proto#L231-L234