Skip to content

Commit

Permalink
Merge pull request #403 from stuggi/system_scoped
Browse files Browse the repository at this point in the history
Use system scoped admin service client per default
  • Loading branch information
openshift-merge-bot[bot] committed Apr 16, 2024
2 parents 962427f + 9917f87 commit d8e4316
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion api/v1beta1/keystoneapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/url"
"time"

"github.com/gophercloud/gophercloud"
"github.com/openstack-k8s-operators/lib-common/modules/common/endpoint"
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
Expand Down Expand Up @@ -69,11 +70,33 @@ func GetKeystoneAPI(
return &keystoneList.Items[0], nil
}

// GetAdminServiceClient - get an admin serviceClient for the keystoneAPI instance
// GetAdminServiceClient - get a system scoped admin serviceClient for the keystoneAPI instance
func GetAdminServiceClient(
ctx context.Context,
h *helper.Helper,
keystoneAPI *KeystoneAPI,
) (*openstack.OpenStack, ctrl.Result, error) {
os, ctrlResult, err := GetScopedAdminServiceClient(
ctx,
h,
keystoneAPI,
&gophercloud.AuthScope{
System: true,
},
)
if err != nil {
return nil, ctrlResult, err
}

return os, ctrlResult, nil
}

// GetScopedAdminServiceClient - get a scoped admin serviceClient for the keystoneAPI instance
func GetScopedAdminServiceClient(
ctx context.Context,
h *helper.Helper,
keystoneAPI *KeystoneAPI,
scope *gophercloud.AuthScope,
) (*openstack.OpenStack, ctrl.Result, error) {
// get public endpoint as authurl from keystone instance
authURL, err := keystoneAPI.GetEndpoint(endpoint.EndpointInternal)
Expand Down Expand Up @@ -118,6 +141,7 @@ func GetAdminServiceClient(
DomainName: "Default",
Region: keystoneAPI.Spec.Region,
TLS: tlsConfig,
Scope: scope,
})
if err != nil {
return nil, ctrl.Result{}, err
Expand Down

0 comments on commit d8e4316

Please sign in to comment.