Skip to content

Commit 083fc65

Browse files
committed
cache namespaces
1 parent 00d23c5 commit 083fc65

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

modules/common/client/cache/client/core/core.go

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ func (in *Client) Secrets(namespace string) corev1.SecretInterface {
2525
return newSecrets(in, namespace, in.token)
2626
}
2727

28+
func (in *Client) Namespaces() corev1.NamespaceInterface {
29+
return newNamespaces(in, in.token)
30+
}
31+
2832
func (in *Client) Nodes() corev1.NodeInterface {
2933
return newNodes(in, in.token)
3034
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package core
2+
3+
import (
4+
"context"
5+
6+
corev1 "k8s.io/api/core/v1"
7+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
8+
authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1"
9+
v1 "k8s.io/client-go/kubernetes/typed/core/v1"
10+
11+
"k8s.io/dashboard/types"
12+
)
13+
14+
type namespaces struct {
15+
v1.NamespaceInterface
16+
17+
authorizationV1 authorizationv1.AuthorizationV1Interface
18+
token string
19+
}
20+
21+
func (in *namespaces) List(ctx context.Context, opts metav1.ListOptions) (*corev1.NamespaceList, error) {
22+
return NewCachedClusterScopedResourceLister[corev1.NamespaceList](
23+
in.authorizationV1,
24+
in.token,
25+
types.ResourceKindNamespace,
26+
).List(ctx, in.NamespaceInterface, opts)
27+
}
28+
29+
func newNamespaces(c *Client, token string) v1.NamespaceInterface {
30+
return &namespaces{c.CoreV1Client.Namespaces(), c.authorizationV1, token}
31+
}

0 commit comments

Comments
 (0)