Skip to content

Commit cbdfd1f

Browse files
Merge pull request #612 from ratailor/get-keystoneapi-byname
add GetKeystoneAPIByName function
2 parents e790d63 + 07ad1d8 commit cbdfd1f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

api/v1beta1/keystoneapi.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
openstack "github.com/openstack-k8s-operators/lib-common/modules/openstack"
3535
appsv1 "k8s.io/api/apps/v1"
3636
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
37+
"k8s.io/apimachinery/pkg/types"
3738
ctrl "sigs.k8s.io/controller-runtime"
3839
)
3940

@@ -100,6 +101,23 @@ func GetKeystoneAPI(
100101
return &keystoneList.Items[0], nil
101102
}
102103

104+
// GetKeystoneAPIByName - get keystoneAPI object by name and namespace
105+
func GetKeystoneAPIByName(
106+
ctx context.Context,
107+
h *helper.Helper,
108+
name string,
109+
namespace string,
110+
) (*KeystoneAPI, error) {
111+
keystoneAPI := &KeystoneAPI{}
112+
err := h.GetClient().Get(ctx, types.NamespacedName{Name: name, Namespace: namespace}, keystoneAPI)
113+
if err != nil {
114+
return nil, err
115+
}
116+
117+
return keystoneAPI, nil
118+
}
119+
120+
103121
// GetAdminServiceClient - get a system scoped admin serviceClient for the keystoneAPI instance
104122
func GetAdminServiceClient(
105123
ctx context.Context,

0 commit comments

Comments
 (0)