Skip to content

Commit

Permalink
test(record): swap value for content
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbednarz committed Aug 29, 2024
1 parent 3ab7b24 commit e111a4b
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 11 deletions.
7 changes: 0 additions & 7 deletions internal/app/cf-terraforming/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ func generateResources() func(cmd *cobra.Command, args []string) {
}

case "cloudflare_record":
simpleDNSTypes := []string{"A", "AAAA", "CNAME", "TXT", "MX", "NS", "PTR"}
jsonPayload, _, err := api.ListDNSRecords(context.Background(), identifier, cloudflare.ListDNSRecordsParams{})
if err != nil {
log.Fatal(err)
Expand All @@ -719,12 +718,6 @@ func generateResources() func(cmd *cobra.Command, args []string) {
if jsonStructData[i].(map[string]interface{})["name"].(string) != jsonStructData[i].(map[string]interface{})["zone_name"].(string) {
jsonStructData[i].(map[string]interface{})["name"] = strings.ReplaceAll(jsonStructData[i].(map[string]interface{})["name"].(string), "."+jsonStructData[i].(map[string]interface{})["zone_name"].(string), "")
}

// We only want to remap the "value" to the "content" value for simple
// DNS types as the aggregate types use `data` for the structure.
if contains(simpleDNSTypes, jsonStructData[i].(map[string]interface{})["type"].(string)) {
jsonStructData[i].(map[string]interface{})["value"] = jsonStructData[i].(map[string]interface{})["content"]
}
}
case "cloudflare_ruleset":
jsonPayload, err := api.ListRulesets(context.Background(), identifier, cloudflare.ListRulesetsParams{})
Expand Down
2 changes: 1 addition & 1 deletion testdata/terraform/cloudflare_record/test.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource "cloudflare_record" "terraform_managed_resource" {
content = "198.51.100.4"
name = "example.com"
proxied = false
ttl = 120
type = "A"
value = "198.51.100.4"
zone_id = "0da42c8d2132a9ddaf714f9e7c920711"
}
2 changes: 1 addition & 1 deletion testdata/terraform/cloudflare_record_ptr/test.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource "cloudflare_record" "terraform_managed_resource" {
content = "255.2.0.192.in-addr.arpa"
name = "example.com"
proxied = false
ttl = 1
type = "PTR"
value = "255.2.0.192.in-addr.arpa"
zone_id = "0da42c8d2132a9ddaf714f9e7c920711"
}
2 changes: 1 addition & 1 deletion testdata/terraform/cloudflare_record_subdomain/test.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource "cloudflare_record" "terraform_managed_resource" {
content = "198.51.100.4"
name = "subdomain"
proxied = false
ttl = 120
type = "A"
value = "198.51.100.4"
zone_id = "0da42c8d2132a9ddaf714f9e7c920711"
}
2 changes: 1 addition & 1 deletion testdata/terraform/cloudflare_record_txt_spf/test.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource "cloudflare_record" "terraform_managed_resource" {
content = "\"v=spf1 include:%%{ir}.%%{v}.%%{d}.spf.has.pphosted.com include:amazonses.com ~all\""
name = "txtspf"
proxied = false
ttl = 1
type = "TXT"
value = "\"v=spf1 include:%%{ir}.%%{v}.%%{d}.spf.has.pphosted.com include:amazonses.com ~all\""
zone_id = "0da42c8d2132a9ddaf714f9e7c920711"
}

0 comments on commit e111a4b

Please sign in to comment.