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

Passing a foreign resource argument should work, or error gracefully #99

Open
iwahbe opened this issue Jul 17, 2023 · 0 comments
Open
Labels
kind/bug Some behavior is incorrect or out of spec

Comments

@iwahbe
Copy link
Member

iwahbe commented Jul 17, 2023

What happened?

I tried to create the schema for the random-login provider with this patch:

 examples/random-login/main.go | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/examples/random-login/main.go b/examples/random-login/main.go
index b3b0ba8..7e406fe 100644
--- a/examples/random-login/main.go
+++ b/examples/random-login/main.go
@@ -41,7 +41,8 @@ func provider() p.Provider {
 // like this structure is only implementable in typescript, but that will need to change.
 type MoreRandomPassword struct{}
 type MoreRandomPasswordArgs struct {
-	Length *random.RandomInteger `pulumi:"length" provider:"[email protected]:index/randomInteger:RandomInteger"`
+	Length       *random.RandomInteger      `pulumi:"length" provider:"[email protected]:index/randomInteger:RandomInteger"`
+	PasswordArgs *random.RandomPasswordArgs `pulumi:"pArgs,optional"`
 }
 
 type MoreRandomPasswordState struct {
@@ -59,9 +60,11 @@ func (r *MoreRandomPassword) Construct(ctx *pulumi.Context, name, typ string, ar
 		return nil, err
 	}
 
-	pArgs := &random.RandomPasswordArgs{
-		Length: args.Length.Result,
+	pArgs := args.PasswordArgs
+	if pArgs == nil {
+		pArgs = new(random.RandomPasswordArgs)
 	}
+	pArgs.Length = args.Length.Result
 
 	pctx := infer.CtxFromPulumiContext(ctx)
 	config := infer.GetConfig[Config](pctx)

When I called GetSchema on the provider, I got:

--- FAIL: TestSchema (0.00s)
    main_test.go:137: 
                Error Trace:    /Users/ianwahbe/go/src/github.com/pulumi/pulumi-go-provider/examples/random-login/main_test.go:137
                Error:          Received unexpected error:
                                1 error occurred:
                                        * failed to get schema for 'random-login:index:MoreRandomPassword': 1 error occurred:
                                        * could not serialize input type main.MoreRandomPasswordArgs: invalid type 'random.RandomPasswordArgs' on 'main.MoreRandomPasswordArgs.PasswordArgs': RandomPasswordArgs is an input type, but does not have a ToRandomPasswordArgsOutput method

Expected Behavior

I expect this type to be registered into the schema of random-login. I want this type to be injected into the schema instead of referenced because *Args types are not in the pulumi schema.

Steps to reproduce

See example from commit 6034a2c.

Output of pulumi about

NA

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).

@iwahbe iwahbe added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team and removed needs-triage Needs attention from the triage team labels Jul 17, 2023
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
Projects
None yet
Development

No branches or pull requests

1 participant