diff --git a/provider/resources.go b/provider/resources.go index 6cae163f..810475b6 100644 --- a/provider/resources.go +++ b/provider/resources.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "os" + "path" // embed is used to store bridge-metadata.json in the compiled binary _ "embed" @@ -424,27 +425,30 @@ func Provider() tfbridge.ProviderInfo { func editRules(defaults []tfbridge.DocsEdit) []tfbridge.DocsEdit { return append( defaults, - - tfbridge.DocsEdit{ - Path: "index.md", - Edit: func(_ string, content []byte) ([]byte, error) { - input, err := os.ReadFile("provider/installation-replaces/example-input.md") - if err != nil { - return nil, err - } - replace, err := os.ReadFile("provider/installation-replaces/example-desired.md") - if err != nil { - return nil, err - } - b := bytes.ReplaceAll( - content, - input, - replace) - return b, nil - }, - }, + fixInstallationExample, ) } +// In the upstream example, two providers are defined in the same code block. +// Pulumi Convert is not set up to handle this case, so this edit breaks the example up into two separate code blocks. +var fixInstallationExample = tfbridge.DocsEdit{ + Path: "index.md", + Edit: func(_ string, content []byte) ([]byte, error) { + input, err := os.ReadFile("provider/installation-replaces/example-input.md") + if err != nil { + return nil, err + } + replace, err := os.ReadFile("provider/installation-replaces/example-desired.md") + if err != nil { + return nil, err + } + b := bytes.ReplaceAll( + content, + input, + replace) + return b, nil + }, +} + //go:embed cmd/pulumi-resource-harness/bridge-metadata.json var metadata []byte