Skip to content

Commit

Permalink
Fix provider name discrepancy in index doc (#2562)
Browse files Browse the repository at this point in the history
This pull request swaps out use of `g.info.Name` for
`g.pkg.Name().String()` when determining the name of the provider for
title and download link purposes.
`g.info.Name` refers to the upstream Terraform provider name. We need to
use the Pulumi package name instead.
Fortunately the bridge already knows how to do this, so this pull
request swaps out the package name getter and adjusts the parser test
provider to have a pkg name.

Fixes pulumi/pulumi-f5bigip#598.
PR in that provider with these changes:
pulumi/pulumi-f5bigip#601
  • Loading branch information
guineveresaenger authored Nov 1, 2024
1 parent 38be4eb commit 2096fb4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/tfgen/installation_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func plainDocsParser(docFile *DocFile, g *Generator) ([]byte, error) {

// Add pulumi-specific front matter
// Generate pulumi-specific front matter
frontMatter := writeFrontMatter(g.info.Name)
frontMatter := writeFrontMatter(g.pkg.Name().String())

// Remove the title. A title gets populated from Hugo frontmatter; we do not want two.
content, err = removeTitle(content)
Expand All @@ -47,7 +47,7 @@ func plainDocsParser(docFile *DocFile, g *Generator) ([]byte, error) {
content = stripSchemaGeneratedByTFPluginDocs(content)

// Generate pulumi-specific installation instructions
installationInstructions := writeInstallationInstructions(g.info.Golang.ImportBasePath, g.info.Name)
installationInstructions := writeInstallationInstructions(g.info.Golang.ImportBasePath, g.pkg.Name().String())

// Determine if we should write an overview header.
overviewHeader := getOverviewHeader(content)
Expand Down
3 changes: 2 additions & 1 deletion pkg/tfgen/installation_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
sdkv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
)

func TestPlainDocsParser(t *testing.T) {
Expand Down Expand Up @@ -91,14 +92,14 @@ func TestPlainDocsParser(t *testing.T) {
Golang: &tfbridge.GolangInfo{
ImportBasePath: "github.com/pulumi/pulumi-libvirt/sdk/go/libvirt",
},
Name: "libvirt",
},
cliConverterState: &cliConverter{
info: p,
pcls: pclsMap,
},
editRules: tt.edits,
language: RegistryDocs,
pkg: tokens.NewPackageToken("libvirt"),
}
actual, err := plainDocsParser(&tt.docFile, g)
require.NoError(t, err)
Expand Down

0 comments on commit 2096fb4

Please sign in to comment.