From 77577d00dca1e1ffd1c9bd146b951d67b0ad84be Mon Sep 17 00:00:00 2001 From: Ian Wahbe Date: Wed, 13 Nov 2024 22:10:39 +0100 Subject: [PATCH] Replace "Managed by Terraform" in our docs (#2611) Fixes #2610 --- pkg/tfgen/edit_rules.go | 1 + pkg/tfgen/edit_rules_test.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/pkg/tfgen/edit_rules.go b/pkg/tfgen/edit_rules.go index 8e85e491d..7f8c8aa37 100644 --- a/pkg/tfgen/edit_rules.go +++ b/pkg/tfgen/edit_rules.go @@ -37,6 +37,7 @@ func defaultEditRules() editRules { fixupImports(), // Replace content such as "jdoe@hashicorp.com" with "jdoe@example.com" reReplace("@hashicorp.com", "@example.com", info.PreCodeTranslation), + reReplace(`"Managed by Terraform"`, `"Managed by Pulumi"`, info.PreCodeTranslation), // The following edit rules may be applied after translating the code sections in a document. // Their primary use case is for the docs translation approach spearheaded in installation_docs.go. diff --git a/pkg/tfgen/edit_rules_test.go b/pkg/tfgen/edit_rules_test.go index a4404bf6a..261724249 100644 --- a/pkg/tfgen/edit_rules_test.go +++ b/pkg/tfgen/edit_rules_test.go @@ -265,6 +265,36 @@ func TestApplyEditRules(t *testing.T) { expected: []byte("# Configuration Reference"), phase: info.PostCodeTranslation, }, + { + // Found in azuredevops: https://github.com/pulumi/pulumi-terraform-bridge/issues/2610 + name: `Replaces "Managed by Terraform" with "Manged by Pulumi"`, + docFile: DocFile{ + Content: []byte(` +const example = new azuredevops.Project("example", { + description: "Managed by Terraform", +}); +`), + }, + expected: []byte(` +const example = new azuredevops.Project("example", { + description: "Managed by Pulumi", +}); +`), + }, + { + name: "Does not replace \"Managed by Terraform\" with \"Manged by Pulumi\" (require quotes)", + // It's harder to tell if Managed by Terraform would sense to replace, so we don't do it for now. + // + // We don't have a canonical example where this does not work. + docFile: DocFile{ + Content: []byte(` + This Resource is Managed by Terraform +`), + }, + expected: []byte(` + This Resource is Managed by Terraform +`), + }, } edits := defaultEditRules()