Skip to content

Commit

Permalink
Explain the need for the edit rule
Browse files Browse the repository at this point in the history
  • Loading branch information
guineveresaenger committed Oct 22, 2024
1 parent 0672886 commit 1bab333
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"os"
"path"
// embed is used to store bridge-metadata.json in the compiled binary
_ "embed"

Expand Down Expand Up @@ -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

0 comments on commit 1bab333

Please sign in to comment.