-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkclient.go
41 lines (36 loc) · 868 Bytes
/
kclient.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
// kclient.go is WiP for experimental and testing purposes only.
package k8s
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
)
// KClient is the abstraction interface for interacting with k8s resources.
type KClient struct {
cs *kubernetes.Clientset
ns string
listOpts metav1.ListOptions
}
// SetNS sets the namespace to operate within, defaults to all
func (kc *KClient) setNS(ns string) {
kc.ns = ns
}
// NewKClient returns a new RawClient
func newKClient(inCluster bool) (*KClient, error) {
var kc KClient
if inCluster {
cs, err := CreateICClientSet()
if err != nil {
return &kc, err
}
kc.cs = cs
kc.listOpts = metav1.ListOptions{}
return &kc, nil
}
cs, err := CreateOCClientSet()
if err != nil {
return &kc, err
}
kc.cs = cs
kc.listOpts = metav1.ListOptions{}
return &kc, nil
}