forked from moby/swarmkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
by.go
123 lines (88 loc) · 2.36 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
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 byCN string
func (b byCN) isBy() {
}
// ByCN creates an object to pass to Find to select by CN.
func ByCN(name string) By {
return byCN(name)
}
type byService string
func (b byService) isBy() {
}
// 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 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)
}