-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake.go
30 lines (24 loc) · 850 Bytes
/
fake.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
package kubernetes
import (
"github.com/golang/glog"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/tools/cache"
fcache "k8s.io/client-go/tools/cache/testing"
"sync"
)
func NewFakeK8sResourceManager() *K8sResourceManager {
glog.Info("Using fake kubernetes client")
result := &K8sResourceManager{
ClientSet: fake.NewSimpleClientset(),
mutex: &sync.RWMutex{},
labelTypeResourceMap: make(map[string]ResourcesOnLabel),
watchListMap: make(map[string]cache.ListerWatcher),
}
for resource, _ := range GetRESTClientMap(result.ClientSet) {
result.watchListMap[resource] = fcache.NewFakeControllerSource()
}
return result
}
func (manager *K8sResourceManager) GetListerWatcher(resourceType string) *fcache.FakeControllerSource {
return manager.watchListMap[resourceType].(*fcache.FakeControllerSource)
}