Skip to content

Commit

Permalink
raising an exception when creating client failed (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiChangkuo authored Apr 9, 2020
1 parent 5c3c899 commit 6c6f749
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 1 deletion.
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_antiddos_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ func dataSourceAntiDdosV1() *schema.Resource {
func dataSourceAntiDdosV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
antiddosClient, err := config.antiddosV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating antiddos client: %s", err)
}

listStatusOpts := antiddos.ListStatusOpts{
FloatingIpId: d.Get("floating_ip_id").(string),
Expand Down
1 change: 0 additions & 1 deletion huaweicloud/data_source_huaweicloud_cce_cluster_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func dataSourceCCEClusterV3() *schema.Resource {
func dataSourceCCEClusterV3Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
cceClient, err := config.cceV3Client(GetRegion(d, config))

if err != nil {
return fmt.Errorf("Unable to create HuaweiCloud CCE client : %s", err)
}
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_csbs_backup_policy_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func dataSourceCSBSBackupPolicyV1() *schema.Resource {
func dataSourceCSBSBackupPolicyV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
policyClient, err := config.csbsV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating csbs client: %s", err)
}

listOpts := policies.ListOpts{
ID: d.Get("id").(string),
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_csbs_backup_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ func dataSourceCSBSBackupV1() *schema.Resource {
func dataSourceCSBSBackupV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
backupClient, err := config.csbsV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating csbs client: %s", err)
}

listOpts := backup.ListOpts{
ID: d.Get("id").(string),
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_cts_tracker_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func dataSourceCTSTrackerV1() *schema.Resource {
func dataSourceCTSTrackerV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
trackerClient, err := config.ctsV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating cts Client: %s", err)
}

listOpts := tracker.ListOpts{
TrackerName: d.Get("tracker_name").(string),
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_networking_network_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func dataSourceNetworkingNetworkV2() *schema.Resource {
func dataSourceNetworkingNetworkV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating HuaweiCloud networking client: %s", err)
}

listOpts := networks.ListOpts{
ID: d.Get("network_id").(string),
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_networking_secgroup_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func dataSourceNetworkingSecGroupV2() *schema.Resource {
func dataSourceNetworkingSecGroupV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating HuaweiCloud networking client: %s", err)
}

listOpts := groups.ListOpts{
ID: d.Get("secgroup_id").(string),
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_networking_subnet_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ func dataSourceNetworkingSubnetV2() *schema.Resource {
func dataSourceNetworkingSubnetV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
networkingClient, err := config.networkingV2Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating HuaweiCloud networking client: %s", err)
}

listOpts := subnets.ListOpts{}

Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_rts_software_config_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ func dataSourceRtsSoftwareConfigV1() *schema.Resource {
func dataSourceRtsSoftwareConfigV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
orchestrationClient, err := config.orchestrationV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating HuaweiCloud rts client: %s", err)
}

n, err := softwareconfig.Get(orchestrationClient, d.Get("id").(string)).Extract()
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_rts_stack_resource_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func dataSourceRTSStackResourcesV1() *schema.Resource {
func dataSourceRTSStackResourcesV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
orchestrationClient, err := config.orchestrationV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating HuaweiCloud rts client: %s", err)
}

listOpts := stackresources.ListOpts{
Name: d.Get("resource_name").(string),
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_sfs_file_system_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ func dataSourceSFSFileSystemV2() *schema.Resource {
func dataSourceSFSFileSystemV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
sfsClient, err := config.sfsV2Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating Huaweicloud SFS Client: %s", err)
}

listOpts := shares.ListOpts{
ID: d.Get("id").(string),
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_vbs_backup_policy_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func dataSourceVBSBackupPolicyV2() *schema.Resource {
func dataSourceVBSPolicyV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
vbsClient, err := config.vbsV2Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating huaweicloud vbs client: %s", err)
}

policyID := d.Get("id").(string)
rawTags := d.Get("filter_tags").(*schema.Set).List()
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_vbs_backup_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ func dataSourceVBSBackupV2() *schema.Resource {
func dataSourceVBSBackupV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
vbsClient, err := config.vbsV2Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating huaweicloud vbs client: %s", err)
}

listOpts := backups.ListOpts{
Id: d.Get("id").(string),
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_vpc_ids_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func dataSourceVirtualPrivateCloudVpcIdsV1() *schema.Resource {
func dataSourceVirtualPrivateCloudIdsV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
vpcClient, err := config.networkingV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating Huaweicloud Vpc client: %s", err)
}

listOpts := vpcs.ListOpts{}
refinedVpcs, err := vpcs.List(vpcClient, listOpts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func dataSourceVpcPeeringConnectionV2() *schema.Resource {
func dataSourceVpcPeeringConnectionV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
peeringClient, err := config.networkingHwV2Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating Huaweicloud Vpc client: %s", err)
}

listOpts := peerings.ListOpts{
ID: d.Get("id").(string),
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_vpc_route_ids_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func dataSourceVPCRouteIdsV2() *schema.Resource {
func dataSourceVpcRouteIdsV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
vpcRouteClient, err := config.networkingHwV2Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating Huaweicloud Vpc client: %s", err)
}

listOpts := routes.ListOpts{
VPC_ID: d.Get("vpc_id").(string),
Expand Down
4 changes: 4 additions & 0 deletions huaweicloud/data_source_huaweicloud_vpc_route_v2_.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func dataSourceVPCRouteV2() *schema.Resource {
func dataSourceVpcRouteV2Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
vpcRouteClient, err := config.networkingHwV2Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating Huaweicloud Vpc client: %s", err)
}

listOpts := routes.ListOpts{
Type: d.Get("type").(string),
Destination: d.Get("destination").(string),
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_vpc_subnet_ids_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func dataSourceVpcSubnetIdsV1() *schema.Resource {
func dataSourceVpcSubnetIdsV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
subnetClient, err := config.networkingV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating Huaweicloud Vpc client: %s", err)
}

listOpts := subnets.ListOpts{
VPC_ID: d.Get("vpc_id").(string),
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_vpc_subnet_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ func dataSourceVpcSubnetV1() *schema.Resource {
func dataSourceVpcSubnetV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
subnetClient, err := config.networkingV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating Huaweicloud Vpc client: %s", err)
}

listOpts := subnets.ListOpts{
ID: d.Get("id").(string),
Expand Down
3 changes: 3 additions & 0 deletions huaweicloud/data_source_huaweicloud_vpc_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ func dataSourceVirtualPrivateCloudVpcV1() *schema.Resource {
func dataSourceVirtualPrivateCloudV1Read(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
vpcClient, err := config.networkingV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating Huaweicloud Vpc client: %s", err)
}

listOpts := vpcs.ListOpts{
ID: d.Get("id").(string),
Expand Down

0 comments on commit 6c6f749

Please sign in to comment.