Skip to content

Commit 9b6ca98

Browse files
committed
Remove interface from GetAdminServiceClient
Refactor the change added in this branch to pick the right bundle internally based on KeystoneAPI spec instead of making callers of GetAdminServiceClient figure that out. The client will continue to default to the internal interface, but use the public interface when using an external Keytone API.
1 parent d2f5f27 commit 9b6ca98

File tree

3 files changed

+2
-17
lines changed

3 files changed

+2
-17
lines changed

api/v1beta1/keystoneapi.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ func GetAdminServiceClient(
121121
ctx context.Context,
122122
h *helper.Helper,
123123
keystoneAPI *KeystoneAPI,
124-
endpointInterface ...endpoint.Endpoint,
125124
) (*openstack.OpenStack, ctrl.Result, error) {
126125
os, ctrlResult, err := GetScopedAdminServiceClient(
127126
ctx,
@@ -130,7 +129,6 @@ func GetAdminServiceClient(
130129
&gophercloud.AuthScope{
131130
System: true,
132131
},
133-
endpointInterface...,
134132
)
135133
if err != nil {
136134
return nil, ctrlResult, err
@@ -145,13 +143,12 @@ func GetScopedAdminServiceClient(
145143
h *helper.Helper,
146144
keystoneAPI *KeystoneAPI,
147145
scope *gophercloud.AuthScope,
148-
endpointInterface ...endpoint.Endpoint,
149146
) (*openstack.OpenStack, ctrl.Result, error) {
150147
// get endpoint as authurl from keystone instance
151148
// default to internal endpoint if not specified
152149
epInterface := endpoint.EndpointInternal
153-
if len(endpointInterface) > 0 {
154-
epInterface = endpoint.Endpoint(endpointInterface[0])
150+
if keystoneAPI.Spec.ExternalKeystoneAPI {
151+
epInterface = endpoint.Endpoint(endpoint.EndpointPublic)
155152
}
156153
authURL, err := keystoneAPI.GetEndpoint(epInterface)
157154
if err != nil {

internal/controller/keystoneendpoint_controller.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"github.com/go-logr/logr"
3333
keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
3434
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
35-
"github.com/openstack-k8s-operators/lib-common/modules/common/endpoint"
3635
helper "github.com/openstack-k8s-operators/lib-common/modules/common/helper"
3736
util "github.com/openstack-k8s-operators/lib-common/modules/common/util"
3837
openstack "github.com/openstack-k8s-operators/lib-common/modules/openstack"
@@ -213,15 +212,10 @@ func (r *KeystoneEndpointReconciler) Reconcile(ctx context.Context, req ctrl.Req
213212
//
214213
// get admin authentication OpenStack
215214
//
216-
adminInterface := endpoint.EndpointInternal
217-
if keystoneAPI.Spec.ExternalKeystoneAPI {
218-
adminInterface = endpoint.EndpointPublic
219-
}
220215
os, ctrlResult, err := keystonev1.GetAdminServiceClient(
221216
ctx,
222217
helper,
223218
keystoneAPI,
224-
adminInterface,
225219
)
226220
if err != nil {
227221
instance.Status.Conditions.Set(condition.FalseCondition(

internal/controller/keystoneservice_controller.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/go-logr/logr"
2626
keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
2727
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
28-
endpoint "github.com/openstack-k8s-operators/lib-common/modules/common/endpoint"
2928
helper "github.com/openstack-k8s-operators/lib-common/modules/common/helper"
3029
secret "github.com/openstack-k8s-operators/lib-common/modules/common/secret"
3130

@@ -215,15 +214,10 @@ func (r *KeystoneServiceReconciler) Reconcile(ctx context.Context, req ctrl.Requ
215214
//
216215
// get admin authentication OpenStack
217216
//
218-
adminInterface := endpoint.EndpointInternal
219-
if keystoneAPI.Spec.ExternalKeystoneAPI {
220-
adminInterface = endpoint.EndpointPublic
221-
}
222217
os, ctrlResult, err := keystonev1.GetAdminServiceClient(
223218
ctx,
224219
helper,
225220
keystoneAPI,
226-
adminInterface,
227221
)
228222
if err != nil {
229223
instance.Status.Conditions.Set(condition.FalseCondition(

0 commit comments

Comments
 (0)