Skip to content

Commit 4d5526d

Browse files
committed
Provide detailed error when entered VPC cannot be found
1 parent d0738a8 commit 4d5526d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: pkg/asset/installconfig/powervs/client.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -587,28 +587,28 @@ func (c *Client) GetVPCByName(ctx context.Context, vpcName string) (*vpcv1.VPC,
587587
if err != nil {
588588
return nil, fmt.Errorf("failed to list vpc regions: %w", err)
589589
}
590-
590+
var vpcNamesList []string
591591
for _, region := range listRegionsResponse.Regions {
592592
err := c.vpcAPI.SetServiceURL(fmt.Sprintf("%s/v1", *region.Endpoint))
593593
if err != nil {
594594
return nil, fmt.Errorf("failed to set vpc api service url: %w", err)
595595
}
596-
597596
vpcs, detailedResponse, err := c.vpcAPI.ListVpcsWithContext(ctx, c.vpcAPI.NewListVpcsOptions())
598597
if err != nil {
599598
if detailedResponse.GetStatusCode() != http.StatusNotFound {
600599
return nil, err
601600
}
602601
} else {
603602
for _, vpc := range vpcs.Vpcs {
603+
vpcNamesList = append(vpcNamesList, *vpc.Name)
604604
if *vpc.Name == vpcName {
605605
return &vpc, nil
606606
}
607607
}
608608
}
609609
}
610610

611-
return nil, errors.New("failed to find VPC")
611+
return nil, errors.New(fmt.Sprint("failed to find VPC. VPC name entered in platform.powervs.vpcName ", vpcName, " is not among ", vpcNamesList))
612612
}
613613

614614
// GetPublicGatewayByVPC gets all PublicGateways in a region

0 commit comments

Comments
 (0)