Skip to content

Commit

Permalink
continue sweeper run for other resources if no resource found (#11589) (
Browse files Browse the repository at this point in the history
hashicorp#8140)

[upstream:924f91440a2b9674686182851772e467252da18e]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Sep 9, 2024
1 parent f7841e1 commit 30be1ff
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .changelog/11589.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none
netapp: modified manual sweepers to continue or other locations if no resource found
```
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func testSweepNetappActiveDirectory(region string) error {
listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err)
return nil
continue
}

res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Expand All @@ -69,13 +69,13 @@ func testSweepNetappActiveDirectory(region string) error {
})
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err)
return nil
continue
}

resourceList, ok := res["activeDirectories"]
if !ok {
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
return nil
continue
}

rl := resourceList.([]interface{})
Expand All @@ -87,7 +87,7 @@ func testSweepNetappActiveDirectory(region string) error {
obj := ri.(map[string]interface{})
if obj["name"] == nil {
log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName)
return nil
continue
}

name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string))
Expand All @@ -101,7 +101,7 @@ func testSweepNetappActiveDirectory(region string) error {
deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err)
return nil
continue
}
deleteUrl = deleteUrl + name

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func testSweepNetappBackupPolicy(region string) error {
listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err)
return nil
continue
}

res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Expand All @@ -69,13 +69,13 @@ func testSweepNetappBackupPolicy(region string) error {
})
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err)
return nil
continue
}

resourceList, ok := res["backupPolicies"]
if !ok {
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
return nil
continue
}

rl := resourceList.([]interface{})
Expand All @@ -87,7 +87,7 @@ func testSweepNetappBackupPolicy(region string) error {
obj := ri.(map[string]interface{})
if obj["name"] == nil {
log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName)
return nil
continue
}

name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string))
Expand All @@ -101,7 +101,7 @@ func testSweepNetappBackupPolicy(region string) error {
deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err)
return nil
continue
}
deleteUrl = deleteUrl + name

Expand Down
10 changes: 5 additions & 5 deletions google-beta/services/netapp/resource_netapp_backup_sweeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func testSweepNetappBackup(region string) error {
listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err)
return nil
continue
}

res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Expand All @@ -69,13 +69,13 @@ func testSweepNetappBackup(region string) error {
})
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err)
return nil
continue
}

resourceList, ok := res["backups"]
if !ok {
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
return nil
continue
}

rl := resourceList.([]interface{})
Expand All @@ -87,7 +87,7 @@ func testSweepNetappBackup(region string) error {
obj := ri.(map[string]interface{})
if obj["name"] == nil {
log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName)
return nil
continue
}

name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string))
Expand All @@ -101,7 +101,7 @@ func testSweepNetappBackup(region string) error {
deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err)
return nil
continue
}
deleteUrl = deleteUrl + name

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func testSweepNetappBackupVault(region string) error {
listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err)
return nil
continue
}

res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Expand All @@ -69,13 +69,13 @@ func testSweepNetappBackupVault(region string) error {
})
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err)
return nil
continue
}

resourceList, ok := res["backupVaults"]
if !ok {
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
return nil
continue
}

rl := resourceList.([]interface{})
Expand All @@ -87,7 +87,7 @@ func testSweepNetappBackupVault(region string) error {
obj := ri.(map[string]interface{})
if obj["name"] == nil {
log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName)
return nil
continue
}

name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string))
Expand All @@ -101,7 +101,7 @@ func testSweepNetappBackupVault(region string) error {
deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err)
return nil
continue
}
deleteUrl = deleteUrl + name

Expand Down
10 changes: 5 additions & 5 deletions google-beta/services/netapp/resource_netapp_kmsconfig_sweeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func testSweepNetappkmsconfig(region string) error {
listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err)
return nil
continue
}

res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Expand All @@ -69,13 +69,13 @@ func testSweepNetappkmsconfig(region string) error {
})
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err)
return nil
continue
}

resourceList, ok := res["kmsconfigs"]
if !ok {
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
return nil
continue
}

rl := resourceList.([]interface{})
Expand All @@ -87,7 +87,7 @@ func testSweepNetappkmsconfig(region string) error {
obj := ri.(map[string]interface{})
if obj["name"] == nil {
log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName)
return nil
continue
}

name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string))
Expand All @@ -101,7 +101,7 @@ func testSweepNetappkmsconfig(region string) error {
deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err)
return nil
continue
}
deleteUrl = deleteUrl + name

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func testSweepNetappStoragePool(region string) error {
listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err)
return nil
continue
}

res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Expand All @@ -69,13 +69,13 @@ func testSweepNetappStoragePool(region string) error {
})
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err)
return nil
continue
}

resourceList, ok := res["storagePools"]
if !ok {
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
return nil
continue
}

rl := resourceList.([]interface{})
Expand All @@ -87,7 +87,7 @@ func testSweepNetappStoragePool(region string) error {
obj := ri.(map[string]interface{})
if obj["name"] == nil {
log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName)
return nil
continue
}

name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string))
Expand All @@ -101,7 +101,7 @@ func testSweepNetappStoragePool(region string) error {
deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err)
return nil
continue
}
deleteUrl = deleteUrl + name

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func testSweepNetappVolumeSnapshot(region string) error {
listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err)
return nil
continue
}

res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Expand All @@ -69,13 +69,13 @@ func testSweepNetappVolumeSnapshot(region string) error {
})
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err)
return nil
continue
}

resourceList, ok := res["volumeSnapshots"]
if !ok {
log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.")
return nil
continue
}

rl := resourceList.([]interface{})
Expand All @@ -87,7 +87,7 @@ func testSweepNetappVolumeSnapshot(region string) error {
obj := ri.(map[string]interface{})
if obj["name"] == nil {
log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName)
return nil
continue
}

name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string))
Expand All @@ -101,7 +101,7 @@ func testSweepNetappVolumeSnapshot(region string) error {
deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate)
if err != nil {
log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err)
return nil
continue
}
deleteUrl = deleteUrl + name

Expand Down

0 comments on commit 30be1ff

Please sign in to comment.