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

tool: add update-types sync command to synchronize go types with proto definitions #3401

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jingyih
Copy link
Collaborator

@jingyih jingyih commented Dec 17, 2024

Add a new command update-types sync that synchronizes existing Go types with corresponding proto definitions (at the pinned version). This ensures that Go field types and comments stay in sync with the proto definitions while preserving:

  • Special annotations (e.g. // +required, // +kubebuilder:xxx)
  • Reference fields
  • Manual edits

Example usage

go run . update-types sync \
  --service google.cloud.bigquery.datatransfer.v1 \
  --api-version bigquerydatatransfer.cnrm.cloud.google.com/v1beta1 \
  --legacy-mode

Use the --legacy-mode flag for resources that were previously generated with KRM fields without the // +kcc:proto annotations.

Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign maqiuyujoyce for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jingyih jingyih force-pushed the type_updater_sync_tool branch 2 times, most recently from 967b9e4 to 00988c1 Compare December 18, 2024 09:50
@jingyih jingyih changed the title WIP: "update-types sync tool: Add update-types sync command to synchronize Go types with proto definitions Dec 18, 2024
@jingyih jingyih changed the title tool: Add update-types sync command to synchronize Go types with proto definitions tool: add update-types sync command to synchronize go types with proto definitions Dec 18, 2024
schedule. This field supports existing time-based and manual transfer
schedule. Also supports Event-Driven transfer schedule. ScheduleOptionsV2
cannot be used together with ScheduleOptions/Schedule.
description: Options customizing different types of data transfer
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jingyih jingyih force-pushed the type_updater_sync_tool branch from 31cd34f to 16f0059 Compare December 18, 2024 21:45
@jingyih
Copy link
Collaborator Author

jingyih commented Dec 18, 2024

Rebased to pick up the fix for the broken HEAD.

Add a new command 'update-types sync' that synchronizes existing Go types
with their proto definitions. This ensures that Go field types and comments
stay in sync with the proto definitions while preserving:
- Special annotations (e.g. +required)
- Reference fields
- Ignored fields
- Manual edits
go run . update-types sync \
    --service google.cloud.bigquery.datatransfer.v1 \
    --api-version bigquerydatatransfer.cnrm.cloud.google.com/v1beta1 \
    --legacy-mode

${REPO_ROOT}/dev/tasks/fix-gofmt
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.

1 participant