Skip to content

Commit

Permalink
clean up installation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
guineveresaenger committed Dec 13, 2024
1 parent ab31ef8 commit 8dff1e9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
5 changes: 1 addition & 4 deletions dynamic/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ require (
github.com/opentofu/opentofu/shim v0.0.0-00010101000000-000000000000
github.com/pulumi/providertest v0.1.3
github.com/pulumi/pulumi-terraform-bridge/v3 v3.92.0
github.com/ryboe/q v1.0.19
github.com/stretchr/testify v1.9.0
google.golang.org/protobuf v1.35.1
)
Expand All @@ -31,8 +30,6 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/nxadm/tail v1.4.11 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pulumi/terraform-diff-reader v0.0.2 // indirect
Expand Down Expand Up @@ -219,7 +216,7 @@ require (
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/spf13/afero v1.9.5
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.8.0
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/texttheater/golang-levenshtein v1.0.1 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
Expand Down
2 changes: 0 additions & 2 deletions dynamic/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1974,8 +1974,6 @@ github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfF
github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk=
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
github.com/ryboe/q v1.0.19 h1:1dO1anK4gorZRpXBD/edBZkMxIC1tFIwN03nfyOV13A=
github.com/ryboe/q v1.0.19/go.mod h1:IoEB3Q2/p6n1qbhIQVuNyakxtnV4rNJ/XJPK+jsEa0M=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 h1:TToq11gyfNlrMFZiYujSekIsPd9AmsA2Bj/iv+s4JHE=
Expand Down
83 changes: 44 additions & 39 deletions pkg/tfgen/installation_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,59 +101,64 @@ func writeFrontMatter(providerDisplayName string) string {

// writeInstallationInstructions renders the following for a pulumi-maintained provider:
// ****
// Installation
// The Foo provider is available as a package in all Pulumi languages:
//
// JavaScript/TypeScript: @pulumi/foo
// Python: pulumi-foo
// Go: github.com/pulumi/pulumi-foo/sdk/v3/go/foo
// .NET: Pulumi.foo
// Java: com.pulumi/foo
// Installation
// The Foo provider is available as a package in all Pulumi languages:
//
// JavaScript/TypeScript: @pulumi/foo
// Python: pulumi-foo
// Go: github.com/pulumi/pulumi-foo/sdk/v3/go/foo
// .NET: Pulumi.foo
// Java: com.pulumi/foo
//
// ****
//
// A dynamically bridged provider receives the following instead:
// ****
// ## Generate Provider
//
// The Foo provider must be installed as a Local Package by following the instructions for Any Terraform Provider: (link)
// ```bash
// pulumi package add terraform-provider org/foo
// ```
// ## Generate Provider
//
// The Foo provider must be installed as a Local Package by following the instructions for Any Terraform Provider: (link)
// ```bash
// pulumi package add terraform-provider org/foo
// ```
//
// ****
func writeInstallationInstructions(goImportBasePath, displayName, pkgName, ghOrg, sourceRepo string) string {
// Capitalize the package name for C#
capitalize := cases.Title(language.English)
cSharpName := capitalize.String(pkgName)

var instructions string
installInstructions := fmt.Sprintf(
"## Installation\n\n"+
"The %[1]s provider is available as a package in all Pulumi languages:\n\n"+
"* JavaScript/TypeScript: [`@pulumi/%[2]s`](https://www.npmjs.com/package/@pulumi/%[2]s)\n"+
"* Python: [`pulumi-%[2]s`](https://pypi.org/project/pulumi-%[2]s/)\n"+
"* Go: [`%[4]s`](https://github.com/pulumi/pulumi-%[2]s)\n"+
"* .NET: [`Pulumi.%[3]s`](https://www.nuget.org/packages/Pulumi.%[3]s)\n"+
"* Java: [`com.pulumi/%[2]s`](https://central.sonatype.com/artifact/com.pulumi/%[2]s)\n\n",
displayName,
pkgName,
cSharpName,
goImportBasePath,
)

generateInstructions := fmt.Sprintf("## Generate Provider\n\n"+
"The %[1]s provider must be installed as a Local Package by following the "+
"[instructions for Any Terraform Provider]"+
"(https://www.pulumi.com/registry/packages/terraform-provider/):\n\n"+
"```bash\n"+
"pulumi package add terraform-provider %[2]s/%[3]s\n"+
"```\n",
displayName,
ghOrg,
pkgName,
)

if strings.Contains(sourceRepo, "pulumi") {
instructions = fmt.Sprintf(
"## Installation\n\n"+
"The %[1]s provider is available as a package in all Pulumi languages:\n\n"+
"* JavaScript/TypeScript: [`@pulumi/%[2]s`](https://www.npmjs.com/package/@pulumi/%[2]s)\n"+
"* Python: [`pulumi-%[2]s`](https://pypi.org/project/pulumi-%[2]s/)\n"+
"* Go: [`%[4]s`](https://github.com/pulumi/pulumi-%[2]s)\n"+
"* .NET: [`Pulumi.%[3]s`](https://www.nuget.org/packages/Pulumi.%[3]s)\n"+
"* Java: [`com.pulumi/%[2]s`](https://central.sonatype.com/artifact/com.pulumi/%[2]s)\n\n",
displayName,
pkgName,
cSharpName,
goImportBasePath,
)
} else {
instructions = fmt.Sprintf("## Generate Provider\n\n"+
"The %[1]s provider must be installed as a Local Package by following the "+
"[instructions for Any Terraform Provider]"+
"(https://www.pulumi.com/registry/packages/terraform-provider/):\n\n"+
"```bash\n"+
"pulumi package add terraform-provider %[2]s/%[3]s\n"+
"```\n",
displayName,
ghOrg,
pkgName,
)
return installInstructions
}
return instructions
return generateInstructions
}

func getOverviewHeader(content []byte) string {
Expand Down

0 comments on commit 8dff1e9

Please sign in to comment.