Skip to content

Commit

Permalink
Add various replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
guineveresaenger committed Sep 19, 2024
1 parent 9668009 commit a096423
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 0 deletions.
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
23 changes: 23 additions & 0 deletions pkg/tfgen/installation_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,29 @@ 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
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`
7 changes: 7 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,7 @@
Note: Fully qualified `secret_name` ARN as input is REQUIRED for cross-AWS account secrets. For more detatils see:
* https://aws.amazon.com/blogs/security/how-to-access-secrets-across-aws-accounts-by-attaching-resource-based-policies/
* https://aws.amazon.com/premiumsupport/knowledge-center/secrets-manager-share-between-accounts/

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

In terminal, `pulumi up`
7 changes: 7 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,7 @@
Note: Fully qualified `secret_name` ARN as input is REQUIRED for cross-AWS account secrets. For more detatils see:
* https://aws.amazon.com/blogs/security/how-to-access-secrets-across-aws-accounts-by-attaching-resource-based-policies/
* https://aws.amazon.com/premiumsupport/knowledge-center/secrets-manager-share-between-accounts/

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

In terminal, `terraform init`

0 comments on commit a096423

Please sign in to comment.