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

Support references to external types #16

Closed
lukehoban opened this issue Jul 7, 2022 · 4 comments · Fixed by #21
Closed

Support references to external types #16

lukehoban opened this issue Jul 7, 2022 · 4 comments · Fixed by #21
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@lukehoban
Copy link
Contributor

Pulumi schema can contain references to externally defined types from other packages. This does not yet appear to be supported by this library. In principal it seems like it could be supported either automatically (if package name and version can be identified?) or via some manual mapping information users provide?

This is to support something like this:

"properties": {
                "functions": {
                    "type": "array",
                    "items": {
                        "$ref": "/aws/v4.0.0/schema.json#/resources/aws:lambda%2Ffunction:Function"
                    },
                    "description": "The functions managed by this service."
                },
                "url": {
                    "type": "string",
                    "description": "The API Gateway REST API managed by this service, if any of the functions expose HTTP handlers."
                }
            },

Via something like this:

type Service struct {
	pulumi.ResourceState

	// Outputs
	Url     pulumi.StringPtrOutput `pulumi:"url" provider:"output"`
	Lambdas []*lambda.Function     `pulumi:"lambdas" provider:"output"`

	// Inputs
	Functions FunctionMapInput     `pulumi:"functions"`
	Provider  ServiceProviderInput `pulumi:"provider"`
}
@iwahbe
Copy link
Member

iwahbe commented Jul 7, 2022

We can already do this in theory for types like ServiceProviderOutput. We can implement support for this generically (input+output) by traversing the To*Output of FunctionMapInput and then calling ElementType on an empty instance of that. This should be a transparent experience to users.

@hliuson hliuson linked a pull request Jul 7, 2022 that will close this issue
@lukehoban
Copy link
Contributor Author

#21 definitely addressed other issues (I made more progress on #17 👏 ) - but didn't address the issue described in this issue.

For two reasons I believe:

  1. The code noted above (and commented out in Attempt to port a serverless component to this library #17) triggers panic: Detected pointer type during serialization - did you forget to dereference?.
  2. I'm fairly sure even if that was fixed or worked around, this would run into what's captured in Ensure we generate valid tokens for external types with non-standard tokens #20?

If (2) is the only issue, this could be closed as a dupe of #20, but probably worth reopening this for now? (I can't as I'm not a contributor on this repo 😄).

@hliuson hliuson reopened this Jul 9, 2022
@hliuson
Copy link
Contributor

hliuson commented Jul 9, 2022

I believe this issue is that []*lambda.Function is an array of pointers, not that it's an external type. I've opened a pull request (#23 ) which should address this.

@hliuson hliuson closed this as completed Jul 9, 2022
@iwahbe iwahbe reopened this Jul 9, 2022
@lukehoban lukehoban added kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed labels Jul 28, 2023
@lukehoban
Copy link
Contributor Author

Fixed with #23.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants