forked from moby/swarmkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
by.go
214 lines (158 loc) · 4.33 KB
/
by.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
package store
import "github.com/docker/swarmkit/api"
// By is an interface type passed to Find methods. Implementations must be
// defined in this package.
type By interface {
// isBy allows this interface to only be satisfied by certain internal
// types.
isBy()
}
type byAll struct{}
func (a byAll) isBy() {
}
// All is an argument that can be passed to find to list all items in the
// set.
var All byAll
type byNamePrefix string
func (b byNamePrefix) isBy() {
}
// ByNamePrefix creates an object to pass to Find to select by query.
func ByNamePrefix(namePrefix string) By {
return byNamePrefix(namePrefix)
}
type byIDPrefix string
func (b byIDPrefix) isBy() {
}
// ByIDPrefix creates an object to pass to Find to select by query.
func ByIDPrefix(idPrefix string) By {
return byIDPrefix(idPrefix)
}
type byName string
func (b byName) isBy() {
}
// ByName creates an object to pass to Find to select by name.
func ByName(name string) By {
return byName(name)
}
type byService string
func (b byService) isBy() {
}
type byRuntime string
func (b byRuntime) isBy() {
}
// ByRuntime creates an object to pass to Find to select by runtime.
func ByRuntime(runtime string) By {
return byRuntime(runtime)
}
// ByServiceID creates an object to pass to Find to select by service.
func ByServiceID(serviceID string) By {
return byService(serviceID)
}
type byNode string
func (b byNode) isBy() {
}
// ByNodeID creates an object to pass to Find to select by node.
func ByNodeID(nodeID string) By {
return byNode(nodeID)
}
type bySlot struct {
serviceID string
slot uint64
}
func (b bySlot) isBy() {
}
// BySlot creates an object to pass to Find to select by slot.
func BySlot(serviceID string, slot uint64) By {
return bySlot{serviceID: serviceID, slot: slot}
}
type byDesiredState api.TaskState
func (b byDesiredState) isBy() {
}
// ByDesiredState creates an object to pass to Find to select by desired state.
func ByDesiredState(state api.TaskState) By {
return byDesiredState(state)
}
type byTaskState api.TaskState
func (b byTaskState) isBy() {
}
// ByTaskState creates an object to pass to Find to select by task state.
func ByTaskState(state api.TaskState) By {
return byTaskState(state)
}
type byRole api.NodeRole
func (b byRole) isBy() {
}
// ByRole creates an object to pass to Find to select by role.
func ByRole(role api.NodeRole) By {
return byRole(role)
}
type byMembership api.NodeSpec_Membership
func (b byMembership) isBy() {
}
// ByMembership creates an object to pass to Find to select by Membership.
func ByMembership(membership api.NodeSpec_Membership) By {
return byMembership(membership)
}
type byReferencedNetworkID string
func (b byReferencedNetworkID) isBy() {
}
// ByReferencedNetworkID creates an object to pass to Find to search for a
// service or task that references a network with the given ID.
func ByReferencedNetworkID(networkID string) By {
return byReferencedNetworkID(networkID)
}
type byReferencedSecretID string
func (b byReferencedSecretID) isBy() {
}
// ByReferencedSecretID creates an object to pass to Find to search for a
// service or task that references a secret with the given ID.
func ByReferencedSecretID(secretID string) By {
return byReferencedSecretID(secretID)
}
type byReferencedConfigID string
func (b byReferencedConfigID) isBy() {
}
// ByReferencedConfigID creates an object to pass to Find to search for a
// service or task that references a config with the given ID.
func ByReferencedConfigID(configID string) By {
return byReferencedConfigID(configID)
}
type byKind string
func (b byKind) isBy() {
}
// ByKind creates an object to pass to Find to search for a Resource of a
// particular kind.
func ByKind(kind string) By {
return byKind(kind)
}
type byCustom struct {
objType string
index string
value string
}
func (b byCustom) isBy() {
}
// ByCustom creates an object to pass to Find to search a custom index.
func ByCustom(objType, index, value string) By {
return byCustom{
objType: objType,
index: index,
value: value,
}
}
type byCustomPrefix struct {
objType string
index string
value string
}
func (b byCustomPrefix) isBy() {
}
// ByCustomPrefix creates an object to pass to Find to search a custom index by
// a value prefix.
func ByCustomPrefix(objType, index, value string) By {
return byCustomPrefix{
objType: objType,
index: index,
value: value,
}
}