Skip to content

Commit 2b4cd9b

Browse files
Additional replacements for installation docs (#2431)
A few additional useful replaces encountered in the installation docs: - terraform init --> pulumi up - providers.tf --> Pulumi.yaml - provider block --> provider configuration
1 parent db8da85 commit 2b4cd9b

File tree

8 files changed

+74
-0
lines changed

8 files changed

+74
-0
lines changed

pkg/tfgen/installation_docs.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ func applyEditRules(contentBytes []byte, docFile string, g *Generator) ([]byte,
114114
edits = append(edits,
115115
skipSectionHeadersEdit(docFile),
116116
removeTfVersionMentions(docFile),
117+
//Replace "providers.tf" with "Pulumi.yaml"
118+
reReplace(`providers.tf`, `Pulumi.yaml`),
119+
reReplace(`terraform init`, `pulumi up`),
117120
// Replace all "T/terraform" with "P/pulumi"
118121
reReplace(`Terraform`, `Pulumi`),
119122
reReplace(`terraform`, `pulumi`),
@@ -130,6 +133,7 @@ func applyEditRules(contentBytes []byte, docFile string, g *Generator) ([]byte,
130133
reReplace("### Optional\n", ""),
131134
reReplace(`block contains the following arguments`,
132135
`input has the following nested fields`),
136+
reReplace(`provider block`, `provider configuration`),
133137
)
134138
contentBytes, err := edits.apply(docFile, contentBytes)
135139
if err != nil {

pkg/tfgen/installation_docs_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,37 @@ func TestApplyEditRules(t *testing.T) {
306306
},
307307
expected: []byte(readfile(t, "test_data/replace-terraform-version/expected.md")),
308308
},
309+
{
310+
// Found in linode
311+
name: "Rewrites providers.tf to Pulumi.yaml",
312+
docFile: DocFile{
313+
Content: []byte(readfile(t, "test_data/rewrite-providers-tf-to-pulumi-yaml/input.md")),
314+
},
315+
expected: []byte(readfile(t, "test_data/rewrite-providers-tf-to-pulumi-yaml/expected.md")),
316+
},
317+
{
318+
name: "Rewrites terraform init to pulumi up",
319+
docFile: DocFile{
320+
Content: []byte(readfile(t, "test_data/rewrite-tf-init-to-pulumi-up/input.md")),
321+
},
322+
expected: []byte(readfile(t, "test_data/rewrite-tf-init-to-pulumi-up/expected.md")),
323+
},
324+
{
325+
// Found in linode
326+
name: "Replaces provider block with provider configuration",
327+
docFile: DocFile{
328+
Content: []byte(readfile(t, "test_data/replace-provider-block/input.md")),
329+
},
330+
expected: []byte(readfile(t, "test_data/replace-provider-block/expected.md")),
331+
},
309332
}
310333
for _, tt := range tests {
311334
tt := tt
312335
t.Run(tt.name, func(t *testing.T) {
313336
t.Parallel()
337+
if runtime.GOOS == "windows" {
338+
t.Skipf("Skipping on Windows due to a newline handling issue")
339+
}
314340
g := &Generator{
315341
sink: mockSink{t},
316342
editRules: defaultEditRules(),
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Configuring the Target API Version
2+
3+
The `api_version` can be set on the provider configuration like so:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Configuring the Target API Version
2+
3+
The `api_version` can be set on the provider block like so:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Using Configuration Files
2+
3+
Configuration files can be used to specify Linode client configuration options across various Linode integrations.
4+
5+
For example:
6+
7+
`~/.config/linode`
8+
9+
```ini
10+
[default]
11+
token = mylinodetoken
12+
```
13+
14+
`Pulumi.yaml`
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Using Configuration Files
2+
3+
Configuration files can be used to specify Linode client configuration options across various Linode integrations.
4+
5+
For example:
6+
7+
`~/.config/linode`
8+
9+
```ini
10+
[default]
11+
token = mylinodetoken
12+
```
13+
14+
`providers.tf`
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Note: Fully qualified `secret_name` ARN as input is REQUIRED for cross-AWS account secrets.
2+
3+
Note: `sts_endpoint` parameter is REQUIRED for cross-AWS region or cross-AWS account secrets.
4+
5+
In terminal, `pulumi up`
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Note: Fully qualified `secret_name` ARN as input is REQUIRED for cross-AWS account secrets.
2+
3+
Note: `sts_endpoint` parameter is REQUIRED for cross-AWS region or cross-AWS account secrets.
4+
5+
In terminal, `terraform init`

0 commit comments

Comments
 (0)