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] pulumi imports are incorrectly using pulumi-kubernetes #12624

Closed
phillipedwards opened this issue Apr 6, 2023 · 4 comments · Fixed by #12669
Closed

[codegen] pulumi imports are incorrectly using pulumi-kubernetes #12624

phillipedwards opened this issue Apr 6, 2023 · 4 comments · Fixed by #12669
Assignees
Labels
area/codegen SDK-gen, program-gen, convert area/component-packages aka multi-language components customer/lighthouse Lighthouse customer bugs kind/bug Some behavior is incorrect or out of spec language/python resolution/fixed This issue was fixed
Milestone

Comments

@phillipedwards
Copy link
Member

What happened?

A type in a MLC schema file with kubernetes:...:... is automatically assumed to be from pulumi-kubernetes and is referenced as such in the generated python SDK.

Expected Behavior

Imports should be generated correctly as in the other languages.

Steps to reproduce

  1. git clone https://github.com/phillipedwards/pulumi-aws-s3-replicated-bucket.git
  2. git checkout k8s-python-import
  3. make generate
  4. open sdk/python/pulumi-aws-s3-replicated-bucket/replicated_bucket.py
  5. specifically, look at the import for from pulumi-kubernetes import gcp as _gcp
  6. also view the location_policy getter which utilizes a type which does not exist.

Import statement
https://github.com/phillipedwards/pulumi-aws-s3-replicated-bucket/blob/f08cfb9caaa93cb185021535a2c5d7d4073cd3d3/sdk/python/pulumi_aws_s3_replicated_bucket/replicated_bucket.py#L11

getter function
https://github.com/phillipedwards/pulumi-aws-s3-replicated-bucket/blob/f08cfb9caaa93cb185021535a2c5d7d4073cd3d3/sdk/python/pulumi_aws_s3_replicated_bucket/replicated_bucket.py#L113

Output of pulumi about

CLI
Version 3.60.1
Go Version go1.20.2
Go Compiler gc

Host
OS ubuntu
Version 22.04
Arch x86_64

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@phillipedwards phillipedwards added kind/bug Some behavior is incorrect or out of spec language/python needs-triage Needs attention from the triage team customer/lighthouse Lighthouse customer bugs labels Apr 6, 2023
@AaronFriel
Copy link
Member

The type kubernetes:gcp/gke:NodePoolAutoscaling is a bit confusing, and the type ref seems off.

I think you want the type ref to be like described in Pulumi Schema: https://www.pulumi.com/docs/guides/pulumi-packages/schema/

            "properties": {
                "url": {
                    "type": "string"
                },
                "api": {
                    "$ref": "/aws/v3.30.0/schema.json#/resources/aws:apigateway%2FrestApi:RestApi"
                }
            },

And you would then not declare that type in the types section. I'm not sure what it would mean if any token in types or resources or functions to not be prefixed by the package name.

@phillipedwards
Copy link
Member Author

The example is not about the type; it could be any arbitrary simple or complex type and the mismatched python (and dotnet) output would be the same. This nonsense example is about the token.

I'm taking two things away from your comment:

  1. you cannot (should not?) have a token in a MLC prefixed with something other than package name
  2. codegen can automatically assume a token that is prefixed with aws, gcp, or kubernetes to be a part of their respective pulumi packages.

At any rate, go and ts behave as I would expect and handle the token in question appropriately, while dotnet and python do not. This still feels like a codegen issue to me, for the simple fact that the python sdk injects pulumi_kubernetes where the token reads kubernetes:..:....

@dixler dixler added area/component-packages aka multi-language components area/codegen SDK-gen, program-gen, convert and removed needs-triage Needs attention from the triage team labels Apr 7, 2023
@tusharshahrs
Copy link
Member

@justinvp
Copy link
Member

I took a quick look and think I understand what the problem is. WIP PR: #12669

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen SDK-gen, program-gen, convert area/component-packages aka multi-language components customer/lighthouse Lighthouse customer bugs kind/bug Some behavior is incorrect or out of spec language/python resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants