-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(sweeper): add sweeper base function #1959
Conversation
6fb0c12
to
75d5b47
Compare
f6bf12e
to
aecc096
Compare
aecc096
to
bb6161f
Compare
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/config" | ||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/utils/fmtp" | ||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/utils/logp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with fmt and log
|
||
err := initProviderConfig() | ||
if err != nil { | ||
logp.Printf("[ERROR]Error init huaweicloud provider config: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace with log
config := acceptance.TestAccProvider.Meta().(*config.Config) | ||
rmsClient, err := config.RmsV1Client(region) | ||
if err != nil { | ||
logp.Printf("Error creating RMS client: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
pages, err := resources.List(rmsClient, resources.ListOpts{Region: region}).AllPages() | ||
|
||
if err != nil { | ||
logp.Printf("Unable to retrieve all resources in the region %s:%s ", region, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
|
||
allResources, err := resources.ExtractResources(pages) | ||
if err != nil { | ||
logp.Printf("Unable to retrieve all resources in the region %s:%s ", region, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
SweepResourcesList["unKnow_resources"] = append(b, v) | ||
} | ||
} | ||
logp.Printf("[WARN]%d resource is not in sweeper, please check: %s ", len(SweepResourcesList), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
raw := make(map[string]interface{}) | ||
diags := testProvider.Configure(context.Background(), terraform.NewResourceConfigRaw(raw)) | ||
if diags.HasError() { | ||
return fmtp.Errorf("Unexpected error when configure HuaweiCloud provider: %s", diags[0].Summary) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace with fmt
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance/sweep" | ||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/vpc" | ||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/utils/fmtp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
config := acceptance.TestAccProvider.Meta().(*config.Config) | ||
client, err := config.NetworkingV1Client(region) | ||
if err != nil { | ||
return fmtp.Errorf("Error creating huaweicloud vpc client: %s", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
What this PR does / why we need it:
Which issue this PR fixes:
(optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged)fixes #1951
Special notes for your reviewer:
Release note:
PR Checklist
Acceptance Steps Performed