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 aliasfix to fix migrated import paths #6502

Merged
merged 4 commits into from
Aug 24, 2022

Conversation

codyoss
Copy link
Member

@codyoss codyoss commented Aug 10, 2022

This will assist us in the migration effort and is also a tool our users can use.
The tool is allowlisted to only migrate specific imports, and only if we have
made a configuration change to say the code has been migrated.

@product-auto-label product-auto-label bot added the size: xl Pull request size is extra large. label Aug 10, 2022
@hongalex hongalex added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 14, 2022
@codyoss codyoss changed the title feat: add aliasgen to fix migrated import paths feat: add aliasfix to fix migrated import paths Aug 23, 2022
@codyoss codyoss marked this pull request as ready for review August 24, 2022 14:54
@codyoss codyoss requested a review from a team as a code owner August 24, 2022 14:54
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 24, 2022
@codyoss
Copy link
Member Author

codyoss commented Aug 24, 2022

Once merged in a future PR, it may be a good idea to move the mapping file elsewhere or make it public so gapicgen can rely on it too. That way the tools can stay in-sync.

Copy link
Contributor

@noahdietz noahdietz left a comment

Choose a reason for hiding this comment

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

FWIW, the GAPIC generator already does this in that if we give it an "import path override" for the protos its generating, it will know to generate request/response/stub types using the "overridden" import path. This of course does not help with manual clients.

I do realize though that there has to be a time where we generate the stubs in google-cloud-go without changing the type in the signature for the GAPIC, while we do the alias/release dance. Perhaps we need to toggle when the GAPIC generator is made aware of he import path override e.g. decouple it from configuring gapicgen to generate stubs in google-cloud-go. Right now it is coupled (see storage) in that if we want to provide an override, the GAPIC will respect it rather than deferring to go-genproto still.

internal/aliasfix/main.go Show resolved Hide resolved
internal/aliasfix/main.go Show resolved Hide resolved
@codyoss
Copy link
Member Author

codyoss commented Aug 24, 2022

@noahdietz This is supposed to be more of an equivalent to go fix. I fully intend for us to leverage the generator override. This is for updating existing code that references go-genproto.

For example:

  • Users can run this command in their local code to fixup all import paths automatically.
  • We can use this in the samples repo to mass update samples to use new type locations.

@codyoss
Copy link
Member Author

codyoss commented Aug 24, 2022

I do realize though that there has to be a time where we generate the stubs in google-cloud-go without changing the type in the signature for the GAPIC, while we do the alias/release dance. Perhaps we need to toggle when the GAPIC generator is made aware of he import path override e.g. decouple it from configuring gapicgen to generate stubs in google-cloud-go. Right now it is coupled (see storage) in that if we want to provide an override, the GAPIC will respect it rather than deferring to go-genproto still.

You are right. We may be able to accomplish them by just having a toggle in gapicgen to regen in both locations in two different invocations of protoc

@noahdietz
Copy link
Contributor

@noahdietz This is supposed to be more of an equivalent to go fix. I fully intend for us to leverage the generator override. This is for updating existing code that references go-genproto.

For example:

  • Users can run this command in their local code to fixup all import paths automatically.
  • We can use this in the samples repo to mass update samples to use new type locations.

Oh! cool! awesome.

@codyoss codyoss merged commit 7a0e411 into googleapis:main Aug 24, 2022
@codyoss codyoss deleted the aliasfix branch August 24, 2022 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants