Skip to content

Commit

Permalink
Merge pull request #3285 from Fedosin/glance_url
Browse files Browse the repository at this point in the history
OpenStack: reuse the existing function to get glance public URL
  • Loading branch information
openshift-merge-robot committed Mar 13, 2020
2 parents 009d7b5 + 84ab7d1 commit 578abd8
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions pkg/tfvars/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"encoding/json"
"fmt"

"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack"
"github.com/gophercloud/gophercloud/openstack/identity/v3/tokens"
"github.com/gophercloud/gophercloud/openstack/imageservice/v2/images"
"github.com/gophercloud/utils/openstack/clientconfig"
Expand Down Expand Up @@ -155,26 +157,17 @@ func validateOverriddenImageName(imageName, cloud string) error {

// getGlancePublicURL obtains Glance public endpoint URL
func getGlancePublicURL(cloud string) (string, error) {
var glancePublicURL string
serviceCatalog, err := getServiceCatalog(cloud)
if err != nil {
return "", err
}

for _, svc := range serviceCatalog.Entries {
if svc.Type == "image" {
for _, e := range svc.Endpoints {
if e.Interface == "public" {
glancePublicURL = e.URL
break
}
}
break
}
}

if glancePublicURL == "" {
return "", errors.Errorf("cannot retrieve Glance URL from the service catalog")
glancePublicURL, err := openstack.V3EndpointURL(serviceCatalog, gophercloud.EndpointOpts{
Type: "image",
Availability: gophercloud.AvailabilityPublic,
})
if err != nil {
return "", errors.Errorf("cannot retrieve Glance URL from the service catalog: %v", err)
}

return glancePublicURL, nil
Expand Down

0 comments on commit 578abd8

Please sign in to comment.