/
list.go
152 lines (135 loc) · 5.08 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package kube
import (
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// ListNodes returns the list of nodes
func (c *Client) ListNodes() (*corev1.NodeList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.CoreV1().Nodes().List(metav1.ListOptions{})
}
// ListDaemonSets returns a list of daemonsets for a namespace, set to empty string to get from all
func (c *Client) ListDaemonSets(namespace string) (*appsv1.DaemonSetList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.AppsV1().DaemonSets(namespace).List(metav1.ListOptions{})
}
// ListStatefulSets returns a list of statefulsets for a namespace, set to empty string to get from all
func (c *Client) ListStatefulSets(namespace string) (*appsv1.StatefulSetList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.AppsV1().StatefulSets(namespace).List(metav1.ListOptions{})
}
// ListDeployments returns a list of deployments for a namespace, set to empty string to get from all
func (c *Client) ListDeployments(namespace string) (*appsv1.DeploymentList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.AppsV1().Deployments(namespace).List(metav1.ListOptions{})
}
// ListReplicaSets returns a list of deployments for a namespace, set to empty string to get from all
func (c *Client) ListReplicaSets(namespace string) (*appsv1.ReplicaSetList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.AppsV1().ReplicaSets(namespace).List(metav1.ListOptions{})
}
// ListServices returns a list of services for a namespace, set to empty string to get from all
func (c *Client) ListServices(namespace string) (*corev1.ServiceList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.CoreV1().Services(namespace).List(metav1.ListOptions{})
}
// ListEndpoints returns a list of endpoints for a namespace, set to empty string to get from all
func (c *Client) ListEndpoints(namespace string) (*corev1.EndpointsList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.CoreV1().Endpoints(namespace).List(metav1.ListOptions{})
}
// ListReplicationControllers returns a list of replication controllers for a namespace, set to empty string to get from all
func (c *Client) ListReplicationControllers(namespace string) (*corev1.ReplicationControllerList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.CoreV1().ReplicationControllers(namespace).List(metav1.ListOptions{})
}
// ListPods returns a list of pods for a namespace, set to empty string to get from all
func (c *Client) ListPods(namespace string) (*corev1.PodList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.CoreV1().Pods(namespace).List(metav1.ListOptions{})
}
// ListConfigMaps returns a list of configmaps for a namespace, set to empty string to get from all
func (c *Client) ListConfigMaps(namespace string) (*corev1.ConfigMapList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.CoreV1().ConfigMaps(namespace).List(metav1.ListOptions{})
}
// ListSecrets returns a list of secrets for a namespace, set to empty string to get from all
func (c *Client) ListSecrets(namespace string) (*corev1.SecretList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.CoreV1().Secrets(namespace).List(metav1.ListOptions{})
}
// ListServiceAccounts returns a list of service accounts for a namespace, set to empty string to get from all
func (c *Client) ListServiceAccounts(namespace string) (*corev1.ServiceAccountList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.CoreV1().ServiceAccounts(namespace).List(metav1.ListOptions{})
}
// ListPersistentVolumeClaims returns a list of persistent volume claims for a namespace, set to empty string to get from all
func (c *Client) ListPersistentVolumeClaims(namespace string) (*corev1.PersistentVolumeClaimList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.CoreV1().PersistentVolumeClaims(namespace).List(metav1.ListOptions{})
}
// ListPersistentVolumes returns a list of persistent volumes
func (c *Client) ListPersistentVolumes() (*corev1.PersistentVolumeList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.CoreV1().PersistentVolumes().List(metav1.ListOptions{})
}
// ListNamespaces returns a list of namespaces
func (c *Client) ListNamespaces() (*corev1.NamespaceList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.CoreV1().Namespaces().List(metav1.ListOptions{})
}
// ListJobs returns a list of jobs for a namespace, set to empty string to get from all
func (c *Client) ListJobs(namespace string) (*batchv1.JobList, error) {
err := c.ClientSet()
if err != nil {
return nil, err
}
return c.clientset.BatchV1().Jobs(namespace).List(metav1.ListOptions{})
}