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

Second phase of convert mapper #654

Merged
merged 1 commit into from Nov 30, 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
6 changes: 3 additions & 3 deletions go.mod
Expand Up @@ -34,9 +34,9 @@ require (
github.com/mitchellh/reflectwalk v1.0.2
github.com/pkg/errors v0.9.1
github.com/pulumi/pulumi-java/pkg v0.6.0
github.com/pulumi/pulumi-yaml v1.0.2
github.com/pulumi/pulumi/pkg/v3 v3.46.1
github.com/pulumi/pulumi/sdk/v3 v3.46.1
github.com/pulumi/pulumi-yaml v1.0.3
github.com/pulumi/pulumi/pkg/v3 v3.48.1-0.20221129095827-e43e98e5a7ab
github.com/pulumi/pulumi/sdk/v3 v3.48.1-0.20221129095827-e43e98e5a7ab
github.com/pulumi/schema-tools v0.1.0
github.com/pulumi/terraform-diff-reader v0.0.0-20201211191010-ad4715e9285e
github.com/russross/blackfriday/v2 v2.1.0
Expand Down
16 changes: 10 additions & 6 deletions go.sum
Expand Up @@ -1546,12 +1546,16 @@ github.com/prometheus/prometheus v0.37.0/go.mod h1:egARUgz+K93zwqsVIAneFlLZefyGO
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/pulumi/pulumi-java/pkg v0.6.0 h1:haiSQJlhrQIBBcR0r0aQCIF8i69e4znzRnHpaNQUchE=
github.com/pulumi/pulumi-java/pkg v0.6.0/go.mod h1:xSK2B792P8zjwYZTHYapMM1RJdue2BpRFQNYObWO0C8=
github.com/pulumi/pulumi-yaml v1.0.2 h1:8fuoFNJlYJm1ni1Fff8QsIvef3E+ilroTPDrYKyy088=
github.com/pulumi/pulumi-yaml v1.0.2/go.mod h1:FKly+y0x5onXHEZALNnFglr6ZZnro4Y/jlN4sYLKYeM=
github.com/pulumi/pulumi/pkg/v3 v3.46.1 h1:YwEAckUmXUM/ELWiPRk9/ZuPv9bogJgDLh11x6VdGtI=
github.com/pulumi/pulumi/pkg/v3 v3.46.1/go.mod h1:Rebr+SHHGtTu2w7VURQZDEUYDhtvjECoovIfh9TYHQU=
github.com/pulumi/pulumi/sdk/v3 v3.46.1 h1:z9I0dLP2FPGTrNSIuUtShTNe1SZLSK0//tmWrjDfFrI=
github.com/pulumi/pulumi/sdk/v3 v3.46.1/go.mod h1:n5EPRVFDh+EFwYZ+oaZmEtwgVN1A6NnI82B7ks/bmTU=
github.com/pulumi/pulumi-yaml v1.0.3 h1:JDRQfGcQYxwJETIepa7T3B7wTV7Bk2P7uApmWvQZeL4=
github.com/pulumi/pulumi-yaml v1.0.3/go.mod h1:KLFTyADnoNoPU9djMyRvXymrTH2SCBg9wnXaapuggEA=
github.com/pulumi/pulumi/pkg/v3 v3.48.0 h1:AHzLLX8bSAVlqE6WZk3kYPJmP9kpkFtMqjaFpgtN8UM=
github.com/pulumi/pulumi/pkg/v3 v3.48.0/go.mod h1:9f7Mbv0amXUNDbvG6jHJ4SaGLMEhXseW2KwjDTqvRAo=
github.com/pulumi/pulumi/pkg/v3 v3.48.1-0.20221129095827-e43e98e5a7ab h1:i6J8IQtcabo0PQzFpOC5NcbdtELAWR33jCOk+PZSdDU=
github.com/pulumi/pulumi/pkg/v3 v3.48.1-0.20221129095827-e43e98e5a7ab/go.mod h1:9f7Mbv0amXUNDbvG6jHJ4SaGLMEhXseW2KwjDTqvRAo=
github.com/pulumi/pulumi/sdk/v3 v3.48.0 h1:Uf7Cq7oyzEOT+d+/RSfMldtN4MWWtJhOkOwSZnbr4CE=
github.com/pulumi/pulumi/sdk/v3 v3.48.0/go.mod h1:n5EPRVFDh+EFwYZ+oaZmEtwgVN1A6NnI82B7ks/bmTU=
github.com/pulumi/pulumi/sdk/v3 v3.48.1-0.20221129095827-e43e98e5a7ab h1:i/huPIYO6KRrdDWLzJhu2siEJi1sZr2/XNXbP0EGe+w=
github.com/pulumi/pulumi/sdk/v3 v3.48.1-0.20221129095827-e43e98e5a7ab/go.mod h1:n5EPRVFDh+EFwYZ+oaZmEtwgVN1A6NnI82B7ks/bmTU=
github.com/pulumi/schema-tools v0.1.0 h1:o1nVQaJEnmcA+3trxe+0sIDlrILxEIOvgUQ2Ze4OFsk=
github.com/pulumi/schema-tools v0.1.0/go.mod h1:feL1siLWdcCNUm+irXoHyNHbGaqoX7pfYojpGZe2ziY=
github.com/pulumi/terraform-diff-reader v0.0.0-20201211191010-ad4715e9285e h1:Dik4Qe/+xguB8JagPyXNlbOnRiXGmq/PSPQTGunYnTk=
Expand Down
14 changes: 14 additions & 0 deletions pkg/tfbridge/provider.go
Expand Up @@ -1250,6 +1250,20 @@ func (p *Provider) Cancel(ctx context.Context, req *pbempty.Empty) (*pbempty.Emp
return &pbempty.Empty{}, nil
}

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
}
return &pulumirpc.GetMappingResponse{
Provider: p.info.Name,
Data: mapping,
}, nil
}

func initializationError(id string, props *pbstruct.Struct, reasons []string) error {
contract.Assertf(len(reasons) > 0, "initializationError must be passed at least one reason")
detail := pulumirpc.ErrorResourceInitFailed{
Expand Down
10 changes: 10 additions & 0 deletions pkg/tfgen/pluginHost.go
Expand Up @@ -15,6 +15,7 @@
package tfgen

import (
"encoding/json"
"fmt"
"sync"

Expand Down Expand Up @@ -53,6 +54,15 @@ func (p *inmemoryProvider) GetSchema(version int) ([]byte, error) {
return p.schema, nil
}

func (p *inmemoryProvider) GetMapping(key string) ([]byte, string, error) {
info := tfbridge.MarshalProviderInfo(&p.info)
Copy link
Member

Choose a reason for hiding this comment

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

Whoah. Is all of this needed🙏

This is a large-ish export, I need to get a bit more of a handle on all the things here to be comfortable, as presumably this now also becomes an obligation for PF-built providers to hit the same contract.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not new, this is the data structure that tf2pulumi already expects for bridged providers to export for conversions. It's just currently it access it via running the plugin with the "-get-provider-info" flag (see https://github.com/pulumi/pulumi-terraform-bridge/blob/master/pkg/tfbridge/main.go#L55-L60)

This is just moving that interface to be a well known engine interface so that the engine can do the plugin lookup and loading, rather than tf2pulumi having to do it.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, gotcha so tf2pulumi consumes it. This is my miss then, I need to target supporting this from tfpf branch as well!

mapping, err := json.Marshal(info)
if err != nil {
return nil, "", err
}
return mapping, p.info.Name, nil
}

func (p *inmemoryProvider) GetPluginInfo() (workspace.PluginInfo, error) {
var version *semver.Version
if p.info.Version != "" {
Expand Down