Skip to content

Commit 6f54843

Browse files
openstack/clientconfig/requests.go: make sure tls config is generated before creating authenticated client (#140)
Previously the function would call AuthenticatedClient function which would try authenitcating without the appropiate tls configuration. Since the function is public, changing it's behavior would be not ideal, so I have moved the 2 steps of creating provider client and authenticating it into this functions itself. So now the function creates a provider client, updates the HTTPClient to correct tls configuration and uses that to authenticate.
1 parent 19f764e commit 6f54843

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

openstack/clientconfig/requests.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -744,12 +744,6 @@ func NewServiceClient(service string, opts *ClientOpts) (*gophercloud.ServiceCli
744744
}
745745
}
746746

747-
// Get a Provider Client
748-
pClient, err := AuthenticatedClient(opts)
749-
if err != nil {
750-
return nil, err
751-
}
752-
753747
// Check if a custom CA cert was provided.
754748
// First, check if the CACERT environment variable is set.
755749
var caCertPath string
@@ -796,6 +790,16 @@ func NewServiceClient(service string, opts *ClientOpts) (*gophercloud.ServiceCli
796790
return nil, err
797791
}
798792

793+
// Get a Provider Client
794+
ao, err := AuthOptions(opts)
795+
if err != nil {
796+
return nil, err
797+
}
798+
pClient, err := openstack.NewClient(ao.IdentityEndpoint)
799+
if err != nil {
800+
return nil, err
801+
}
802+
799803
// If an HTTPClient was specified, use it.
800804
if opts.HTTPClient != nil {
801805
pClient.HTTPClient = *opts.HTTPClient
@@ -808,6 +812,11 @@ func NewServiceClient(service string, opts *ClientOpts) (*gophercloud.ServiceCli
808812
}
809813
}
810814

815+
err = openstack.Authenticate(pClient, *ao)
816+
if err != nil {
817+
return nil, err
818+
}
819+
811820
// Determine the region to use.
812821
// First, check if the REGION_NAME environment variable is set.
813822
var region string

0 commit comments

Comments
 (0)