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

Additional replacements for installation docs #2431

Merged
merged 1 commit into from
Sep 20, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/tfgen/installation_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ func applyEditRules(contentBytes []byte, docFile string, g *Generator) ([]byte,
edits = append(edits,
skipSectionHeadersEdit(docFile),
removeTfVersionMentions(docFile),
//Replace "providers.tf" with "Pulumi.yaml"
reReplace(`providers.tf`, `Pulumi.yaml`),
reReplace(`terraform init`, `pulumi up`),
// Replace all "T/terraform" with "P/pulumi"
reReplace(`Terraform`, `Pulumi`),
reReplace(`terraform`, `pulumi`),
Expand All @@ -130,6 +133,7 @@ func applyEditRules(contentBytes []byte, docFile string, g *Generator) ([]byte,
reReplace("### Optional\n", ""),
reReplace(`block contains the following arguments`,
`input has the following nested fields`),
reReplace(`provider block`, `provider configuration`),
)
contentBytes, err := edits.apply(docFile, contentBytes)
if err != nil {
Expand Down
26 changes: 26 additions & 0 deletions pkg/tfgen/installation_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,37 @@ func TestApplyEditRules(t *testing.T) {
},
expected: []byte(readfile(t, "test_data/replace-terraform-version/expected.md")),
},
{
// Found in linode
name: "Rewrites providers.tf to Pulumi.yaml",
docFile: DocFile{
Content: []byte(readfile(t, "test_data/rewrite-providers-tf-to-pulumi-yaml/input.md")),
},
expected: []byte(readfile(t, "test_data/rewrite-providers-tf-to-pulumi-yaml/expected.md")),
},
{
name: "Rewrites terraform init to pulumi up",
docFile: DocFile{
Content: []byte(readfile(t, "test_data/rewrite-tf-init-to-pulumi-up/input.md")),
},
expected: []byte(readfile(t, "test_data/rewrite-tf-init-to-pulumi-up/expected.md")),
},
{
// Found in linode
name: "Replaces provider block with provider configuration",
docFile: DocFile{
Content: []byte(readfile(t, "test_data/replace-provider-block/input.md")),
},
expected: []byte(readfile(t, "test_data/replace-provider-block/expected.md")),
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if runtime.GOOS == "windows" {
t.Skipf("Skipping on Windows due to a newline handling issue")
}
g := &Generator{
sink: mockSink{t},
editRules: defaultEditRules(),
Expand Down
3 changes: 3 additions & 0 deletions pkg/tfgen/test_data/replace-provider-block/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Configuring the Target API Version

The `api_version` can be set on the provider configuration like so:
3 changes: 3 additions & 0 deletions pkg/tfgen/test_data/replace-provider-block/input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Configuring the Target API Version

The `api_version` can be set on the provider block like so:
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Using Configuration Files

Configuration files can be used to specify Linode client configuration options across various Linode integrations.

For example:

`~/.config/linode`

```ini
[default]
token = mylinodetoken
```

`Pulumi.yaml`
14 changes: 14 additions & 0 deletions pkg/tfgen/test_data/rewrite-providers-tf-to-pulumi-yaml/input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Using Configuration Files

Configuration files can be used to specify Linode client configuration options across various Linode integrations.

For example:

`~/.config/linode`

```ini
[default]
token = mylinodetoken
```

`providers.tf`
5 changes: 5 additions & 0 deletions pkg/tfgen/test_data/rewrite-tf-init-to-pulumi-up/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Note: Fully qualified `secret_name` ARN as input is REQUIRED for cross-AWS account secrets.

Note: `sts_endpoint` parameter is REQUIRED for cross-AWS region or cross-AWS account secrets.

In terminal, `pulumi up`
5 changes: 5 additions & 0 deletions pkg/tfgen/test_data/rewrite-tf-init-to-pulumi-up/input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Note: Fully qualified `secret_name` ARN as input is REQUIRED for cross-AWS account secrets.

Note: `sts_endpoint` parameter is REQUIRED for cross-AWS region or cross-AWS account secrets.

In terminal, `terraform init`