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

GetMapping should only return for the 'tf' key #662

Merged
merged 1 commit into from Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions pkg/tfbridge/provider.go
Expand Up @@ -1253,15 +1253,20 @@ func (p *Provider) Cancel(ctx context.Context, req *pbempty.Empty) (*pbempty.Emp
func (p *Provider) GetMapping(
ctx context.Context, req *pulumirpc.GetMappingRequest) (*pulumirpc.GetMappingResponse, error) {

info := MarshalProviderInfo(&p.info)
mapping, err := json.Marshal(info)
if err != nil {
return nil, err
if req.Key == "tf" {
info := MarshalProviderInfo(&p.info)
mapping, err := json.Marshal(info)
if err != nil {
return nil, err
}
return &pulumirpc.GetMappingResponse{
Provider: p.info.Name,
Data: mapping,
}, nil
}
return &pulumirpc.GetMappingResponse{
Provider: p.info.Name,
Data: mapping,
}, nil

// An empty response is valid for GetMapping, it means we don't have a mapping for the given key
return &pulumirpc.GetMappingResponse{}, nil
}

func initializationError(id string, props *pbstruct.Struct, reasons []string) error {
Expand Down
13 changes: 8 additions & 5 deletions pkg/tfgen/pluginHost.go
Expand Up @@ -55,12 +55,15 @@ func (p *inmemoryProvider) GetSchema(version int) ([]byte, error) {
}

func (p *inmemoryProvider) GetMapping(key string) ([]byte, string, error) {
info := tfbridge.MarshalProviderInfo(&p.info)
mapping, err := json.Marshal(info)
if err != nil {
return nil, "", err
if key == "tf" {
info := tfbridge.MarshalProviderInfo(&p.info)
mapping, err := json.Marshal(info)
if err != nil {
return nil, "", err
}
return mapping, p.info.Name, nil
}
return mapping, p.info.Name, nil
return nil, "", nil
}

func (p *inmemoryProvider) GetPluginInfo() (workspace.PluginInfo, error) {
Expand Down