-
Notifications
You must be signed in to change notification settings - Fork 5
/
list.go
28 lines (23 loc) · 920 Bytes
/
list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package configmap
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// ListByLabel list configmaps by labels.
func (h *Handler) ListByLabel(labels string) (*corev1.ConfigMapList, error) {
listOptions := h.Options.ListOptions.DeepCopy()
listOptions.LabelSelector = labels
return h.clientset.CoreV1().ConfigMaps(h.namespace).List(h.ctx, *listOptions)
}
// List list configmaps by labels, alias to "ListByLabel".
func (h *Handler) List(labels string) (*corev1.ConfigMapList, error) {
return h.ListByLabel(labels)
}
// ListByNamespace list configmaps by namespace.
func (h *Handler) ListByNamespace(namespace string) (*corev1.ConfigMapList, error) {
return h.WithNamespace(namespace).ListByLabel("")
}
// ListAll list all configmaps in the k8s cluster.
func (h *Handler) ListAll() (*corev1.ConfigMapList, error) {
return h.WithNamespace(metav1.NamespaceAll).ListByLabel("")
}