mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-02-14 18:09:58 +00:00
refactor: using interfaces for accessing tenant namespaces
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
8
pkg/api/status_namespaces.go
Normal file
8
pkg/api/status_namespaces.go
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright 2020-2021 Clastix Labs
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package api
|
||||
|
||||
type Tenant interface {
|
||||
GetNamespaces() []string
|
||||
}
|
||||
Reference in New Issue
Block a user