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 component resources to inherit providers
from component resources
#10933
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...pending/20221005--sdk-dotnet-go-nodejs-python--component-resources-inherit-providers.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
changes: | ||
- type: fix | ||
scope: cli/engine | ||
description: Component Resources inherit thier parents providers map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -41,7 +41,7 @@ func NewResource(ctx *pulumi.Context, name string, echo pulumi.Input, | |||
opts ...pulumi.ResourceOption) (*Resource, error) { | ||||
args := &ResourceArgs{Echo: echo} | ||||
var resource Resource | ||||
err := ctx.RegisterResource("testcomponent:index:Resource", name, args, &resource, opts...) | ||||
err := ctx.RegisterResource(providerName+":index:Resource", name, args, &resource, opts...) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see providerName declared in here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its declared on line 104.
|
||||
if err != nil { | ||||
return nil, err | ||||
} | ||||
|
@@ -76,7 +76,7 @@ func NewComponent(ctx *pulumi.Context, name string, args *ComponentArgs, | |||
secret := conf.RequireSecret(secretKey) | ||||
|
||||
component := &Component{} | ||||
err := ctx.RegisterComponentResource("testcomponent:index:Component", name, component, opts...) | ||||
err := ctx.RegisterComponentResource(providerName+":index:Component", name, component, opts...) | ||||
if err != nil { | ||||
return nil, err | ||||
} | ||||
|
@@ -115,28 +115,35 @@ func main() { | |||
} | ||||
} | ||||
|
||||
type testcomponentProvider struct { | ||||
type Provider struct { | ||||
host *provider.HostClient | ||||
name string | ||||
version string | ||||
|
||||
expectResourceArg bool | ||||
} | ||||
|
||||
func makeProvider(host *provider.HostClient, name, version string) (pulumirpc.ResourceProviderServer, error) { | ||||
return &testcomponentProvider{ | ||||
return &Provider{ | ||||
host: host, | ||||
name: name, | ||||
version: version, | ||||
}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) Create(ctx context.Context, | ||||
func (p *Provider) Create(ctx context.Context, | ||||
req *pulumirpc.CreateRequest) (*pulumirpc.CreateResponse, error) { | ||||
urn := resource.URN(req.GetUrn()) | ||||
typ := urn.Type() | ||||
if typ != "testcomponent:index:Resource" { | ||||
if typ != providerName+":index:Resource" { | ||||
return nil, fmt.Errorf("Unknown resource type '%s'", typ) | ||||
} | ||||
|
||||
if s, ok := req.GetProperties().Fields["echo"].AsInterface().(string); ok && | ||||
s == "checkExpected" && !p.expectResourceArg { | ||||
return nil, fmt.Errorf("did not receive configured provider") | ||||
} | ||||
|
||||
id := currentID | ||||
currentID++ | ||||
|
||||
|
@@ -145,12 +152,12 @@ func (p *testcomponentProvider) Create(ctx context.Context, | |||
}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) Construct(ctx context.Context, | ||||
func (p *Provider) Construct(ctx context.Context, | ||||
req *pulumirpc.ConstructRequest) (*pulumirpc.ConstructResponse, error) { | ||||
return pulumiprovider.Construct(ctx, req, p.host.EngineConn(), func(ctx *pulumi.Context, typ, name string, | ||||
inputs pulumiprovider.ConstructInputs, options pulumi.ResourceOption) (*pulumiprovider.ConstructResult, error) { | ||||
|
||||
if typ != "testcomponent:index:Component" { | ||||
if typ != providerName+":index:Component" { | ||||
return nil, fmt.Errorf("unknown resource type %s", typ) | ||||
} | ||||
|
||||
|
@@ -168,82 +175,85 @@ func (p *testcomponentProvider) Construct(ctx context.Context, | |||
}) | ||||
} | ||||
|
||||
func (p *testcomponentProvider) CheckConfig(ctx context.Context, | ||||
func (p *Provider) CheckConfig(ctx context.Context, | ||||
req *pulumirpc.CheckRequest) (*pulumirpc.CheckResponse, error) { | ||||
return &pulumirpc.CheckResponse{Inputs: req.GetNews()}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) DiffConfig(ctx context.Context, | ||||
func (p *Provider) DiffConfig(ctx context.Context, | ||||
req *pulumirpc.DiffRequest) (*pulumirpc.DiffResponse, error) { | ||||
return &pulumirpc.DiffResponse{}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) Configure(ctx context.Context, | ||||
func (p *Provider) Configure(ctx context.Context, | ||||
req *pulumirpc.ConfigureRequest) (*pulumirpc.ConfigureResponse, error) { | ||||
if _, ok := req.GetArgs().Fields["expectResourceArg"]; ok { | ||||
p.expectResourceArg = true | ||||
} | ||||
return &pulumirpc.ConfigureResponse{ | ||||
AcceptSecrets: true, | ||||
SupportsPreview: true, | ||||
AcceptResources: true, | ||||
}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) Invoke(ctx context.Context, | ||||
func (p *Provider) Invoke(ctx context.Context, | ||||
req *pulumirpc.InvokeRequest) (*pulumirpc.InvokeResponse, error) { | ||||
return nil, fmt.Errorf("Unknown Invoke token '%s'", req.GetTok()) | ||||
} | ||||
|
||||
func (p *testcomponentProvider) StreamInvoke(req *pulumirpc.InvokeRequest, | ||||
func (p *Provider) StreamInvoke(req *pulumirpc.InvokeRequest, | ||||
server pulumirpc.ResourceProvider_StreamInvokeServer) error { | ||||
return fmt.Errorf("Unknown StreamInvoke token '%s'", req.GetTok()) | ||||
} | ||||
|
||||
func (p *testcomponentProvider) Call(ctx context.Context, | ||||
func (p *Provider) Call(ctx context.Context, | ||||
req *pulumirpc.CallRequest) (*pulumirpc.CallResponse, error) { | ||||
return nil, fmt.Errorf("Unknown Call token '%s'", req.GetTok()) | ||||
} | ||||
|
||||
func (p *testcomponentProvider) Check(ctx context.Context, | ||||
func (p *Provider) Check(ctx context.Context, | ||||
req *pulumirpc.CheckRequest) (*pulumirpc.CheckResponse, error) { | ||||
return &pulumirpc.CheckResponse{Inputs: req.News, Failures: nil}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) Diff(ctx context.Context, req *pulumirpc.DiffRequest) (*pulumirpc.DiffResponse, error) { | ||||
func (p *Provider) Diff(ctx context.Context, req *pulumirpc.DiffRequest) (*pulumirpc.DiffResponse, error) { | ||||
return &pulumirpc.DiffResponse{}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) Read(ctx context.Context, req *pulumirpc.ReadRequest) (*pulumirpc.ReadResponse, error) { | ||||
func (p *Provider) Read(ctx context.Context, req *pulumirpc.ReadRequest) (*pulumirpc.ReadResponse, error) { | ||||
return &pulumirpc.ReadResponse{ | ||||
Id: req.GetId(), | ||||
Properties: req.GetProperties(), | ||||
}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) Update(ctx context.Context, | ||||
func (p *Provider) Update(ctx context.Context, | ||||
req *pulumirpc.UpdateRequest) (*pulumirpc.UpdateResponse, error) { | ||||
return &pulumirpc.UpdateResponse{ | ||||
Properties: req.GetNews(), | ||||
}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) Delete(ctx context.Context, req *pulumirpc.DeleteRequest) (*pbempty.Empty, error) { | ||||
func (p *Provider) Delete(ctx context.Context, req *pulumirpc.DeleteRequest) (*pbempty.Empty, error) { | ||||
return &pbempty.Empty{}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) GetPluginInfo(context.Context, *pbempty.Empty) (*pulumirpc.PluginInfo, error) { | ||||
func (p *Provider) GetPluginInfo(context.Context, *pbempty.Empty) (*pulumirpc.PluginInfo, error) { | ||||
return &pulumirpc.PluginInfo{ | ||||
Version: p.version, | ||||
}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) Attach(ctx context.Context, req *pulumirpc.PluginAttach) (*pbempty.Empty, error) { | ||||
func (p *Provider) Attach(ctx context.Context, req *pulumirpc.PluginAttach) (*pbempty.Empty, error) { | ||||
return &pbempty.Empty{}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) GetSchema(ctx context.Context, | ||||
func (p *Provider) GetSchema(ctx context.Context, | ||||
req *pulumirpc.GetSchemaRequest) (*pulumirpc.GetSchemaResponse, error) { | ||||
return &pulumirpc.GetSchemaResponse{}, nil | ||||
} | ||||
|
||||
func (p *testcomponentProvider) Cancel(context.Context, *pbempty.Empty) (*pbempty.Empty, error) { | ||||
func (p *Provider) Cancel(context.Context, *pbempty.Empty) (*pbempty.Empty, error) { | ||||
return &pbempty.Empty{}, nil | ||||
} |
2 changes: 2 additions & 0 deletions
2
tests/integration/construct_component/testcomponent2-go/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pulumi-resource-secondtestcomponent | ||
pulumi-resource-secondtestcomponent.exe |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is just "not custom" now isn't it? Resources are either LocalComponent, RemoteComponent, or Custom (remote=true, custom=true should be inexpressible). Also is a similar change not needed in the dotnet code?
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.
I couldn't find the equivalent logic. It is just a branch on
custom
:pulumi/sdk/dotnet/Pulumi/Resources/Resource.cs
Lines 221 to 259 in 85cfd79
.NET should work as is.