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

Allow specifying dependencies for output invokes #693

Merged
merged 7 commits into from
Dec 13, 2024
Merged

Conversation

julienp
Copy link
Contributor

@julienp julienp commented Nov 20, 2024

Provider functions that take inputs as arguments, and return an output (aka output invokes), now allow specifying a dependsOn option. This allows programs to ensure that invokes are executed after things they depend on, similar to the depdendsOn resource option.

pulumi/pulumi#17710

Fixes pulumi/pulumi#17755

@julienp julienp marked this pull request as ready for review November 22, 2024 12:29
@julienp julienp requested a review from a team as a code owner November 22, 2024 12:29
@julienp julienp changed the title Allow specifiying dependencies for output invokes Allow specifying dependencies for output invokes Dec 4, 2024
if err != nil {
return e.error(t, err.Error())
}

if t.Return.GetValue() == "" {
output := pulumi.OutputWithDependencies(context.TODO(), pulumi.Any(result), deps...)
Copy link
Contributor

Choose a reason for hiding this comment

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

e.pulumiCtx has a .Context() which might be a good thing to hang this off, rather than TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, there's another call to context.TODO just above in the call to ResolveFunction, I'll update that one too.

}

retv, ok := result[t.Return.Value]
if !ok {
e.error(t.Return, fmt.Sprintf("Unable to evaluate result[%v], result is: %+v", t.Return.Value, t.Return))
return e.error(t.Return, fmt.Sprintf("fn::invoke of %s did not contain a property '%s' in the returned value", t.Token.Value, t.Return.Value))
}

output := pulumi.OutputWithDependencies(context.TODO(), pulumi.Any(retv), deps...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thoughts about context.TODO here.

@@ -216,7 +216,7 @@ runtime: yaml
requireNoErrors(t, tmpl, diags)
}

func TestInvokeReturningSecrets(t *testing.T) {
func TestInvokeReturningSecretsWithReturn(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the best name change? I'm guessing one is testing plain, the other outputs? Or is it something different? It's not super clear to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's not super clear. This test has a return property on the invoke on like 229, so the test covers the if t.Return.GetValue() == "" { branch above, whereas the other test returns the whole response, covering the rest of the changes in that file.

@julienp julienp force-pushed the julienp/depends-on branch 2 times, most recently from 64c7865 to 3c287a0 Compare December 10, 2024 14:03
go.mod Outdated
Comment on lines 15 to 16
github.com/pulumi/pulumi/pkg/v3 v3.142.1-0.20241210130857-42257d81376e
github.com/pulumi/pulumi/sdk/v3 v3.142.1-0.20241210130857-42257d81376e
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO @julienp update on next pu/pu release

@julienp julienp force-pushed the julienp/depends-on branch 2 times, most recently from f0ccee2 to 769eea4 Compare December 11, 2024 12:00
@julienp julienp merged commit 8ee6ffa into main Dec 13, 2024
6 checks passed
@julienp julienp deleted the julienp/depends-on branch December 13, 2024 11:31
@julienp julienp mentioned this pull request Dec 17, 2024
julienp added a commit that referenced this pull request Dec 17, 2024
## v1.13.0 - 2024-12-17

### Improvements

- [runtime] Allow specifying dependencies for output invokes
[#693](#693)

- [runtime] Update to pulumi v3.143.0
[#700](#700)

### Bug Fixes

- [runtime] Fix the language plugin to return a version
[#682](#682)

- [runtime] Fix a mixup between package names and plugin names when
listing required plugins
[#688](#688)

- [runtime] Resource properties marked as secret in schema are now sent
as secrets [#698](#698)

- [convert] Emit invoke options to PCL when ejecting YAML templates
[#697](#697)
@pulumi-bot
Copy link

This PR has been shipped in release v1.13.0.

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.

YAML: DependsOn for Provider Functions
3 participants