Skip to content

Conversation

@melinath
Copy link
Member

This allows us to preserve the exact API field name in metadata while still being able to programmatically derive the terraform field name. Since conversion to terraform name is lossy, we can't reliably go the other direction.

This PR only handles generated meta.yaml files. If this approach works, I'll handle the handwritten files separately later.

Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.


This allows us to preserve the exact API field name in metadata while still being able to programmatically derive the terraform field name. Since conversion to terraform name is lossy, we can't reliably go the other direction.
@melinath melinath requested a review from roaks3 July 31, 2025 22:24
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 643 files changed, 13979 insertions(+), 13979 deletions(-))
google-beta provider: Diff ( 696 files changed, 14905 insertions(+), 14905 deletions(-))

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 643 files changed, 14011 insertions(+), 14011 deletions(-))
google-beta provider: Diff ( 696 files changed, 14937 insertions(+), 14937 deletions(-))

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

Copy link
Contributor

@roaks3 roaks3 left a comment

Choose a reason for hiding this comment

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

I think we may want to update docs/content/reference/metadata.md, at least slightly. api_field will now be camelcased, and I assume field will default to the snakecased version of api_field?

Also:

Since conversion to terraform name is lossy, we can't reliably go the other direction

Could you clarify, or possibly have an example to share?

Everything else LGTM (including a scan of the results)

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions github-actions bot closed this Oct 2, 2025
@melinath melinath reopened this Oct 2, 2025
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 654 files changed, 14391 insertions(+), 14391 deletions(-))
google-beta provider: Diff ( 711 files changed, 15396 insertions(+), 15396 deletions(-))

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 654 files changed, 14391 insertions(+), 14391 deletions(-))
google-beta provider: Diff ( 711 files changed, 15396 insertions(+), 15396 deletions(-))

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 658 files changed, 14465 insertions(+), 14465 deletions(-))
google-beta provider: Diff ( 718 files changed, 15515 insertions(+), 15515 deletions(-))

@melinath
Copy link
Member Author

I think we may want to update docs/content/reference/metadata.md, at least slightly. api_field will now be camelcased, and I assume field will default to the snakecased version of api_field?

Done. Yes, those are the changes.

Since conversion to terraform name is lossy, we can't reliably go the other direction

Could you clarify, or possibly have an example to share?

Conversion to terraform name uses this function:

func Underscore(source string) string {
tmp := regexp.MustCompile(`([A-Z]+)([A-Z][a-z])`).ReplaceAllString(source, "${1}_${2}")
tmp = regexp.MustCompile(`([a-z\d])([A-Z])`).ReplaceAllString(tmp, "${1}_${2}")
tmp = strings.Replace(tmp, "-", "_", 1)
tmp = strings.Replace(tmp, ".", "_", 1)
tmp = strings.ToLower(tmp)
return tmp
}

It looks like we don't have any fields that contain . or - in their API names, so the fact those get collapsed doesn't matter (unless fields like that are added in the future).

However, we can't tell the difference between fields like IPAddress vs IpAddress - both would be converted to ip_address. Examples: InterconnectAttachment has cloudRouterIpAddress, but RegionBackendService has fastIPMove.

@melinath melinath requested a review from roaks3 October 15, 2025 00:03
Copy link
Contributor

@roaks3 roaks3 left a comment

Choose a reason for hiding this comment

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

However, we can't tell the difference between fields like IPAddress vs IpAddress - both would be converted to ip_address. Examples: InterconnectAttachment has cloudRouterIpAddress, but RegionBackendService has fastIPMove.

Ah right, the acronym handling makes it lossy. Thanks for explaining!

@melinath melinath added this pull request to the merge queue Oct 15, 2025
Merged via the queue into GoogleCloudPlatform:main with commit 42b9e5c Oct 15, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants