Skip to content

Commit 65f84eb

Browse files
authored
Merge pull request #580 from jafowler/do-not-return-custom-pages-without-urls
2 parents 9f77aae + 654ff4c commit 65f84eb

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

internal/app/cf-terraforming/cmd/generate.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,18 @@ func generateResources() func(cmd *cobra.Command, args []string) {
412412
}
413413
}
414414

415+
var newJsonStructData []interface{}
415416
// remap ID to the "type" field
416417
for i := 0; i < resourceCount; i++ {
417418
jsonStructData[i].(map[string]interface{})["type"] = jsonStructData[i].(map[string]interface{})["id"]
419+
// we only want repsonses that have 'url'
420+
if jsonStructData[i].(map[string]interface{})["url"] != nil {
421+
newJsonStructData = append(newJsonStructData, jsonStructData[i])
422+
}
418423
}
424+
jsonStructData = newJsonStructData
425+
resourceCount = len(jsonStructData)
426+
419427
case "cloudflare_custom_hostname_fallback_origin":
420428
var jsonPayload []cloudflare.CustomHostnameFallbackOrigin
421429
apiCall, err := api.CustomHostnameFallbackOrigin(context.Background(), zoneID)

testdata/cloudflare/cloudflare_custom_pages_account.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ interactions:
2727
],
2828
"preview_target": "preview:target",
2929
"description": "example"
30+
},
31+
{
32+
"id": "basic_challenge",
33+
"created_on": "2014-01-01T05:20:00.12345Z",
34+
"modified_on": "2014-01-01T05:20:00.12345Z",
35+
"url": null,
36+
"state": "customized",
37+
"required_tokens": [
38+
"::CAPTCHA_BOX::"
39+
],
40+
"preview_target": "preview:target",
41+
"description": "example"
3042
}
3143
]
3244
}

testdata/cloudflare/cloudflare_custom_pages_zone.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ interactions:
2727
],
2828
"preview_target": "preview:target",
2929
"description": "example"
30+
},
31+
{
32+
"id": "basic_challenge",
33+
"created_on": "2014-01-01T05:20:00.12345Z",
34+
"modified_on": "2014-01-01T05:20:00.12345Z",
35+
"url": null,
36+
"state": "customized",
37+
"required_tokens": [
38+
"::CAPTCHA_BOX::"
39+
],
40+
"preview_target": "preview:target",
41+
"description": "example"
3042
}
3143
]
3244
}

0 commit comments

Comments
 (0)