github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/swarmkit/manager/state/store/by.go (about)

     1  package store
     2  
     3  import "github.com/docker/swarmkit/api"
     4  
     5  // By is an interface type passed to Find methods. Implementations must be
     6  // defined in this package.
     7  type By interface {
     8  	// isBy allows this interface to only be satisfied by certain internal
     9  	// types.
    10  	isBy()
    11  }
    12  
    13  type byAll struct{}
    14  
    15  func (a byAll) isBy() {
    16  }
    17  
    18  // All is an argument that can be passed to find to list all items in the
    19  // set.
    20  var All byAll
    21  
    22  type byNamePrefix string
    23  
    24  func (b byNamePrefix) isBy() {
    25  }
    26  
    27  // ByNamePrefix creates an object to pass to Find to select by query.
    28  func ByNamePrefix(namePrefix string) By {
    29  	return byNamePrefix(namePrefix)
    30  }
    31  
    32  type byIDPrefix string
    33  
    34  func (b byIDPrefix) isBy() {
    35  }
    36  
    37  // ByIDPrefix creates an object to pass to Find to select by query.
    38  func ByIDPrefix(idPrefix string) By {
    39  	return byIDPrefix(idPrefix)
    40  }
    41  
    42  type byName string
    43  
    44  func (b byName) isBy() {
    45  }
    46  
    47  // ByName creates an object to pass to Find to select by name.
    48  func ByName(name string) By {
    49  	return byName(name)
    50  }
    51  
    52  type byService string
    53  
    54  func (b byService) isBy() {
    55  }
    56  
    57  type byRuntime string
    58  
    59  func (b byRuntime) isBy() {
    60  }
    61  
    62  // ByRuntime creates an object to pass to Find to select by runtime.
    63  func ByRuntime(runtime string) By {
    64  	return byRuntime(runtime)
    65  }
    66  
    67  // ByServiceID creates an object to pass to Find to select by service.
    68  func ByServiceID(serviceID string) By {
    69  	return byService(serviceID)
    70  }
    71  
    72  type byNode string
    73  
    74  func (b byNode) isBy() {
    75  }
    76  
    77  // ByNodeID creates an object to pass to Find to select by node.
    78  func ByNodeID(nodeID string) By {
    79  	return byNode(nodeID)
    80  }
    81  
    82  type bySlot struct {
    83  	serviceID string
    84  	slot      uint64
    85  }
    86  
    87  func (b bySlot) isBy() {
    88  }
    89  
    90  // BySlot creates an object to pass to Find to select by slot.
    91  func BySlot(serviceID string, slot uint64) By {
    92  	return bySlot{serviceID: serviceID, slot: slot}
    93  }
    94  
    95  type byDesiredState api.TaskState
    96  
    97  func (b byDesiredState) isBy() {
    98  }
    99  
   100  // ByDesiredState creates an object to pass to Find to select by desired state.
   101  func ByDesiredState(state api.TaskState) By {
   102  	return byDesiredState(state)
   103  }
   104  
   105  type byTaskState api.TaskState
   106  
   107  func (b byTaskState) isBy() {
   108  }
   109  
   110  // ByTaskState creates an object to pass to Find to select by task state.
   111  func ByTaskState(state api.TaskState) By {
   112  	return byTaskState(state)
   113  }
   114  
   115  type byRole api.NodeRole
   116  
   117  func (b byRole) isBy() {
   118  }
   119  
   120  // ByRole creates an object to pass to Find to select by role.
   121  func ByRole(role api.NodeRole) By {
   122  	return byRole(role)
   123  }
   124  
   125  type byMembership api.NodeSpec_Membership
   126  
   127  func (b byMembership) isBy() {
   128  }
   129  
   130  // ByMembership creates an object to pass to Find to select by Membership.
   131  func ByMembership(membership api.NodeSpec_Membership) By {
   132  	return byMembership(membership)
   133  }
   134  
   135  type byReferencedNetworkID string
   136  
   137  func (b byReferencedNetworkID) isBy() {
   138  }
   139  
   140  // ByReferencedNetworkID creates an object to pass to Find to search for a
   141  // service or task that references a network with the given ID.
   142  func ByReferencedNetworkID(networkID string) By {
   143  	return byReferencedNetworkID(networkID)
   144  }
   145  
   146  type byReferencedSecretID string
   147  
   148  func (b byReferencedSecretID) isBy() {
   149  }
   150  
   151  // ByReferencedSecretID creates an object to pass to Find to search for a
   152  // service or task that references a secret with the given ID.
   153  func ByReferencedSecretID(secretID string) By {
   154  	return byReferencedSecretID(secretID)
   155  }
   156  
   157  type byReferencedConfigID string
   158  
   159  func (b byReferencedConfigID) isBy() {
   160  }
   161  
   162  // ByReferencedConfigID creates an object to pass to Find to search for a
   163  // service or task that references a config with the given ID.
   164  func ByReferencedConfigID(configID string) By {
   165  	return byReferencedConfigID(configID)
   166  }
   167  
   168  type byKind string
   169  
   170  func (b byKind) isBy() {
   171  }
   172  
   173  // ByKind creates an object to pass to Find to search for a Resource of a
   174  // particular kind.
   175  func ByKind(kind string) By {
   176  	return byKind(kind)
   177  }
   178  
   179  type byCustom struct {
   180  	objType string
   181  	index   string
   182  	value   string
   183  }
   184  
   185  func (b byCustom) isBy() {
   186  }
   187  
   188  // ByCustom creates an object to pass to Find to search a custom index.
   189  func ByCustom(objType, index, value string) By {
   190  	return byCustom{
   191  		objType: objType,
   192  		index:   index,
   193  		value:   value,
   194  	}
   195  }
   196  
   197  type byCustomPrefix struct {
   198  	objType string
   199  	index   string
   200  	value   string
   201  }
   202  
   203  func (b byCustomPrefix) isBy() {
   204  }
   205  
   206  // ByCustomPrefix creates an object to pass to Find to search a custom index by
   207  // a value prefix.
   208  func ByCustomPrefix(objType, index, value string) By {
   209  	return byCustomPrefix{
   210  		objType: objType,
   211  		index:   index,
   212  		value:   value,
   213  	}
   214  }