forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.go
113 lines (103 loc) · 3.82 KB
/
types.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
/*
* This file is part of the KubeVirt project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright 2019 Red Hat, Inc.
*
*/
package util
import (
"k8s.io/client-go/tools/cache"
"kubevirt.io/kubevirt/pkg/controller"
)
type Stores struct {
ServiceAccountCache cache.Store
ClusterRoleCache cache.Store
ClusterRoleBindingCache cache.Store
RoleCache cache.Store
RoleBindingCache cache.Store
CrdCache cache.Store
ServiceCache cache.Store
DeploymentCache cache.Store
DaemonSetCache cache.Store
}
func (s *Stores) AllEmpty() bool {
return IsStoreEmpty(s.ServiceAccountCache) &&
IsStoreEmpty(s.ClusterRoleCache) &&
IsStoreEmpty(s.ClusterRoleBindingCache) &&
IsStoreEmpty(s.RoleCache) &&
IsStoreEmpty(s.RoleBindingCache) &&
IsStoreEmpty(s.CrdCache) &&
IsStoreEmpty(s.ServiceCache) &&
IsStoreEmpty(s.DeploymentCache) &&
IsStoreEmpty(s.DaemonSetCache)
}
func IsStoreEmpty(store cache.Store) bool {
return len(store.ListKeys()) == 0
}
type Expectations struct {
ServiceAccount *controller.UIDTrackingControllerExpectations
ClusterRole *controller.UIDTrackingControllerExpectations
ClusterRoleBinding *controller.UIDTrackingControllerExpectations
Role *controller.UIDTrackingControllerExpectations
RoleBinding *controller.UIDTrackingControllerExpectations
Crd *controller.UIDTrackingControllerExpectations
Service *controller.UIDTrackingControllerExpectations
Deployment *controller.UIDTrackingControllerExpectations
DaemonSet *controller.UIDTrackingControllerExpectations
}
type Informers struct {
ServiceAccount cache.SharedIndexInformer
ClusterRole cache.SharedIndexInformer
ClusterRoleBinding cache.SharedIndexInformer
Role cache.SharedIndexInformer
RoleBinding cache.SharedIndexInformer
Crd cache.SharedIndexInformer
Service cache.SharedIndexInformer
Deployment cache.SharedIndexInformer
DaemonSet cache.SharedIndexInformer
}
func (e *Expectations) DeleteExpectations(key string) {
e.ServiceAccount.DeleteExpectations(key)
e.ClusterRole.DeleteExpectations(key)
e.ClusterRoleBinding.DeleteExpectations(key)
e.Role.DeleteExpectations(key)
e.RoleBinding.DeleteExpectations(key)
e.Crd.DeleteExpectations(key)
e.Service.DeleteExpectations(key)
e.Deployment.DeleteExpectations(key)
e.DaemonSet.DeleteExpectations(key)
}
func (e *Expectations) ResetExpectations(key string) {
e.ServiceAccount.SetExpectations(key, 0, 0)
e.ClusterRole.SetExpectations(key, 0, 0)
e.ClusterRoleBinding.SetExpectations(key, 0, 0)
e.Role.SetExpectations(key, 0, 0)
e.RoleBinding.SetExpectations(key, 0, 0)
e.Crd.SetExpectations(key, 0, 0)
e.Service.SetExpectations(key, 0, 0)
e.Deployment.SetExpectations(key, 0, 0)
e.DaemonSet.SetExpectations(key, 0, 0)
}
func (e *Expectations) SatisfiedExpectations(key string) bool {
return e.ServiceAccount.SatisfiedExpectations(key) &&
e.ClusterRole.SatisfiedExpectations(key) &&
e.ClusterRoleBinding.SatisfiedExpectations(key) &&
e.Role.SatisfiedExpectations(key) &&
e.RoleBinding.SatisfiedExpectations(key) &&
e.Crd.SatisfiedExpectations(key) &&
e.Service.SatisfiedExpectations(key) &&
e.Deployment.SatisfiedExpectations(key) &&
e.DaemonSet.SatisfiedExpectations(key)
}