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

[codegen/go] Support foreign enum types #9920

Merged
merged 4 commits into from Jun 22, 2022

Conversation

iwahbe
Copy link
Member

@iwahbe iwahbe commented Jun 21, 2022

Description

Fixes #9916

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • Yes, there are changes in this PR that warrants bumping the Pulumi Service API version

@iwahbe iwahbe self-assigned this Jun 21, 2022
@iwahbe iwahbe requested review from dixler, nimbinatus and t0yv0 and removed request for nimbinatus June 21, 2022 23:13
@pulumi-bot
Copy link
Contributor

Please view the results of the Downstream Codegen Tests Here

@pulumi-bot
Copy link
Contributor

Please view the results of the Downstream Codegen Tests Here

switch t := t.(type) {
case *schema.OptionalType:
pkg.getTypeImports(t.ElementType, recurse, importsAndAliases, seen)
case *schema.InputType:
pkg.getTypeImports(t.ElementType, recurse, importsAndAliases, seen)
case *schema.EnumType:
if importExternal(t.Token) {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the line immediately below it try to handle externals also?

mod := pkg.tokenToPackage(t.Token)
if mod != pkg.mod  // here

I wonder if that is now redundant (dead code)?

Copy link
Member Author

@iwahbe iwahbe Jun 22, 2022

Choose a reason for hiding this comment

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

It shouldn't be. Notice that we are comparing mod instead of pkg. This is us handling enums from other modules (but the same pkg). When we check for external, we compare via pkg:

case *schema.EnumType:
isExternal = pkg.pkg != nil && typ.Package != pkg.pkg

Copy link
Member

Choose a reason for hiding this comment

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

Ah thanks.

TypeLocalInsteadOfRemoteAlias gcpiamv1.AuditConfig `pulumi:"typeLocalInsteadOfRemoteAlias"`
TypeNoAlias s3.BucketWebsite `pulumi:"typeNoAlias"`
TypeRemoteAlias dns.DnsKeySpec `pulumi:"typeRemoteAlias"`
TypeRemoteEnum *accesscontextmanager.DevicePolicyAllowedDeviceManagementLevelsItem `pulumi:"typeRemoteEnum"`
Copy link
Member

Choose a reason for hiding this comment

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

Nice

Copy link
Member

@t0yv0 t0yv0 left a comment

Choose a reason for hiding this comment

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

Great!

@iwahbe iwahbe merged commit 0a53252 into master Jun 22, 2022
@pulumi-bot pulumi-bot deleted the iwahbe/9916/go-handle-external-enums branch June 22, 2022 15:57
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.

[codegen/go] Invalid imports for foreign enums
3 participants