-
Notifications
You must be signed in to change notification settings - Fork 42
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
Basic runtime support for dynamic providers #2102
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2102 +/- ##
==========================================
- Coverage 60.76% 60.74% -0.03%
==========================================
Files 350 350
Lines 45686 45711 +25
==========================================
+ Hits 27762 27768 +6
- Misses 16405 16425 +20
+ Partials 1519 1518 -1 ☔ View full report in Codecov by Sentry. |
info = providerInfo(ctx, tfServer) | ||
} | ||
|
||
err = pfbridge.XParameterizeResetProvider(ctx, info, metadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the variable which contains the lambda? Is it passed as a reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If your talking about the lambda introduced in provider.go:
pulumi-terraform-bridge/pf/tfbridge/provider.go
Lines 213 to 222 in 8c172bf
ctx = context.WithValue(ctx, xResetProviderKey{}, | |
func(ctx context.Context, info tfbridge.ProviderInfo, meta ProviderMetadata) error { | |
pp, err := newProviderWithContext(ctx, info, meta) | |
if err != nil { | |
return err | |
} | |
*p = *pp | |
return nil | |
}) | |
Then ctx
is the variable which contains the lambda. XParameterizeResetProvider
unpacks the lambda from ctx
and then calls it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The metadata
used on this line comes from line 51, as far as I can see, right?
The same metadata
also contains this function which captures it.
It looks a bit odd and I was wondering if it's passed as a reference for this to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think I know what you mean. In Go, lambdas always have access to the location of variables in their scope. If your familiar with C++, then lambdas close over the lvalue of variables they reference.
34d34e7
to
36c0398
Compare
This PR replaces the
.Replace
method with a sounder construct:XParameterizeResetProvider
.ProposeNew
.XParameterizeResetProvider
works, a level of interface indirection was removed.