Skip to content

Commit 4626f1b

Browse files
Resource list fallback to items index (#13352) (#21859)
[upstream:6068f8d4da95cc8dda97fe1467ddd21c24257d11] Signed-off-by: Modular Magician <[email protected]>
1 parent a9b1341 commit 4626f1b

File tree

235 files changed

+2577
-702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+2577
-702
lines changed

.changelog/13352.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google/services/alloydb/resource_alloydb_backup_sweeper.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,18 @@ func testSweepAlloydbBackup(_ string) error {
104104
return err
105105
}
106106

107+
// First try the expected resource key
107108
resourceList, ok := res["backups"]
108-
if !ok {
109-
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
110-
continue
109+
if ok {
110+
log.Printf("[INFO][SWEEPER_LOG] Found resources under expected key 'backups'")
111+
} else {
112+
// Next, try the common "items" pattern
113+
resourceList, ok = res["items"]
114+
if ok {
115+
log.Printf("[INFO][SWEEPER_LOG] Found resources under standard 'items' key")
116+
} else {
117+
continue
118+
}
111119
}
112120
rl := resourceList.([]interface{})
113121

google/services/apigee/resource_apigee_addons_config_sweeper.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,18 @@ func testSweepApigeeAddonsConfig(_ string) error {
105105
return err
106106
}
107107

108+
// First try the expected resource key
108109
resourceList, ok := res["addonsConfigs"]
109-
if !ok {
110-
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
111-
continue
110+
if ok {
111+
log.Printf("[INFO][SWEEPER_LOG] Found resources under expected key 'addonsConfigs'")
112+
} else {
113+
// Next, try the common "items" pattern
114+
resourceList, ok = res["items"]
115+
if ok {
116+
log.Printf("[INFO][SWEEPER_LOG] Found resources under standard 'items' key")
117+
} else {
118+
continue
119+
}
112120
}
113121
rl := resourceList.([]interface{})
114122

google/services/apigee/resource_apigee_organization_sweeper.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,18 @@ func testSweepApigeeOrganization(_ string) error {
104104
return err
105105
}
106106

107+
// First try the expected resource key
107108
resourceList, ok := res["organizations"]
108-
if !ok {
109-
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
110-
continue
109+
if ok {
110+
log.Printf("[INFO][SWEEPER_LOG] Found resources under expected key 'organizations'")
111+
} else {
112+
// Next, try the common "items" pattern
113+
resourceList, ok = res["items"]
114+
if ok {
115+
log.Printf("[INFO][SWEEPER_LOG] Found resources under standard 'items' key")
116+
} else {
117+
continue
118+
}
111119
}
112120
rl := resourceList.([]interface{})
113121

google/services/appengine/resource_app_engine_domain_mapping_sweeper.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,18 @@ func testSweepAppEngineDomainMapping(_ string) error {
105105
return err
106106
}
107107

108+
// First try the expected resource key
108109
resourceList, ok := res["domainMappings"]
109-
if !ok {
110-
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
111-
continue
110+
if ok {
111+
log.Printf("[INFO][SWEEPER_LOG] Found resources under expected key 'domainMappings'")
112+
} else {
113+
// Next, try the common "items" pattern
114+
resourceList, ok = res["items"]
115+
if ok {
116+
log.Printf("[INFO][SWEEPER_LOG] Found resources under standard 'items' key")
117+
} else {
118+
continue
119+
}
112120
}
113121
rl := resourceList.([]interface{})
114122

google/services/apphub/resource_apphub_application_sweeper.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,18 @@ func testSweepApphubApplication(_ string) error {
106106
return err
107107
}
108108

109+
// First try the expected resource key
109110
resourceList, ok := res["applications"]
110-
if !ok {
111-
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
112-
continue
111+
if ok {
112+
log.Printf("[INFO][SWEEPER_LOG] Found resources under expected key 'applications'")
113+
} else {
114+
// Next, try the common "items" pattern
115+
resourceList, ok = res["items"]
116+
if ok {
117+
log.Printf("[INFO][SWEEPER_LOG] Found resources under standard 'items' key")
118+
} else {
119+
continue
120+
}
113121
}
114122
rl := resourceList.([]interface{})
115123

google/services/apphub/resource_apphub_service_project_attachment_sweeper.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,18 @@ func testSweepApphubServiceProjectAttachment(_ string) error {
104104
return err
105105
}
106106

107+
// First try the expected resource key
107108
resourceList, ok := res["serviceProjectAttachments"]
108-
if !ok {
109-
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
110-
continue
109+
if ok {
110+
log.Printf("[INFO][SWEEPER_LOG] Found resources under expected key 'serviceProjectAttachments'")
111+
} else {
112+
// Next, try the common "items" pattern
113+
resourceList, ok = res["items"]
114+
if ok {
115+
log.Printf("[INFO][SWEEPER_LOG] Found resources under standard 'items' key")
116+
} else {
117+
continue
118+
}
111119
}
112120
rl := resourceList.([]interface{})
113121

google/services/artifactregistry/resource_artifact_registry_repository_sweeper.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,18 @@ func testSweepArtifactRegistryRepository(_ string) error {
105105
return err
106106
}
107107

108+
// First try the expected resource key
108109
resourceList, ok := res["repositories"]
109-
if !ok {
110-
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
111-
continue
110+
if ok {
111+
log.Printf("[INFO][SWEEPER_LOG] Found resources under expected key 'repositories'")
112+
} else {
113+
// Next, try the common "items" pattern
114+
resourceList, ok = res["items"]
115+
if ok {
116+
log.Printf("[INFO][SWEEPER_LOG] Found resources under standard 'items' key")
117+
} else {
118+
continue
119+
}
112120
}
113121
rl := resourceList.([]interface{})
114122

google/services/backupdr/resource_backup_dr_backup_plan_association_sweeper.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,18 @@ func testSweepBackupDRBackupPlanAssociation(_ string) error {
104104
return err
105105
}
106106

107+
// First try the expected resource key
107108
resourceList, ok := res["backupPlanAssociations"]
108-
if !ok {
109-
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
110-
continue
109+
if ok {
110+
log.Printf("[INFO][SWEEPER_LOG] Found resources under expected key 'backupPlanAssociations'")
111+
} else {
112+
// Next, try the common "items" pattern
113+
resourceList, ok = res["items"]
114+
if ok {
115+
log.Printf("[INFO][SWEEPER_LOG] Found resources under standard 'items' key")
116+
} else {
117+
continue
118+
}
111119
}
112120
rl := resourceList.([]interface{})
113121

google/services/backupdr/resource_backup_dr_backup_plan_sweeper.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,18 @@ func testSweepBackupDRBackupPlan(_ string) error {
104104
return err
105105
}
106106

107+
// First try the expected resource key
107108
resourceList, ok := res["backupPlans"]
108-
if !ok {
109-
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
110-
continue
109+
if ok {
110+
log.Printf("[INFO][SWEEPER_LOG] Found resources under expected key 'backupPlans'")
111+
} else {
112+
// Next, try the common "items" pattern
113+
resourceList, ok = res["items"]
114+
if ok {
115+
log.Printf("[INFO][SWEEPER_LOG] Found resources under standard 'items' key")
116+
} else {
117+
continue
118+
}
111119
}
112120
rl := resourceList.([]interface{})
113121

0 commit comments

Comments
 (0)