Refactoring multiple results
This commit is contained in:
parent
bad2c9f18d
commit
74482abc5b
|
@ -674,10 +674,14 @@ func getFloatingIPs(networkingClient *gophercloud.ServiceClient) ([]floatingips.
|
||||||
|
|
||||||
func getImageID(client *gophercloud.ServiceClient, d *schema.ResourceData) (string, error) {
|
func getImageID(client *gophercloud.ServiceClient, d *schema.ResourceData) (string, error) {
|
||||||
imageId := d.Get("image_id").(string)
|
imageId := d.Get("image_id").(string)
|
||||||
imageName := d.Get("image_name").(string)
|
|
||||||
imageCount := 0
|
|
||||||
|
|
||||||
if imageId == "" && imageName != "" {
|
if imageId != "" {
|
||||||
|
return imageId, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
imageCount := 0
|
||||||
|
imageName := d.Get("image_name").(string)
|
||||||
|
if imageName != "" {
|
||||||
pager := images.ListDetail(client, &images.ListOpts{
|
pager := images.ListDetail(client, &images.ListOpts{
|
||||||
Name: imageName,
|
Name: imageName,
|
||||||
})
|
})
|
||||||
|
@ -705,11 +709,5 @@ func getImageID(client *gophercloud.ServiceClient, d *schema.ResourceData) (stri
|
||||||
return "", fmt.Errorf("Found %d images matching %s", imageCount, imageName)
|
return "", fmt.Errorf("Found %d images matching %s", imageCount, imageName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if imageId == "" && imageName == "" {
|
|
||||||
return "", fmt.Errorf("Neither an image ID nor an image name were able to be determined.")
|
return "", fmt.Errorf("Neither an image ID nor an image name were able to be determined.")
|
||||||
}
|
|
||||||
|
|
||||||
return imageId, nil
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue