refactor: using interfaces for accessing tenant namespaces

This commit is contained in:
Dario Tranchitella
2022-10-13 15:48:38 +02:00
parent 4835b94839
commit 360a8d2b56
3 changed files with 28 additions and 0 deletions

View File

@@ -72,3 +72,13 @@ type TenantList struct {
func init() {
SchemeBuilder.Register(&Tenant{}, &TenantList{})
}
func (in *Tenant) GetNamespaces() (res []string) {
res = make([]string, 0, len(in.Status.Namespaces))
for _, ns := range in.Status.Namespaces {
res = append(res, ns)
}
return
}

View File

@@ -62,6 +62,16 @@ type Tenant struct {
Status TenantStatus `json:"status,omitempty"`
}
func (in *Tenant) GetNamespaces() (res []string) {
res = make([]string, 0, len(in.Status.Namespaces))
for _, ns := range in.Status.Namespaces {
res = append(res, ns)
}
return
}
//+kubebuilder:object:root=true
// TenantList contains a list of Tenant.

View File

@@ -0,0 +1,8 @@
// Copyright 2020-2021 Clastix Labs
// SPDX-License-Identifier: Apache-2.0
package api
type Tenant interface {
GetNamespaces() []string
}