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

Rewrite Construct handling in line with Call #276

Open
iwahbe opened this issue Sep 23, 2024 · 0 comments
Open

Rewrite Construct handling in line with Call #276

iwahbe opened this issue Sep 23, 2024 · 0 comments
Labels
1.0.0-blocker An issue that must be resolved before 1.0.0 impact/breaking Fixing this issue will require a breaking change kind/enhancement Improvements or new features

Comments

@iwahbe
Copy link
Member

iwahbe commented Sep 23, 2024

The interface provided by provider.Provider.Construct is extremely hard to work with and test against. The interface was "designed" during hack-week and was thus extremely rushed.

pulumi-go-provider/provider.go

Lines 1033 to 1044 in c63d6b6

type ConstructRequest struct {
URN presource.URN
Preview bool
Construct func(context.Context, ConstructFunc) (ConstructResponse, error)
}
type ConstructFunc = func(
*pulumi.Context, comProvider.ConstructInputs, pulumi.ResourceOption,
) (pulumi.ComponentResource, error)
type ConstructResponse struct{ inner *rpc.ConstructResponse }

Downsides are:

provider.Provider.Call has a lot of the same constraints, but a much more reasonable interface:

// CallRequest represents a requested resource method invocation.
//
// It corresponds to [rpc.CallRequest] on the wire.
type CallRequest struct {
Tok tokens.ModuleMember
Args presource.PropertyMap
Context *pulumi.Context
}
// CallResponse represents a completed resource method invocation.
//
// It corresponds to [rpc.CallResponse] on the wire.
type CallResponse struct {
// The returned values, if the call was successful.
Return presource.PropertyMap
// The failures if any arguments didn't pass verification.
Failures []CheckFailure
}

Note that Call has the same set of constraints as Construct, but there was more time spent doing design work.

To make it easier/possible to support #82, #219 and #266, we should re-write Construct in the same style as Call.

This will be a breaking change, so it must go in before 1.0.0. This should not effect infer based component, since they are authored at a higher level. It will effect how infer implements components, and will enable better error messages (or even fixes) to issues like #270.

@iwahbe iwahbe added 1.0.0-blocker An issue that must be resolved before 1.0.0 impact/breaking Fixing this issue will require a breaking change labels Sep 23, 2024
@mikhailshilkov mikhailshilkov added the kind/enhancement Improvements or new features label Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0.0-blocker An issue that must be resolved before 1.0.0 impact/breaking Fixing this issue will require a breaking change kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

2 participants