repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
docker/swarmkit | manager/state/store/secrets.go | FindSecrets | func FindSecrets(tx ReadTx, by By) ([]*api.Secret, error) {
checkType := func(by By) error {
switch by.(type) {
case byName, byNamePrefix, byIDPrefix, byCustom, byCustomPrefix:
return nil
default:
return ErrInvalidFindBy
}
}
secretList := []*api.Secret{}
appendResult := func(o api.StoreObject) {
se... | go | func FindSecrets(tx ReadTx, by By) ([]*api.Secret, error) {
checkType := func(by By) error {
switch by.(type) {
case byName, byNamePrefix, byIDPrefix, byCustom, byCustomPrefix:
return nil
default:
return ErrInvalidFindBy
}
}
secretList := []*api.Secret{}
appendResult := func(o api.StoreObject) {
se... | [
"func",
"FindSecrets",
"(",
"tx",
"ReadTx",
",",
"by",
"By",
")",
"(",
"[",
"]",
"*",
"api",
".",
"Secret",
",",
"error",
")",
"{",
"checkType",
":=",
"func",
"(",
"by",
"By",
")",
"error",
"{",
"switch",
"by",
".",
"(",
"type",
")",
"{",
"case... | // FindSecrets selects a set of secrets and returns them. | [
"FindSecrets",
"selects",
"a",
"set",
"of",
"secrets",
"and",
"returns",
"them",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/state/store/secrets.go#L105-L122 | train |
docker/swarmkit | manager/allocator/network.go | getNodeNetworks | func (a *Allocator) getNodeNetworks(nodeID string) ([]*api.Network, error) {
var (
// no need to initialize networks. we only append to it, and appending
// to a nil slice is valid. this has the added bonus of making this nil
// if we return an error
networks []*api.Network
err error
)
a.store.View(fu... | go | func (a *Allocator) getNodeNetworks(nodeID string) ([]*api.Network, error) {
var (
// no need to initialize networks. we only append to it, and appending
// to a nil slice is valid. this has the added bonus of making this nil
// if we return an error
networks []*api.Network
err error
)
a.store.View(fu... | [
"func",
"(",
"a",
"*",
"Allocator",
")",
"getNodeNetworks",
"(",
"nodeID",
"string",
")",
"(",
"[",
"]",
"*",
"api",
".",
"Network",
",",
"error",
")",
"{",
"var",
"(",
"// no need to initialize networks. we only append to it, and appending",
"// to a nil slice is v... | // getNodeNetworks returns all networks that should be allocated for a node | [
"getNodeNetworks",
"returns",
"all",
"networks",
"that",
"should",
"be",
"allocated",
"for",
"a",
"node"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/allocator/network.go#L407-L467 | train |
docker/swarmkit | manager/allocator/network.go | allocateServices | func (a *Allocator) allocateServices(ctx context.Context, existingAddressesOnly bool) error {
var (
nc = a.netCtx
services []*api.Service
err error
)
a.store.View(func(tx store.ReadTx) {
services, err = store.FindServices(tx, store.All)
})
if err != nil {
return errors.Wrap(err, "error listing... | go | func (a *Allocator) allocateServices(ctx context.Context, existingAddressesOnly bool) error {
var (
nc = a.netCtx
services []*api.Service
err error
)
a.store.View(func(tx store.ReadTx) {
services, err = store.FindServices(tx, store.All)
})
if err != nil {
return errors.Wrap(err, "error listing... | [
"func",
"(",
"a",
"*",
"Allocator",
")",
"allocateServices",
"(",
"ctx",
"context",
".",
"Context",
",",
"existingAddressesOnly",
"bool",
")",
"error",
"{",
"var",
"(",
"nc",
"=",
"a",
".",
"netCtx",
"\n",
"services",
"[",
"]",
"*",
"api",
".",
"Servic... | // allocateServices allocates services in the store so far before we process
// watched events. | [
"allocateServices",
"allocates",
"services",
"in",
"the",
"store",
"so",
"far",
"before",
"we",
"process",
"watched",
"events",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/allocator/network.go#L667-L712 | train |
docker/swarmkit | manager/allocator/network.go | taskReadyForNetworkVote | func taskReadyForNetworkVote(t *api.Task, s *api.Service, nc *networkContext) bool {
// Task is ready for vote if the following is true:
//
// Task has no network attached or networks attached but all
// of them allocated AND Task's service has no endpoint or
// network configured or service endpoints have been
/... | go | func taskReadyForNetworkVote(t *api.Task, s *api.Service, nc *networkContext) bool {
// Task is ready for vote if the following is true:
//
// Task has no network attached or networks attached but all
// of them allocated AND Task's service has no endpoint or
// network configured or service endpoints have been
/... | [
"func",
"taskReadyForNetworkVote",
"(",
"t",
"*",
"api",
".",
"Task",
",",
"s",
"*",
"api",
".",
"Service",
",",
"nc",
"*",
"networkContext",
")",
"bool",
"{",
"// Task is ready for vote if the following is true:",
"//",
"// Task has no network attached or networks atta... | // taskReadyForNetworkVote checks if the task is ready for a network
// vote to move it to PENDING state. | [
"taskReadyForNetworkVote",
"checks",
"if",
"the",
"task",
"is",
"ready",
"for",
"a",
"network",
"vote",
"to",
"move",
"it",
"to",
"PENDING",
"state",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/allocator/network.go#L808-L817 | train |
docker/swarmkit | manager/allocator/network.go | allocateNode | func (a *Allocator) allocateNode(ctx context.Context, node *api.Node, existingAddressesOnly bool, networks []*api.Network) bool {
var allocated bool
nc := a.netCtx
var nwIDs = make(map[string]struct{}, len(networks))
// go through all of the networks we've passed in
for _, network := range networks {
nwIDs[ne... | go | func (a *Allocator) allocateNode(ctx context.Context, node *api.Node, existingAddressesOnly bool, networks []*api.Network) bool {
var allocated bool
nc := a.netCtx
var nwIDs = make(map[string]struct{}, len(networks))
// go through all of the networks we've passed in
for _, network := range networks {
nwIDs[ne... | [
"func",
"(",
"a",
"*",
"Allocator",
")",
"allocateNode",
"(",
"ctx",
"context",
".",
"Context",
",",
"node",
"*",
"api",
".",
"Node",
",",
"existingAddressesOnly",
"bool",
",",
"networks",
"[",
"]",
"*",
"api",
".",
"Network",
")",
"bool",
"{",
"var",
... | // allocateNode takes a context, a node, whether or not new allocations should
// be made, and the networks to allocate. it then makes sure an attachment is
// allocated for every network in the provided networks, allocating new
// attachments if existingAddressesOnly is false. it return true if something
// new was al... | [
"allocateNode",
"takes",
"a",
"context",
"a",
"node",
"whether",
"or",
"not",
"new",
"allocations",
"should",
"be",
"made",
"and",
"the",
"networks",
"to",
"allocate",
".",
"it",
"then",
"makes",
"sure",
"an",
"attachment",
"is",
"allocated",
"for",
"every",... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/allocator/network.go#L987-L1080 | train |
docker/swarmkit | manager/allocator/network.go | allocateService | func (a *Allocator) allocateService(ctx context.Context, s *api.Service, existingAddressesOnly bool) error {
nc := a.netCtx
if s.Spec.Endpoint != nil {
// service has user-defined endpoint
if s.Endpoint == nil {
// service currently has no allocated endpoint, need allocated.
s.Endpoint = &api.Endpoint{
... | go | func (a *Allocator) allocateService(ctx context.Context, s *api.Service, existingAddressesOnly bool) error {
nc := a.netCtx
if s.Spec.Endpoint != nil {
// service has user-defined endpoint
if s.Endpoint == nil {
// service currently has no allocated endpoint, need allocated.
s.Endpoint = &api.Endpoint{
... | [
"func",
"(",
"a",
"*",
"Allocator",
")",
"allocateService",
"(",
"ctx",
"context",
".",
"Context",
",",
"s",
"*",
"api",
".",
"Service",
",",
"existingAddressesOnly",
"bool",
")",
"error",
"{",
"nc",
":=",
"a",
".",
"netCtx",
"\n\n",
"if",
"s",
".",
... | // allocateService takes care to align the desired state with the spec passed
// the last parameter is true only during restart when the data is read from raft
// and used to build internal state | [
"allocateService",
"takes",
"care",
"to",
"align",
"the",
"desired",
"state",
"with",
"the",
"spec",
"passed",
"the",
"last",
"parameter",
"is",
"true",
"only",
"during",
"restart",
"when",
"the",
"data",
"is",
"read",
"from",
"raft",
"and",
"used",
"to",
... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/allocator/network.go#L1164-L1228 | train |
docker/swarmkit | manager/allocator/network.go | updateTaskStatus | func updateTaskStatus(t *api.Task, newStatus api.TaskState, message string) {
t.Status = api.TaskStatus{
State: newStatus,
Message: message,
Timestamp: ptypes.MustTimestampProto(time.Now()),
}
} | go | func updateTaskStatus(t *api.Task, newStatus api.TaskState, message string) {
t.Status = api.TaskStatus{
State: newStatus,
Message: message,
Timestamp: ptypes.MustTimestampProto(time.Now()),
}
} | [
"func",
"updateTaskStatus",
"(",
"t",
"*",
"api",
".",
"Task",
",",
"newStatus",
"api",
".",
"TaskState",
",",
"message",
"string",
")",
"{",
"t",
".",
"Status",
"=",
"api",
".",
"TaskStatus",
"{",
"State",
":",
"newStatus",
",",
"Message",
":",
"messa... | // updateTaskStatus sets TaskStatus and updates timestamp. | [
"updateTaskStatus",
"sets",
"TaskStatus",
"and",
"updates",
"timestamp",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/allocator/network.go#L1521-L1527 | train |
docker/swarmkit | manager/allocator/network.go | GetIngressNetwork | func GetIngressNetwork(s *store.MemoryStore) (*api.Network, error) {
var (
networks []*api.Network
err error
)
s.View(func(tx store.ReadTx) {
networks, err = store.FindNetworks(tx, store.All)
})
if err != nil {
return nil, err
}
for _, n := range networks {
if IsIngressNetwork(n) {
return n, ni... | go | func GetIngressNetwork(s *store.MemoryStore) (*api.Network, error) {
var (
networks []*api.Network
err error
)
s.View(func(tx store.ReadTx) {
networks, err = store.FindNetworks(tx, store.All)
})
if err != nil {
return nil, err
}
for _, n := range networks {
if IsIngressNetwork(n) {
return n, ni... | [
"func",
"GetIngressNetwork",
"(",
"s",
"*",
"store",
".",
"MemoryStore",
")",
"(",
"*",
"api",
".",
"Network",
",",
"error",
")",
"{",
"var",
"(",
"networks",
"[",
"]",
"*",
"api",
".",
"Network",
"\n",
"err",
"error",
"\n",
")",
"\n",
"s",
".",
... | // GetIngressNetwork fetches the ingress network from store.
// ErrNoIngress will be returned if the ingress network is not present,
// nil otherwise. In case of any other failure in accessing the store,
// the respective error will be reported as is. | [
"GetIngressNetwork",
"fetches",
"the",
"ingress",
"network",
"from",
"store",
".",
"ErrNoIngress",
"will",
"be",
"returned",
"if",
"the",
"ingress",
"network",
"is",
"not",
"present",
"nil",
"otherwise",
".",
"In",
"case",
"of",
"any",
"other",
"failure",
"in"... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/allocator/network.go#L1538-L1555 | train |
docker/swarmkit | manager/health/health.go | Check | func (s *Server) Check(ctx context.Context, in *api.HealthCheckRequest) (*api.HealthCheckResponse, error) {
s.mu.Lock()
defer s.mu.Unlock()
if in.Service == "" {
// check the server overall health status.
return &api.HealthCheckResponse{
Status: api.HealthCheckResponse_SERVING,
}, nil
}
if status, ok := s... | go | func (s *Server) Check(ctx context.Context, in *api.HealthCheckRequest) (*api.HealthCheckResponse, error) {
s.mu.Lock()
defer s.mu.Unlock()
if in.Service == "" {
// check the server overall health status.
return &api.HealthCheckResponse{
Status: api.HealthCheckResponse_SERVING,
}, nil
}
if status, ok := s... | [
"func",
"(",
"s",
"*",
"Server",
")",
"Check",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"*",
"api",
".",
"HealthCheckRequest",
")",
"(",
"*",
"api",
".",
"HealthCheckResponse",
",",
"error",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",... | // Check checks if the grpc server is healthy and running. | [
"Check",
"checks",
"if",
"the",
"grpc",
"server",
"is",
"healthy",
"and",
"running",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/health/health.go#L35-L50 | train |
docker/swarmkit | manager/controlapi/extension.go | CreateExtension | func (s *Server) CreateExtension(ctx context.Context, request *api.CreateExtensionRequest) (*api.CreateExtensionResponse, error) {
if request.Annotations == nil || request.Annotations.Name == "" {
return nil, status.Errorf(codes.InvalidArgument, "extension name must be provided")
}
extension := &api.Extension{
... | go | func (s *Server) CreateExtension(ctx context.Context, request *api.CreateExtensionRequest) (*api.CreateExtensionResponse, error) {
if request.Annotations == nil || request.Annotations.Name == "" {
return nil, status.Errorf(codes.InvalidArgument, "extension name must be provided")
}
extension := &api.Extension{
... | [
"func",
"(",
"s",
"*",
"Server",
")",
"CreateExtension",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"api",
".",
"CreateExtensionRequest",
")",
"(",
"*",
"api",
".",
"CreateExtensionResponse",
",",
"error",
")",
"{",
"if",
"request",
".",
... | // CreateExtension creates an `Extension` based on the provided `CreateExtensionRequest.Extension`
// and returns a `CreateExtensionResponse`.
// - Returns `InvalidArgument` if the `CreateExtensionRequest.Extension` is malformed,
// or fails validation.
// - Returns an error if the creation fails. | [
"CreateExtension",
"creates",
"an",
"Extension",
"based",
"on",
"the",
"provided",
"CreateExtensionRequest",
".",
"Extension",
"and",
"returns",
"a",
"CreateExtensionResponse",
".",
"-",
"Returns",
"InvalidArgument",
"if",
"the",
"CreateExtensionRequest",
".",
"Extensio... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/extension.go#L21-L49 | train |
docker/swarmkit | manager/controlapi/extension.go | GetExtension | func (s *Server) GetExtension(ctx context.Context, request *api.GetExtensionRequest) (*api.GetExtensionResponse, error) {
if request.ExtensionID == "" {
return nil, status.Errorf(codes.InvalidArgument, "extension ID must be provided")
}
var extension *api.Extension
s.store.View(func(tx store.ReadTx) {
extensio... | go | func (s *Server) GetExtension(ctx context.Context, request *api.GetExtensionRequest) (*api.GetExtensionResponse, error) {
if request.ExtensionID == "" {
return nil, status.Errorf(codes.InvalidArgument, "extension ID must be provided")
}
var extension *api.Extension
s.store.View(func(tx store.ReadTx) {
extensio... | [
"func",
"(",
"s",
"*",
"Server",
")",
"GetExtension",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"api",
".",
"GetExtensionRequest",
")",
"(",
"*",
"api",
".",
"GetExtensionResponse",
",",
"error",
")",
"{",
"if",
"request",
".",
"Extensi... | // GetExtension returns a `GetExtensionResponse` with a `Extension` with the same
// id as `GetExtensionRequest.extension_id`
// - Returns `NotFound` if the Extension with the given id is not found.
// - Returns `InvalidArgument` if the `GetExtensionRequest.extension_id` is empty.
// - Returns an error if the get fails... | [
"GetExtension",
"returns",
"a",
"GetExtensionResponse",
"with",
"a",
"Extension",
"with",
"the",
"same",
"id",
"as",
"GetExtensionRequest",
".",
"extension_id",
"-",
"Returns",
"NotFound",
"if",
"the",
"Extension",
"with",
"the",
"given",
"id",
"is",
"not",
"fou... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/extension.go#L56-L71 | train |
docker/swarmkit | manager/controlapi/extension.go | RemoveExtension | func (s *Server) RemoveExtension(ctx context.Context, request *api.RemoveExtensionRequest) (*api.RemoveExtensionResponse, error) {
if request.ExtensionID == "" {
return nil, status.Errorf(codes.InvalidArgument, "extension ID must be provided")
}
err := s.store.Update(func(tx store.Tx) error {
// Check if the ex... | go | func (s *Server) RemoveExtension(ctx context.Context, request *api.RemoveExtensionRequest) (*api.RemoveExtensionResponse, error) {
if request.ExtensionID == "" {
return nil, status.Errorf(codes.InvalidArgument, "extension ID must be provided")
}
err := s.store.Update(func(tx store.Tx) error {
// Check if the ex... | [
"func",
"(",
"s",
"*",
"Server",
")",
"RemoveExtension",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"api",
".",
"RemoveExtensionRequest",
")",
"(",
"*",
"api",
".",
"RemoveExtensionResponse",
",",
"error",
")",
"{",
"if",
"request",
".",
... | // RemoveExtension removes the extension referenced by `RemoveExtensionRequest.ID`.
// - Returns `InvalidArgument` if `RemoveExtensionRequest.extension_id` is empty.
// - Returns `NotFound` if the an extension named `RemoveExtensionRequest.extension_id` is not found.
// - Returns an error if the deletion fails. | [
"RemoveExtension",
"removes",
"the",
"extension",
"referenced",
"by",
"RemoveExtensionRequest",
".",
"ID",
".",
"-",
"Returns",
"InvalidArgument",
"if",
"RemoveExtensionRequest",
".",
"extension_id",
"is",
"empty",
".",
"-",
"Returns",
"NotFound",
"if",
"the",
"an",... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/extension.go#L77-L133 | train |
docker/swarmkit | log/context.go | WithFields | func WithFields(ctx context.Context, fields logrus.Fields) context.Context {
logger := ctx.Value(loggerKey{})
if logger == nil {
logger = L
}
return WithLogger(ctx, logger.(*logrus.Entry).WithFields(fields))
} | go | func WithFields(ctx context.Context, fields logrus.Fields) context.Context {
logger := ctx.Value(loggerKey{})
if logger == nil {
logger = L
}
return WithLogger(ctx, logger.(*logrus.Entry).WithFields(fields))
} | [
"func",
"WithFields",
"(",
"ctx",
"context",
".",
"Context",
",",
"fields",
"logrus",
".",
"Fields",
")",
"context",
".",
"Context",
"{",
"logger",
":=",
"ctx",
".",
"Value",
"(",
"loggerKey",
"{",
"}",
")",
"\n\n",
"if",
"logger",
"==",
"nil",
"{",
... | // WithFields returns a new context with added fields to logger. | [
"WithFields",
"returns",
"a",
"new",
"context",
"with",
"added",
"fields",
"to",
"logger",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/log/context.go#L33-L40 | train |
docker/swarmkit | log/context.go | WithField | func WithField(ctx context.Context, key, value string) context.Context {
return WithFields(ctx, logrus.Fields{key: value})
} | go | func WithField(ctx context.Context, key, value string) context.Context {
return WithFields(ctx, logrus.Fields{key: value})
} | [
"func",
"WithField",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
",",
"value",
"string",
")",
"context",
".",
"Context",
"{",
"return",
"WithFields",
"(",
"ctx",
",",
"logrus",
".",
"Fields",
"{",
"key",
":",
"value",
"}",
")",
"\n",
"}"
] | // WithField is convenience wrapper around WithFields. | [
"WithField",
"is",
"convenience",
"wrapper",
"around",
"WithFields",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/log/context.go#L43-L45 | train |
docker/swarmkit | log/context.go | GetModulePath | func GetModulePath(ctx context.Context) string {
module := ctx.Value(moduleKey{})
if module == nil {
return ""
}
return module.(string)
} | go | func GetModulePath(ctx context.Context) string {
module := ctx.Value(moduleKey{})
if module == nil {
return ""
}
return module.(string)
} | [
"func",
"GetModulePath",
"(",
"ctx",
"context",
".",
"Context",
")",
"string",
"{",
"module",
":=",
"ctx",
".",
"Value",
"(",
"moduleKey",
"{",
"}",
")",
"\n",
"if",
"module",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"modu... | // GetModulePath returns the module path for the provided context. If no module
// is set, an empty string is returned. | [
"GetModulePath",
"returns",
"the",
"module",
"path",
"for",
"the",
"provided",
"context",
".",
"If",
"no",
"module",
"is",
"set",
"an",
"empty",
"string",
"is",
"returned",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/log/context.go#L89-L96 | train |
docker/swarmkit | api/genericresource/resource_management.go | Claim | func Claim(nodeAvailableResources, taskAssigned *[]*api.GenericResource,
taskReservations []*api.GenericResource) error {
var resSelected []*api.GenericResource
for _, res := range taskReservations {
tr := res.GetDiscreteResourceSpec()
if tr == nil {
return fmt.Errorf("task should only hold Discrete type")
... | go | func Claim(nodeAvailableResources, taskAssigned *[]*api.GenericResource,
taskReservations []*api.GenericResource) error {
var resSelected []*api.GenericResource
for _, res := range taskReservations {
tr := res.GetDiscreteResourceSpec()
if tr == nil {
return fmt.Errorf("task should only hold Discrete type")
... | [
"func",
"Claim",
"(",
"nodeAvailableResources",
",",
"taskAssigned",
"*",
"[",
"]",
"*",
"api",
".",
"GenericResource",
",",
"taskReservations",
"[",
"]",
"*",
"api",
".",
"GenericResource",
")",
"error",
"{",
"var",
"resSelected",
"[",
"]",
"*",
"api",
".... | // Claim assigns GenericResources to a task by taking them from the
// node's GenericResource list and storing them in the task's available list | [
"Claim",
"assigns",
"GenericResources",
"to",
"a",
"task",
"by",
"taking",
"them",
"from",
"the",
"node",
"s",
"GenericResource",
"list",
"and",
"storing",
"them",
"in",
"the",
"task",
"s",
"available",
"list"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/api/genericresource/resource_management.go#L11-L32 | train |
docker/swarmkit | api/genericresource/resource_management.go | ClaimResources | func ClaimResources(nodeAvailableResources, taskAssigned *[]*api.GenericResource,
resSelected []*api.GenericResource) {
*taskAssigned = append(*taskAssigned, resSelected...)
ConsumeNodeResources(nodeAvailableResources, resSelected)
} | go | func ClaimResources(nodeAvailableResources, taskAssigned *[]*api.GenericResource,
resSelected []*api.GenericResource) {
*taskAssigned = append(*taskAssigned, resSelected...)
ConsumeNodeResources(nodeAvailableResources, resSelected)
} | [
"func",
"ClaimResources",
"(",
"nodeAvailableResources",
",",
"taskAssigned",
"*",
"[",
"]",
"*",
"api",
".",
"GenericResource",
",",
"resSelected",
"[",
"]",
"*",
"api",
".",
"GenericResource",
")",
"{",
"*",
"taskAssigned",
"=",
"append",
"(",
"*",
"taskAs... | // ClaimResources adds the specified resources to the task's list
// and removes them from the node's generic resource list | [
"ClaimResources",
"adds",
"the",
"specified",
"resources",
"to",
"the",
"task",
"s",
"list",
"and",
"removes",
"them",
"from",
"the",
"node",
"s",
"generic",
"resource",
"list"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/api/genericresource/resource_management.go#L36-L40 | train |
docker/swarmkit | api/genericresource/resource_management.go | Reclaim | func Reclaim(nodeAvailableResources *[]*api.GenericResource, taskAssigned, nodeRes []*api.GenericResource) error {
err := reclaimResources(nodeAvailableResources, taskAssigned)
if err != nil {
return err
}
sanitize(nodeRes, nodeAvailableResources)
return nil
} | go | func Reclaim(nodeAvailableResources *[]*api.GenericResource, taskAssigned, nodeRes []*api.GenericResource) error {
err := reclaimResources(nodeAvailableResources, taskAssigned)
if err != nil {
return err
}
sanitize(nodeRes, nodeAvailableResources)
return nil
} | [
"func",
"Reclaim",
"(",
"nodeAvailableResources",
"*",
"[",
"]",
"*",
"api",
".",
"GenericResource",
",",
"taskAssigned",
",",
"nodeRes",
"[",
"]",
"*",
"api",
".",
"GenericResource",
")",
"error",
"{",
"err",
":=",
"reclaimResources",
"(",
"nodeAvailableResou... | // Reclaim adds the resources taken by the task to the node's store | [
"Reclaim",
"adds",
"the",
"resources",
"taken",
"by",
"the",
"task",
"to",
"the",
"node",
"s",
"store"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/api/genericresource/resource_management.go#L75-L84 | train |
docker/swarmkit | api/genericresource/string.go | Kind | func Kind(res *api.GenericResource) string {
switch r := res.Resource.(type) {
case *api.GenericResource_DiscreteResourceSpec:
return r.DiscreteResourceSpec.Kind
case *api.GenericResource_NamedResourceSpec:
return r.NamedResourceSpec.Kind
}
return ""
} | go | func Kind(res *api.GenericResource) string {
switch r := res.Resource.(type) {
case *api.GenericResource_DiscreteResourceSpec:
return r.DiscreteResourceSpec.Kind
case *api.GenericResource_NamedResourceSpec:
return r.NamedResourceSpec.Kind
}
return ""
} | [
"func",
"Kind",
"(",
"res",
"*",
"api",
".",
"GenericResource",
")",
"string",
"{",
"switch",
"r",
":=",
"res",
".",
"Resource",
".",
"(",
"type",
")",
"{",
"case",
"*",
"api",
".",
"GenericResource_DiscreteResourceSpec",
":",
"return",
"r",
".",
"Discre... | // Kind returns the kind key as a string | [
"Kind",
"returns",
"the",
"kind",
"key",
"as",
"a",
"string"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/api/genericresource/string.go#L15-L24 | train |
docker/swarmkit | api/genericresource/string.go | Value | func Value(res *api.GenericResource) string {
switch res := res.Resource.(type) {
case *api.GenericResource_DiscreteResourceSpec:
return discreteToString(res)
case *api.GenericResource_NamedResourceSpec:
return res.NamedResourceSpec.Value
}
return ""
} | go | func Value(res *api.GenericResource) string {
switch res := res.Resource.(type) {
case *api.GenericResource_DiscreteResourceSpec:
return discreteToString(res)
case *api.GenericResource_NamedResourceSpec:
return res.NamedResourceSpec.Value
}
return ""
} | [
"func",
"Value",
"(",
"res",
"*",
"api",
".",
"GenericResource",
")",
"string",
"{",
"switch",
"res",
":=",
"res",
".",
"Resource",
".",
"(",
"type",
")",
"{",
"case",
"*",
"api",
".",
"GenericResource_DiscreteResourceSpec",
":",
"return",
"discreteToString"... | // Value returns the value key as a string | [
"Value",
"returns",
"the",
"value",
"key",
"as",
"a",
"string"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/api/genericresource/string.go#L27-L36 | train |
docker/swarmkit | api/genericresource/string.go | EnvFormat | func EnvFormat(res []*api.GenericResource, prefix string) []string {
envs := make(map[string][]string)
for _, v := range res {
key := Kind(v)
val := Value(v)
envs[key] = append(envs[key], val)
}
env := make([]string, 0, len(res))
for k, v := range envs {
k = strings.ToUpper(prefix + "_" + k)
env = appen... | go | func EnvFormat(res []*api.GenericResource, prefix string) []string {
envs := make(map[string][]string)
for _, v := range res {
key := Kind(v)
val := Value(v)
envs[key] = append(envs[key], val)
}
env := make([]string, 0, len(res))
for k, v := range envs {
k = strings.ToUpper(prefix + "_" + k)
env = appen... | [
"func",
"EnvFormat",
"(",
"res",
"[",
"]",
"*",
"api",
".",
"GenericResource",
",",
"prefix",
"string",
")",
"[",
"]",
"string",
"{",
"envs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"\n",
"for",
"_",
",",
"v",
":=",... | // EnvFormat returns the environment string version of the resource | [
"EnvFormat",
"returns",
"the",
"environment",
"string",
"version",
"of",
"the",
"resource"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/api/genericresource/string.go#L39-L54 | train |
docker/swarmkit | cmd/swarmctl/service/flagparser/flags.go | Merge | func Merge(cmd *cobra.Command, spec *api.ServiceSpec, c api.ControlClient) error {
flags := cmd.Flags()
if flags.Changed("force") {
force, err := flags.GetBool("force")
if err != nil {
return err
}
if force {
spec.Task.ForceUpdate++
}
}
if flags.Changed("name") {
name, err := flags.GetString("na... | go | func Merge(cmd *cobra.Command, spec *api.ServiceSpec, c api.ControlClient) error {
flags := cmd.Flags()
if flags.Changed("force") {
force, err := flags.GetBool("force")
if err != nil {
return err
}
if force {
spec.Task.ForceUpdate++
}
}
if flags.Changed("name") {
name, err := flags.GetString("na... | [
"func",
"Merge",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"spec",
"*",
"api",
".",
"ServiceSpec",
",",
"c",
"api",
".",
"ControlClient",
")",
"error",
"{",
"flags",
":=",
"cmd",
".",
"Flags",
"(",
")",
"\n\n",
"if",
"flags",
".",
"Changed",
"... | // Merge merges a flagset into a service spec. | [
"Merge",
"merges",
"a",
"flagset",
"into",
"a",
"service",
"spec",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/cmd/swarmctl/service/flagparser/flags.go#L68-L159 | train |
docker/swarmkit | node/node.go | observe | func (l *lastSeenRole) observe(newRole api.NodeRole) bool {
changed := l.role != newRole
l.role = newRole
return changed
} | go | func (l *lastSeenRole) observe(newRole api.NodeRole) bool {
changed := l.role != newRole
l.role = newRole
return changed
} | [
"func",
"(",
"l",
"*",
"lastSeenRole",
")",
"observe",
"(",
"newRole",
"api",
".",
"NodeRole",
")",
"bool",
"{",
"changed",
":=",
"l",
".",
"role",
"!=",
"newRole",
"\n",
"l",
".",
"role",
"=",
"newRole",
"\n",
"return",
"changed",
"\n",
"}"
] | // observe notes the latest value of this node role, and returns true if it
// is the first seen value, or is different from the most recently seen value. | [
"observe",
"notes",
"the",
"latest",
"value",
"of",
"this",
"node",
"role",
"and",
"returns",
"true",
"if",
"it",
"is",
"the",
"first",
"seen",
"value",
"or",
"is",
"different",
"from",
"the",
"most",
"recently",
"seen",
"value",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L174-L178 | train |
docker/swarmkit | node/node.go | RemoteAPIAddr | func (n *Node) RemoteAPIAddr() (string, error) {
n.RLock()
defer n.RUnlock()
if n.manager == nil {
return "", errors.New("manager is not running")
}
addr := n.manager.Addr()
if addr == "" {
return "", errors.New("manager addr is not set")
}
return addr, nil
} | go | func (n *Node) RemoteAPIAddr() (string, error) {
n.RLock()
defer n.RUnlock()
if n.manager == nil {
return "", errors.New("manager is not running")
}
addr := n.manager.Addr()
if addr == "" {
return "", errors.New("manager addr is not set")
}
return addr, nil
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"RemoteAPIAddr",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"n",
".",
"RLock",
"(",
")",
"\n",
"defer",
"n",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"n",
".",
"manager",
"==",
"nil",
"{",
"return",
"\"",
... | // RemoteAPIAddr returns address on which remote manager api listens.
// Returns nil if node is not manager. | [
"RemoteAPIAddr",
"returns",
"address",
"on",
"which",
"remote",
"manager",
"api",
"listens",
".",
"Returns",
"nil",
"if",
"node",
"is",
"not",
"manager",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L182-L193 | train |
docker/swarmkit | node/node.go | New | func New(c *Config) (*Node, error) {
if err := os.MkdirAll(c.StateDir, 0700); err != nil {
return nil, err
}
stateFile := filepath.Join(c.StateDir, stateFilename)
dt, err := ioutil.ReadFile(stateFile)
var p []api.Peer
if err != nil && !os.IsNotExist(err) {
return nil, err
}
if err == nil {
if err := json.... | go | func New(c *Config) (*Node, error) {
if err := os.MkdirAll(c.StateDir, 0700); err != nil {
return nil, err
}
stateFile := filepath.Join(c.StateDir, stateFilename)
dt, err := ioutil.ReadFile(stateFile)
var p []api.Peer
if err != nil && !os.IsNotExist(err) {
return nil, err
}
if err == nil {
if err := json.... | [
"func",
"New",
"(",
"c",
"*",
"Config",
")",
"(",
"*",
"Node",
",",
"error",
")",
"{",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"c",
".",
"StateDir",
",",
"0700",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}"... | // New returns new Node instance. | [
"New",
"returns",
"new",
"Node",
"instance",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L196-L235 | train |
docker/swarmkit | node/node.go | BindRemote | func (n *Node) BindRemote(ctx context.Context, listenAddr string, advertiseAddr string) error {
n.RLock()
defer n.RUnlock()
if n.manager == nil {
return errors.New("manager is not running")
}
return n.manager.BindRemote(ctx, manager.RemoteAddrs{
ListenAddr: listenAddr,
AdvertiseAddr: advertiseAddr,
})
... | go | func (n *Node) BindRemote(ctx context.Context, listenAddr string, advertiseAddr string) error {
n.RLock()
defer n.RUnlock()
if n.manager == nil {
return errors.New("manager is not running")
}
return n.manager.BindRemote(ctx, manager.RemoteAddrs{
ListenAddr: listenAddr,
AdvertiseAddr: advertiseAddr,
})
... | [
"func",
"(",
"n",
"*",
"Node",
")",
"BindRemote",
"(",
"ctx",
"context",
".",
"Context",
",",
"listenAddr",
"string",
",",
"advertiseAddr",
"string",
")",
"error",
"{",
"n",
".",
"RLock",
"(",
")",
"\n",
"defer",
"n",
".",
"RUnlock",
"(",
")",
"\n\n"... | // BindRemote starts a listener that exposes the remote API. | [
"BindRemote",
"starts",
"a",
"listener",
"that",
"exposes",
"the",
"remote",
"API",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L238-L250 | train |
docker/swarmkit | node/node.go | Start | func (n *Node) Start(ctx context.Context) error {
err := errNodeStarted
n.startOnce.Do(func() {
close(n.started)
go n.run(ctx)
err = nil // clear error above, only once.
})
return err
} | go | func (n *Node) Start(ctx context.Context) error {
err := errNodeStarted
n.startOnce.Do(func() {
close(n.started)
go n.run(ctx)
err = nil // clear error above, only once.
})
return err
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Start",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"err",
":=",
"errNodeStarted",
"\n\n",
"n",
".",
"startOnce",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"close",
"(",
"n",
".",
"started",
")",
"\... | // Start starts a node instance. | [
"Start",
"starts",
"a",
"node",
"instance",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L253-L262 | train |
docker/swarmkit | node/node.go | configVXLANUDPPort | func configVXLANUDPPort(ctx context.Context, vxlanUDPPort uint32) {
if err := overlayutils.ConfigVXLANUDPPort(vxlanUDPPort); err != nil {
log.G(ctx).WithError(err).Error("failed to configure VXLAN UDP port")
return
}
logrus.Infof("initialized VXLAN UDP port to %d ", vxlanUDPPort)
} | go | func configVXLANUDPPort(ctx context.Context, vxlanUDPPort uint32) {
if err := overlayutils.ConfigVXLANUDPPort(vxlanUDPPort); err != nil {
log.G(ctx).WithError(err).Error("failed to configure VXLAN UDP port")
return
}
logrus.Infof("initialized VXLAN UDP port to %d ", vxlanUDPPort)
} | [
"func",
"configVXLANUDPPort",
"(",
"ctx",
"context",
".",
"Context",
",",
"vxlanUDPPort",
"uint32",
")",
"{",
"if",
"err",
":=",
"overlayutils",
".",
"ConfigVXLANUDPPort",
"(",
"vxlanUDPPort",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"G",
"(",
"ctx",... | // configVXLANUDPPort sets vxlan port in libnetwork | [
"configVXLANUDPPort",
"sets",
"vxlan",
"port",
"in",
"libnetwork"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L275-L281 | train |
docker/swarmkit | node/node.go | Stop | func (n *Node) Stop(ctx context.Context) error {
select {
case <-n.started:
default:
return errNodeNotStarted
}
// ask agent to clean up assignments
n.Lock()
if n.agent != nil {
if err := n.agent.Leave(ctx); err != nil {
log.G(ctx).WithError(err).Error("agent failed to clean up assignments")
}
}
n.Unl... | go | func (n *Node) Stop(ctx context.Context) error {
select {
case <-n.started:
default:
return errNodeNotStarted
}
// ask agent to clean up assignments
n.Lock()
if n.agent != nil {
if err := n.agent.Leave(ctx); err != nil {
log.G(ctx).WithError(err).Error("agent failed to clean up assignments")
}
}
n.Unl... | [
"func",
"(",
"n",
"*",
"Node",
")",
"Stop",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"select",
"{",
"case",
"<-",
"n",
".",
"started",
":",
"default",
":",
"return",
"errNodeNotStarted",
"\n",
"}",
"\n",
"// ask agent to clean up assignmen... | // Stop stops node execution | [
"Stop",
"stops",
"node",
"execution"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L533-L558 | train |
docker/swarmkit | node/node.go | Err | func (n *Node) Err(ctx context.Context) error {
select {
case <-n.closed:
return n.err
case <-ctx.Done():
return ctx.Err()
}
} | go | func (n *Node) Err(ctx context.Context) error {
select {
case <-n.closed:
return n.err
case <-ctx.Done():
return ctx.Err()
}
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Err",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"select",
"{",
"case",
"<-",
"n",
".",
"closed",
":",
"return",
"n",
".",
"err",
"\n",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return... | // Err returns the error that caused the node to shutdown or nil. Err blocks
// until the node has fully shut down. | [
"Err",
"returns",
"the",
"error",
"that",
"caused",
"the",
"node",
"to",
"shutdown",
"or",
"nil",
".",
"Err",
"blocks",
"until",
"the",
"node",
"has",
"fully",
"shut",
"down",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L562-L569 | train |
docker/swarmkit | node/node.go | runAgent | func (n *Node) runAgent(ctx context.Context, db *bolt.DB, securityConfig *ca.SecurityConfig, ready chan<- struct{}) error {
// First, get a channel for knowing when a remote peer has been selected.
// The value returned from the remotesCh is ignored, we just need to know
// when the peer is selected
remotesCh := n.... | go | func (n *Node) runAgent(ctx context.Context, db *bolt.DB, securityConfig *ca.SecurityConfig, ready chan<- struct{}) error {
// First, get a channel for knowing when a remote peer has been selected.
// The value returned from the remotesCh is ignored, we just need to know
// when the peer is selected
remotesCh := n.... | [
"func",
"(",
"n",
"*",
"Node",
")",
"runAgent",
"(",
"ctx",
"context",
".",
"Context",
",",
"db",
"*",
"bolt",
".",
"DB",
",",
"securityConfig",
"*",
"ca",
".",
"SecurityConfig",
",",
"ready",
"chan",
"<-",
"struct",
"{",
"}",
")",
"error",
"{",
"/... | // runAgent starts the node's agent. When the agent has started, the provided
// ready channel is closed. When the agent exits, this will return the error
// that caused it. | [
"runAgent",
"starts",
"the",
"node",
"s",
"agent",
".",
"When",
"the",
"agent",
"has",
"started",
"the",
"provided",
"ready",
"channel",
"is",
"closed",
".",
"When",
"the",
"agent",
"exits",
"this",
"will",
"return",
"the",
"error",
"that",
"caused",
"it",... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L574-L674 | train |
docker/swarmkit | node/node.go | ListenControlSocket | func (n *Node) ListenControlSocket(ctx context.Context) <-chan *grpc.ClientConn {
c := make(chan *grpc.ClientConn, 1)
n.RLock()
conn := n.conn
c <- conn
done := make(chan struct{})
go func() {
select {
case <-ctx.Done():
n.connCond.Broadcast()
case <-done:
}
}()
go func() {
defer close(c)
defer c... | go | func (n *Node) ListenControlSocket(ctx context.Context) <-chan *grpc.ClientConn {
c := make(chan *grpc.ClientConn, 1)
n.RLock()
conn := n.conn
c <- conn
done := make(chan struct{})
go func() {
select {
case <-ctx.Done():
n.connCond.Broadcast()
case <-done:
}
}()
go func() {
defer close(c)
defer c... | [
"func",
"(",
"n",
"*",
"Node",
")",
"ListenControlSocket",
"(",
"ctx",
"context",
".",
"Context",
")",
"<-",
"chan",
"*",
"grpc",
".",
"ClientConn",
"{",
"c",
":=",
"make",
"(",
"chan",
"*",
"grpc",
".",
"ClientConn",
",",
"1",
")",
"\n",
"n",
".",... | // ListenControlSocket listens changes of a connection for managing the
// cluster control api | [
"ListenControlSocket",
"listens",
"changes",
"of",
"a",
"connection",
"for",
"managing",
"the",
"cluster",
"control",
"api"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L695-L731 | train |
docker/swarmkit | node/node.go | NodeID | func (n *Node) NodeID() string {
n.RLock()
defer n.RUnlock()
return n.nodeID
} | go | func (n *Node) NodeID() string {
n.RLock()
defer n.RUnlock()
return n.nodeID
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"NodeID",
"(",
")",
"string",
"{",
"n",
".",
"RLock",
"(",
")",
"\n",
"defer",
"n",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"n",
".",
"nodeID",
"\n",
"}"
] | // NodeID returns current node's ID. May be empty if not set. | [
"NodeID",
"returns",
"current",
"node",
"s",
"ID",
".",
"May",
"be",
"empty",
"if",
"not",
"set",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L734-L738 | train |
docker/swarmkit | node/node.go | Manager | func (n *Node) Manager() *manager.Manager {
n.RLock()
defer n.RUnlock()
return n.manager
} | go | func (n *Node) Manager() *manager.Manager {
n.RLock()
defer n.RUnlock()
return n.manager
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Manager",
"(",
")",
"*",
"manager",
".",
"Manager",
"{",
"n",
".",
"RLock",
"(",
")",
"\n",
"defer",
"n",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"n",
".",
"manager",
"\n",
"}"
] | // Manager returns manager instance started by node. May be nil. | [
"Manager",
"returns",
"manager",
"instance",
"started",
"by",
"node",
".",
"May",
"be",
"nil",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L741-L745 | train |
docker/swarmkit | node/node.go | Agent | func (n *Node) Agent() *agent.Agent {
n.RLock()
defer n.RUnlock()
return n.agent
} | go | func (n *Node) Agent() *agent.Agent {
n.RLock()
defer n.RUnlock()
return n.agent
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Agent",
"(",
")",
"*",
"agent",
".",
"Agent",
"{",
"n",
".",
"RLock",
"(",
")",
"\n",
"defer",
"n",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"n",
".",
"agent",
"\n",
"}"
] | // Agent returns agent instance started by node. May be nil. | [
"Agent",
"returns",
"agent",
"instance",
"started",
"by",
"node",
".",
"May",
"be",
"nil",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L748-L752 | train |
docker/swarmkit | node/node.go | Remotes | func (n *Node) Remotes() []api.Peer {
weights := n.remotes.Weights()
remotes := make([]api.Peer, 0, len(weights))
for p := range weights {
remotes = append(remotes, p)
}
return remotes
} | go | func (n *Node) Remotes() []api.Peer {
weights := n.remotes.Weights()
remotes := make([]api.Peer, 0, len(weights))
for p := range weights {
remotes = append(remotes, p)
}
return remotes
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"Remotes",
"(",
")",
"[",
"]",
"api",
".",
"Peer",
"{",
"weights",
":=",
"n",
".",
"remotes",
".",
"Weights",
"(",
")",
"\n",
"remotes",
":=",
"make",
"(",
"[",
"]",
"api",
".",
"Peer",
",",
"0",
",",
"len"... | // Remotes returns a list of known peers known to node. | [
"Remotes",
"returns",
"a",
"list",
"of",
"known",
"peers",
"known",
"to",
"node",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L769-L776 | train |
docker/swarmkit | node/node.go | isMandatoryFIPSClusterID | func isMandatoryFIPSClusterID(securityConfig *ca.SecurityConfig) bool {
return strings.HasPrefix(securityConfig.ClientTLSCreds.Organization(), "FIPS.")
} | go | func isMandatoryFIPSClusterID(securityConfig *ca.SecurityConfig) bool {
return strings.HasPrefix(securityConfig.ClientTLSCreds.Organization(), "FIPS.")
} | [
"func",
"isMandatoryFIPSClusterID",
"(",
"securityConfig",
"*",
"ca",
".",
"SecurityConfig",
")",
"bool",
"{",
"return",
"strings",
".",
"HasPrefix",
"(",
"securityConfig",
".",
"ClientTLSCreds",
".",
"Organization",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // Given a cluster ID, returns whether the cluster ID indicates that the cluster
// mandates FIPS mode. These cluster IDs start with "FIPS." as a prefix. | [
"Given",
"a",
"cluster",
"ID",
"returns",
"whether",
"the",
"cluster",
"ID",
"indicates",
"that",
"the",
"cluster",
"mandates",
"FIPS",
"mode",
".",
"These",
"cluster",
"IDs",
"start",
"with",
"FIPS",
".",
"as",
"a",
"prefix",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L780-L782 | train |
docker/swarmkit | node/node.go | isMandatoryFIPSClusterJoinToken | func isMandatoryFIPSClusterJoinToken(joinToken string) bool {
if parsed, err := ca.ParseJoinToken(joinToken); err == nil {
return parsed.FIPS
}
return false
} | go | func isMandatoryFIPSClusterJoinToken(joinToken string) bool {
if parsed, err := ca.ParseJoinToken(joinToken); err == nil {
return parsed.FIPS
}
return false
} | [
"func",
"isMandatoryFIPSClusterJoinToken",
"(",
"joinToken",
"string",
")",
"bool",
"{",
"if",
"parsed",
",",
"err",
":=",
"ca",
".",
"ParseJoinToken",
"(",
"joinToken",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"parsed",
".",
"FIPS",
"\n",
"}",
"\n",
... | // Given a join token, returns whether it indicates that the cluster mandates FIPS
// mode. | [
"Given",
"a",
"join",
"token",
"returns",
"whether",
"it",
"indicates",
"that",
"the",
"cluster",
"mandates",
"FIPS",
"mode",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L786-L791 | train |
docker/swarmkit | node/node.go | superviseManager | func (n *Node) superviseManager(ctx context.Context, securityConfig *ca.SecurityConfig, rootPaths ca.CertPaths, ready chan struct{}, renewer *ca.TLSRenewer) error {
// superviseManager is a loop, because we can come in and out of being a
// manager, and need to appropriately handle that without disrupting the
// nod... | go | func (n *Node) superviseManager(ctx context.Context, securityConfig *ca.SecurityConfig, rootPaths ca.CertPaths, ready chan struct{}, renewer *ca.TLSRenewer) error {
// superviseManager is a loop, because we can come in and out of being a
// manager, and need to appropriately handle that without disrupting the
// nod... | [
"func",
"(",
"n",
"*",
"Node",
")",
"superviseManager",
"(",
"ctx",
"context",
".",
"Context",
",",
"securityConfig",
"*",
"ca",
".",
"SecurityConfig",
",",
"rootPaths",
"ca",
".",
"CertPaths",
",",
"ready",
"chan",
"struct",
"{",
"}",
",",
"renewer",
"*... | // superviseManager controls whether or not we are running a manager on this
// node | [
"superviseManager",
"controls",
"whether",
"or",
"not",
"we",
"are",
"running",
"a",
"manager",
"on",
"this",
"node"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L1095-L1187 | train |
docker/swarmkit | node/node.go | DowngradeKey | func (n *Node) DowngradeKey() error {
paths := ca.NewConfigPaths(filepath.Join(n.config.StateDir, certDirectory))
krw := ca.NewKeyReadWriter(paths.Node, n.config.UnlockKey, nil)
return krw.DowngradeKey()
} | go | func (n *Node) DowngradeKey() error {
paths := ca.NewConfigPaths(filepath.Join(n.config.StateDir, certDirectory))
krw := ca.NewKeyReadWriter(paths.Node, n.config.UnlockKey, nil)
return krw.DowngradeKey()
} | [
"func",
"(",
"n",
"*",
"Node",
")",
"DowngradeKey",
"(",
")",
"error",
"{",
"paths",
":=",
"ca",
".",
"NewConfigPaths",
"(",
"filepath",
".",
"Join",
"(",
"n",
".",
"config",
".",
"StateDir",
",",
"certDirectory",
")",
")",
"\n",
"krw",
":=",
"ca",
... | // DowngradeKey reverts the node key to older format so that it can
// run on older version of swarmkit | [
"DowngradeKey",
"reverts",
"the",
"node",
"key",
"to",
"older",
"format",
"so",
"that",
"it",
"can",
"run",
"on",
"older",
"version",
"of",
"swarmkit"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L1191-L1196 | train |
docker/swarmkit | node/node.go | WaitSelect | func (s *persistentRemotes) WaitSelect(ctx context.Context) <-chan api.Peer {
c := make(chan api.Peer, 1)
s.RLock()
done := make(chan struct{})
go func() {
select {
case <-ctx.Done():
s.c.Broadcast()
case <-done:
}
}()
go func() {
defer s.RUnlock()
defer close(c)
defer close(done)
for {
if c... | go | func (s *persistentRemotes) WaitSelect(ctx context.Context) <-chan api.Peer {
c := make(chan api.Peer, 1)
s.RLock()
done := make(chan struct{})
go func() {
select {
case <-ctx.Done():
s.c.Broadcast()
case <-done:
}
}()
go func() {
defer s.RUnlock()
defer close(c)
defer close(done)
for {
if c... | [
"func",
"(",
"s",
"*",
"persistentRemotes",
")",
"WaitSelect",
"(",
"ctx",
"context",
".",
"Context",
")",
"<-",
"chan",
"api",
".",
"Peer",
"{",
"c",
":=",
"make",
"(",
"chan",
"api",
".",
"Peer",
",",
"1",
")",
"\n",
"s",
".",
"RLock",
"(",
")"... | // WaitSelect waits until at least one remote becomes available and then selects one. | [
"WaitSelect",
"waits",
"until",
"at",
"least",
"one",
"remote",
"becomes",
"available",
"and",
"then",
"selects",
"one",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L1253-L1281 | train |
docker/swarmkit | node/node.go | SessionClosed | func (fs *firstSessionErrorTracker) SessionClosed() error {
fs.mu.Lock()
defer fs.mu.Unlock()
// if we've successfully established at least 1 session, never return
// errors
if fs.pastFirstSession {
return nil
}
// get the GRPC status from the error, because we only care about GRPC
// errors
grpcStatus, ok... | go | func (fs *firstSessionErrorTracker) SessionClosed() error {
fs.mu.Lock()
defer fs.mu.Unlock()
// if we've successfully established at least 1 session, never return
// errors
if fs.pastFirstSession {
return nil
}
// get the GRPC status from the error, because we only care about GRPC
// errors
grpcStatus, ok... | [
"func",
"(",
"fs",
"*",
"firstSessionErrorTracker",
")",
"SessionClosed",
"(",
")",
"error",
"{",
"fs",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fs",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"// if we've successfully established at least 1 session,... | // SessionClosed returns an error if we haven't yet established a session, and
// we get a gprc error as a result of an X509 failure. | [
"SessionClosed",
"returns",
"an",
"error",
"if",
"we",
"haven",
"t",
"yet",
"established",
"a",
"session",
"and",
"we",
"get",
"a",
"gprc",
"error",
"as",
"a",
"result",
"of",
"an",
"X509",
"failure",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/node/node.go#L1317-L1364 | train |
docker/swarmkit | manager/state/store/apply.go | Apply | func Apply(store *MemoryStore, item events.Event) (err error) {
return store.Update(func(tx Tx) error {
switch v := item.(type) {
case api.EventCreateTask:
return CreateTask(tx, v.Task)
case api.EventUpdateTask:
return UpdateTask(tx, v.Task)
case api.EventDeleteTask:
return DeleteTask(tx, v.Task.ID)
... | go | func Apply(store *MemoryStore, item events.Event) (err error) {
return store.Update(func(tx Tx) error {
switch v := item.(type) {
case api.EventCreateTask:
return CreateTask(tx, v.Task)
case api.EventUpdateTask:
return UpdateTask(tx, v.Task)
case api.EventDeleteTask:
return DeleteTask(tx, v.Task.ID)
... | [
"func",
"Apply",
"(",
"store",
"*",
"MemoryStore",
",",
"item",
"events",
".",
"Event",
")",
"(",
"err",
"error",
")",
"{",
"return",
"store",
".",
"Update",
"(",
"func",
"(",
"tx",
"Tx",
")",
"error",
"{",
"switch",
"v",
":=",
"item",
".",
"(",
... | // Apply takes an item from the event stream of one Store and applies it to
// a second Store. | [
"Apply",
"takes",
"an",
"item",
"from",
"the",
"event",
"stream",
"of",
"one",
"Store",
"and",
"applies",
"it",
"to",
"a",
"second",
"Store",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/state/store/apply.go#L13-L49 | train |
docker/swarmkit | manager/allocator/cnmallocator/portallocator.go | getPortConfigKey | func getPortConfigKey(p *api.PortConfig) api.PortConfig {
return api.PortConfig{
Name: p.Name,
Protocol: p.Protocol,
TargetPort: p.TargetPort,
}
} | go | func getPortConfigKey(p *api.PortConfig) api.PortConfig {
return api.PortConfig{
Name: p.Name,
Protocol: p.Protocol,
TargetPort: p.TargetPort,
}
} | [
"func",
"getPortConfigKey",
"(",
"p",
"*",
"api",
".",
"PortConfig",
")",
"api",
".",
"PortConfig",
"{",
"return",
"api",
".",
"PortConfig",
"{",
"Name",
":",
"p",
".",
"Name",
",",
"Protocol",
":",
"p",
".",
"Protocol",
",",
"TargetPort",
":",
"p",
... | // getPortConfigKey returns a map key for doing set operations with
// ports. The key consists of name, protocol and target port which
// uniquely identifies a port within a single Endpoint. | [
"getPortConfigKey",
"returns",
"a",
"map",
"key",
"for",
"doing",
"set",
"operations",
"with",
"ports",
".",
"The",
"key",
"consists",
"of",
"name",
"protocol",
"and",
"target",
"port",
"which",
"uniquely",
"identifies",
"a",
"port",
"within",
"a",
"single",
... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/allocator/cnmallocator/portallocator.go#L144-L150 | train |
docker/swarmkit | manager/role_manager.go | newRoleManager | func newRoleManager(store *store.MemoryStore, raftNode *raft.Node) *roleManager {
ctx, cancel := context.WithCancel(context.Background())
return &roleManager{
ctx: ctx,
cancel: cancel,
store: store,
raft: raftNode,
doneChan: make... | go | func newRoleManager(store *store.MemoryStore, raftNode *raft.Node) *roleManager {
ctx, cancel := context.WithCancel(context.Background())
return &roleManager{
ctx: ctx,
cancel: cancel,
store: store,
raft: raftNode,
doneChan: make... | [
"func",
"newRoleManager",
"(",
"store",
"*",
"store",
".",
"MemoryStore",
",",
"raftNode",
"*",
"raft",
".",
"Node",
")",
"*",
"roleManager",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"context",
".",
"Background",
"(",
")",
")",... | // newRoleManager creates a new roleManager. | [
"newRoleManager",
"creates",
"a",
"new",
"roleManager",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/role_manager.go#L47-L58 | train |
docker/swarmkit | manager/role_manager.go | getTicker | func (rm *roleManager) getTicker(interval time.Duration) clock.Ticker {
if rm.clocksource == nil {
return clock.NewClock().NewTicker(interval)
}
return rm.clocksource.NewTicker(interval)
} | go | func (rm *roleManager) getTicker(interval time.Duration) clock.Ticker {
if rm.clocksource == nil {
return clock.NewClock().NewTicker(interval)
}
return rm.clocksource.NewTicker(interval)
} | [
"func",
"(",
"rm",
"*",
"roleManager",
")",
"getTicker",
"(",
"interval",
"time",
".",
"Duration",
")",
"clock",
".",
"Ticker",
"{",
"if",
"rm",
".",
"clocksource",
"==",
"nil",
"{",
"return",
"clock",
".",
"NewClock",
"(",
")",
".",
"NewTicker",
"(",
... | // getTicker returns a ticker based on the configured clock source | [
"getTicker",
"returns",
"a",
"ticker",
"based",
"on",
"the",
"configured",
"clock",
"source"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/role_manager.go#L61-L67 | train |
docker/swarmkit | manager/role_manager.go | removeMember | func (rm *roleManager) removeMember(ctx context.Context, member *membership.Member) {
// Quorum safeguard - quorum should have been checked before a node was allowed to be demoted, but if in the
// intervening time some other node disconnected, removing this node would result in a loss of cluster quorum.
// We leave... | go | func (rm *roleManager) removeMember(ctx context.Context, member *membership.Member) {
// Quorum safeguard - quorum should have been checked before a node was allowed to be demoted, but if in the
// intervening time some other node disconnected, removing this node would result in a loss of cluster quorum.
// We leave... | [
"func",
"(",
"rm",
"*",
"roleManager",
")",
"removeMember",
"(",
"ctx",
"context",
".",
"Context",
",",
"member",
"*",
"membership",
".",
"Member",
")",
"{",
"// Quorum safeguard - quorum should have been checked before a node was allowed to be demoted, but if in the",
"// ... | // removeMember removes a member from the raft cluster membership | [
"removeMember",
"removes",
"a",
"member",
"from",
"the",
"raft",
"cluster",
"membership"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/role_manager.go#L200-L227 | train |
docker/swarmkit | manager/role_manager.go | reconcileRole | func (rm *roleManager) reconcileRole(ctx context.Context, node *api.Node) {
if node.Role == node.Spec.DesiredRole {
// Nothing to do.
delete(rm.pendingReconciliation, node.ID)
return
}
// Promotion can proceed right away.
if node.Spec.DesiredRole == api.NodeRoleManager && node.Role == api.NodeRoleWorker {
... | go | func (rm *roleManager) reconcileRole(ctx context.Context, node *api.Node) {
if node.Role == node.Spec.DesiredRole {
// Nothing to do.
delete(rm.pendingReconciliation, node.ID)
return
}
// Promotion can proceed right away.
if node.Spec.DesiredRole == api.NodeRoleManager && node.Role == api.NodeRoleWorker {
... | [
"func",
"(",
"rm",
"*",
"roleManager",
")",
"reconcileRole",
"(",
"ctx",
"context",
".",
"Context",
",",
"node",
"*",
"api",
".",
"Node",
")",
"{",
"if",
"node",
".",
"Role",
"==",
"node",
".",
"Spec",
".",
"DesiredRole",
"{",
"// Nothing to do.",
"del... | // reconcileRole looks at the desired role for a node, and if it is being demoted or promoted, updates the
// node role accordingly. If the node is being demoted, it also removes the node from the raft cluster membership. | [
"reconcileRole",
"looks",
"at",
"the",
"desired",
"role",
"for",
"a",
"node",
"and",
"if",
"it",
"is",
"being",
"demoted",
"or",
"promoted",
"updates",
"the",
"node",
"role",
"accordingly",
".",
"If",
"the",
"node",
"is",
"being",
"demoted",
"it",
"also",
... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/role_manager.go#L231-L279 | train |
docker/swarmkit | manager/scheduler/pipeline.go | NewPipeline | func NewPipeline() *Pipeline {
p := &Pipeline{}
for _, f := range defaultFilters {
p.checklist = append(p.checklist, checklistEntry{f: f})
}
return p
} | go | func NewPipeline() *Pipeline {
p := &Pipeline{}
for _, f := range defaultFilters {
p.checklist = append(p.checklist, checklistEntry{f: f})
}
return p
} | [
"func",
"NewPipeline",
"(",
")",
"*",
"Pipeline",
"{",
"p",
":=",
"&",
"Pipeline",
"{",
"}",
"\n\n",
"for",
"_",
",",
"f",
":=",
"range",
"defaultFilters",
"{",
"p",
".",
"checklist",
"=",
"append",
"(",
"p",
".",
"checklist",
",",
"checklistEntry",
... | // NewPipeline returns a pipeline with the default set of filters. | [
"NewPipeline",
"returns",
"a",
"pipeline",
"with",
"the",
"default",
"set",
"of",
"filters",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/scheduler/pipeline.go#L44-L52 | train |
docker/swarmkit | manager/scheduler/pipeline.go | Process | func (p *Pipeline) Process(n *NodeInfo) bool {
for i, entry := range p.checklist {
if entry.enabled && !entry.f.Check(n) {
// Immediately stop on first failure.
p.checklist[i].failureCount++
return false
}
}
for i := range p.checklist {
p.checklist[i].failureCount = 0
}
return true
} | go | func (p *Pipeline) Process(n *NodeInfo) bool {
for i, entry := range p.checklist {
if entry.enabled && !entry.f.Check(n) {
// Immediately stop on first failure.
p.checklist[i].failureCount++
return false
}
}
for i := range p.checklist {
p.checklist[i].failureCount = 0
}
return true
} | [
"func",
"(",
"p",
"*",
"Pipeline",
")",
"Process",
"(",
"n",
"*",
"NodeInfo",
")",
"bool",
"{",
"for",
"i",
",",
"entry",
":=",
"range",
"p",
".",
"checklist",
"{",
"if",
"entry",
".",
"enabled",
"&&",
"!",
"entry",
".",
"f",
".",
"Check",
"(",
... | // Process a node through the filter pipeline.
// Returns true if all filters pass, false otherwise. | [
"Process",
"a",
"node",
"through",
"the",
"filter",
"pipeline",
".",
"Returns",
"true",
"if",
"all",
"filters",
"pass",
"false",
"otherwise",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/scheduler/pipeline.go#L56-L68 | train |
docker/swarmkit | manager/scheduler/pipeline.go | SetTask | func (p *Pipeline) SetTask(t *api.Task) {
for i := range p.checklist {
p.checklist[i].enabled = p.checklist[i].f.SetTask(t)
p.checklist[i].failureCount = 0
}
} | go | func (p *Pipeline) SetTask(t *api.Task) {
for i := range p.checklist {
p.checklist[i].enabled = p.checklist[i].f.SetTask(t)
p.checklist[i].failureCount = 0
}
} | [
"func",
"(",
"p",
"*",
"Pipeline",
")",
"SetTask",
"(",
"t",
"*",
"api",
".",
"Task",
")",
"{",
"for",
"i",
":=",
"range",
"p",
".",
"checklist",
"{",
"p",
".",
"checklist",
"[",
"i",
"]",
".",
"enabled",
"=",
"p",
".",
"checklist",
"[",
"i",
... | // SetTask sets up the filters to process a new task. Once this is called,
// Process can be called repeatedly to try to assign the task various nodes. | [
"SetTask",
"sets",
"up",
"the",
"filters",
"to",
"process",
"a",
"new",
"task",
".",
"Once",
"this",
"is",
"called",
"Process",
"can",
"be",
"called",
"repeatedly",
"to",
"try",
"to",
"assign",
"the",
"task",
"various",
"nodes",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/scheduler/pipeline.go#L72-L77 | train |
docker/swarmkit | manager/scheduler/pipeline.go | Explain | func (p *Pipeline) Explain() string {
var explanation string
// Sort from most failures to least
sortedByFailures := make([]checklistEntry, len(p.checklist))
copy(sortedByFailures, p.checklist)
sort.Sort(sort.Reverse(checklistByFailures(sortedByFailures)))
for _, entry := range sortedByFailures {
if entry.fa... | go | func (p *Pipeline) Explain() string {
var explanation string
// Sort from most failures to least
sortedByFailures := make([]checklistEntry, len(p.checklist))
copy(sortedByFailures, p.checklist)
sort.Sort(sort.Reverse(checklistByFailures(sortedByFailures)))
for _, entry := range sortedByFailures {
if entry.fa... | [
"func",
"(",
"p",
"*",
"Pipeline",
")",
"Explain",
"(",
")",
"string",
"{",
"var",
"explanation",
"string",
"\n\n",
"// Sort from most failures to least",
"sortedByFailures",
":=",
"make",
"(",
"[",
"]",
"checklistEntry",
",",
"len",
"(",
"p",
".",
"checklist"... | // Explain returns a string explaining why a task could not be scheduled. | [
"Explain",
"returns",
"a",
"string",
"explaining",
"why",
"a",
"task",
"could",
"not",
"be",
"scheduled",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/scheduler/pipeline.go#L80-L99 | train |
docker/swarmkit | manager/controlapi/service.go | validateImage | func validateImage(image string) error {
if image == "" {
return status.Errorf(codes.InvalidArgument, "ContainerSpec: image reference must be provided")
}
if _, err := reference.ParseNormalizedNamed(image); err != nil {
return status.Errorf(codes.InvalidArgument, "ContainerSpec: %q is not a valid repository/tag... | go | func validateImage(image string) error {
if image == "" {
return status.Errorf(codes.InvalidArgument, "ContainerSpec: image reference must be provided")
}
if _, err := reference.ParseNormalizedNamed(image); err != nil {
return status.Errorf(codes.InvalidArgument, "ContainerSpec: %q is not a valid repository/tag... | [
"func",
"validateImage",
"(",
"image",
"string",
")",
"error",
"{",
"if",
"image",
"==",
"\"",
"\"",
"{",
"return",
"status",
".",
"Errorf",
"(",
"codes",
".",
"InvalidArgument",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"_",
",",
"err",
":=",
... | // validateImage validates image name in containerSpec | [
"validateImage",
"validates",
"image",
"name",
"in",
"containerSpec"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/service.go#L165-L174 | train |
docker/swarmkit | manager/controlapi/service.go | validateMounts | func validateMounts(mounts []api.Mount) error {
mountMap := make(map[string]bool)
for _, mount := range mounts {
if _, exists := mountMap[mount.Target]; exists {
return status.Errorf(codes.InvalidArgument, "ContainerSpec: duplicate mount point: %s", mount.Target)
}
mountMap[mount.Target] = true
}
return n... | go | func validateMounts(mounts []api.Mount) error {
mountMap := make(map[string]bool)
for _, mount := range mounts {
if _, exists := mountMap[mount.Target]; exists {
return status.Errorf(codes.InvalidArgument, "ContainerSpec: duplicate mount point: %s", mount.Target)
}
mountMap[mount.Target] = true
}
return n... | [
"func",
"validateMounts",
"(",
"mounts",
"[",
"]",
"api",
".",
"Mount",
")",
"error",
"{",
"mountMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\n",
"for",
"_",
",",
"mount",
":=",
"range",
"mounts",
"{",
"if",
"_",
",",
"exists"... | // validateMounts validates if there are duplicate mounts in containerSpec | [
"validateMounts",
"validates",
"if",
"there",
"are",
"duplicate",
"mounts",
"in",
"containerSpec"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/service.go#L177-L187 | train |
docker/swarmkit | manager/controlapi/service.go | validateHealthCheck | func validateHealthCheck(hc *api.HealthConfig) error {
if hc == nil {
return nil
}
if hc.Interval != nil {
interval, err := gogotypes.DurationFromProto(hc.Interval)
if err != nil {
return err
}
if interval != 0 && interval < minimumDuration {
return status.Errorf(codes.InvalidArgument, "ContainerSpe... | go | func validateHealthCheck(hc *api.HealthConfig) error {
if hc == nil {
return nil
}
if hc.Interval != nil {
interval, err := gogotypes.DurationFromProto(hc.Interval)
if err != nil {
return err
}
if interval != 0 && interval < minimumDuration {
return status.Errorf(codes.InvalidArgument, "ContainerSpe... | [
"func",
"validateHealthCheck",
"(",
"hc",
"*",
"api",
".",
"HealthConfig",
")",
"error",
"{",
"if",
"hc",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"hc",
".",
"Interval",
"!=",
"nil",
"{",
"interval",
",",
"err",
":=",
"gogotypes",
... | // validateHealthCheck validates configs about container's health check | [
"validateHealthCheck",
"validates",
"configs",
"about",
"container",
"s",
"health",
"check"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/service.go#L190-L230 | train |
docker/swarmkit | manager/controlapi/service.go | validateSecretRefsSpec | func validateSecretRefsSpec(spec api.TaskSpec) error {
container := spec.GetContainer()
if container == nil {
return nil
}
// Keep a map to track all the targets that will be exposed
// The string returned is only used for logging. It could as well be struct{}{}
existingTargets := make(map[string]string)
for ... | go | func validateSecretRefsSpec(spec api.TaskSpec) error {
container := spec.GetContainer()
if container == nil {
return nil
}
// Keep a map to track all the targets that will be exposed
// The string returned is only used for logging. It could as well be struct{}{}
existingTargets := make(map[string]string)
for ... | [
"func",
"validateSecretRefsSpec",
"(",
"spec",
"api",
".",
"TaskSpec",
")",
"error",
"{",
"container",
":=",
"spec",
".",
"GetContainer",
"(",
")",
"\n",
"if",
"container",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Keep a map to track all the t... | // validateSecretRefsSpec finds if the secrets passed in spec are valid and have no
// conflicting targets. | [
"validateSecretRefsSpec",
"finds",
"if",
"the",
"secrets",
"passed",
"in",
"spec",
"are",
"valid",
"and",
"have",
"no",
"conflicting",
"targets",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/service.go#L349-L385 | train |
docker/swarmkit | manager/controlapi/service.go | validateConfigRefsSpec | func validateConfigRefsSpec(spec api.TaskSpec) error {
container := spec.GetContainer()
if container == nil {
return nil
}
// check if we're using a config as a CredentialSpec -- if so, we need to
// verify
var (
credSpecConfig string
credSpecConfigFound bool
)
if p := container.Privileges; p != nil... | go | func validateConfigRefsSpec(spec api.TaskSpec) error {
container := spec.GetContainer()
if container == nil {
return nil
}
// check if we're using a config as a CredentialSpec -- if so, we need to
// verify
var (
credSpecConfig string
credSpecConfigFound bool
)
if p := container.Privileges; p != nil... | [
"func",
"validateConfigRefsSpec",
"(",
"spec",
"api",
".",
"TaskSpec",
")",
"error",
"{",
"container",
":=",
"spec",
".",
"GetContainer",
"(",
")",
"\n",
"if",
"container",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// check if we're using a config... | // validateConfigRefsSpec finds if the configs passed in spec are valid and have no
// conflicting targets. | [
"validateConfigRefsSpec",
"finds",
"if",
"the",
"configs",
"passed",
"in",
"spec",
"are",
"valid",
"and",
"have",
"no",
"conflicting",
"targets",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/service.go#L389-L456 | train |
docker/swarmkit | manager/controlapi/service.go | checkSecretExistence | func (s *Server) checkSecretExistence(tx store.Tx, spec *api.ServiceSpec) error {
container := spec.Task.GetContainer()
if container == nil {
return nil
}
var failedSecrets []string
for _, secretRef := range container.Secrets {
secret := store.GetSecret(tx, secretRef.SecretID)
// Check to see if the secret ... | go | func (s *Server) checkSecretExistence(tx store.Tx, spec *api.ServiceSpec) error {
container := spec.Task.GetContainer()
if container == nil {
return nil
}
var failedSecrets []string
for _, secretRef := range container.Secrets {
secret := store.GetSecret(tx, secretRef.SecretID)
// Check to see if the secret ... | [
"func",
"(",
"s",
"*",
"Server",
")",
"checkSecretExistence",
"(",
"tx",
"store",
".",
"Tx",
",",
"spec",
"*",
"api",
".",
"ServiceSpec",
")",
"error",
"{",
"container",
":=",
"spec",
".",
"Task",
".",
"GetContainer",
"(",
")",
"\n",
"if",
"container",... | // checkSecretExistence finds if the secret exists | [
"checkSecretExistence",
"finds",
"if",
"the",
"secret",
"exists"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/service.go#L609-L635 | train |
docker/swarmkit | manager/controlapi/service.go | checkConfigExistence | func (s *Server) checkConfigExistence(tx store.Tx, spec *api.ServiceSpec) error {
container := spec.Task.GetContainer()
if container == nil {
return nil
}
var failedConfigs []string
for _, configRef := range container.Configs {
config := store.GetConfig(tx, configRef.ConfigID)
// Check to see if the config ... | go | func (s *Server) checkConfigExistence(tx store.Tx, spec *api.ServiceSpec) error {
container := spec.Task.GetContainer()
if container == nil {
return nil
}
var failedConfigs []string
for _, configRef := range container.Configs {
config := store.GetConfig(tx, configRef.ConfigID)
// Check to see if the config ... | [
"func",
"(",
"s",
"*",
"Server",
")",
"checkConfigExistence",
"(",
"tx",
"store",
".",
"Tx",
",",
"spec",
"*",
"api",
".",
"ServiceSpec",
")",
"error",
"{",
"container",
":=",
"spec",
".",
"Task",
".",
"GetContainer",
"(",
")",
"\n",
"if",
"container",... | // checkConfigExistence finds if the config exists | [
"checkConfigExistence",
"finds",
"if",
"the",
"config",
"exists"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/service.go#L638-L664 | train |
docker/swarmkit | manager/controlapi/service.go | CreateService | func (s *Server) CreateService(ctx context.Context, request *api.CreateServiceRequest) (*api.CreateServiceResponse, error) {
if err := validateServiceSpec(request.Spec); err != nil {
return nil, err
}
if err := s.validateNetworks(request.Spec.Task.Networks); err != nil {
return nil, err
}
if err := s.checkPo... | go | func (s *Server) CreateService(ctx context.Context, request *api.CreateServiceRequest) (*api.CreateServiceResponse, error) {
if err := validateServiceSpec(request.Spec); err != nil {
return nil, err
}
if err := s.validateNetworks(request.Spec.Task.Networks); err != nil {
return nil, err
}
if err := s.checkPo... | [
"func",
"(",
"s",
"*",
"Server",
")",
"CreateService",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"api",
".",
"CreateServiceRequest",
")",
"(",
"*",
"api",
".",
"CreateServiceResponse",
",",
"error",
")",
"{",
"if",
"err",
":=",
"validat... | // CreateService creates and returns a Service based on the provided ServiceSpec.
// - Returns `InvalidArgument` if the ServiceSpec is malformed.
// - Returns `Unimplemented` if the ServiceSpec references unimplemented features.
// - Returns `AlreadyExists` if the ServiceID conflicts.
// - Returns an error if the creat... | [
"CreateService",
"creates",
"and",
"returns",
"a",
"Service",
"based",
"on",
"the",
"provided",
"ServiceSpec",
".",
"-",
"Returns",
"InvalidArgument",
"if",
"the",
"ServiceSpec",
"is",
"malformed",
".",
"-",
"Returns",
"Unimplemented",
"if",
"the",
"ServiceSpec",
... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/service.go#L671-L723 | train |
docker/swarmkit | manager/controlapi/service.go | GetService | func (s *Server) GetService(ctx context.Context, request *api.GetServiceRequest) (*api.GetServiceResponse, error) {
if request.ServiceID == "" {
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
}
var service *api.Service
s.store.View(func(tx store.ReadTx) {
service = store.GetServic... | go | func (s *Server) GetService(ctx context.Context, request *api.GetServiceRequest) (*api.GetServiceResponse, error) {
if request.ServiceID == "" {
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
}
var service *api.Service
s.store.View(func(tx store.ReadTx) {
service = store.GetServic... | [
"func",
"(",
"s",
"*",
"Server",
")",
"GetService",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"api",
".",
"GetServiceRequest",
")",
"(",
"*",
"api",
".",
"GetServiceResponse",
",",
"error",
")",
"{",
"if",
"request",
".",
"ServiceID",
... | // GetService returns a Service given a ServiceID.
// - Returns `InvalidArgument` if ServiceID is not provided.
// - Returns `NotFound` if the Service is not found. | [
"GetService",
"returns",
"a",
"Service",
"given",
"a",
"ServiceID",
".",
"-",
"Returns",
"InvalidArgument",
"if",
"ServiceID",
"is",
"not",
"provided",
".",
"-",
"Returns",
"NotFound",
"if",
"the",
"Service",
"is",
"not",
"found",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/service.go#L728-L748 | train |
docker/swarmkit | manager/controlapi/service.go | RemoveService | func (s *Server) RemoveService(ctx context.Context, request *api.RemoveServiceRequest) (*api.RemoveServiceResponse, error) {
if request.ServiceID == "" {
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
}
err := s.store.Update(func(tx store.Tx) error {
return store.DeleteService(tx, ... | go | func (s *Server) RemoveService(ctx context.Context, request *api.RemoveServiceRequest) (*api.RemoveServiceResponse, error) {
if request.ServiceID == "" {
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
}
err := s.store.Update(func(tx store.Tx) error {
return store.DeleteService(tx, ... | [
"func",
"(",
"s",
"*",
"Server",
")",
"RemoveService",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"api",
".",
"RemoveServiceRequest",
")",
"(",
"*",
"api",
".",
"RemoveServiceResponse",
",",
"error",
")",
"{",
"if",
"request",
".",
"Serv... | // RemoveService removes a Service referenced by ServiceID.
// - Returns `InvalidArgument` if ServiceID is not provided.
// - Returns `NotFound` if the Service is not found.
// - Returns an error if the deletion fails. | [
"RemoveService",
"removes",
"a",
"Service",
"referenced",
"by",
"ServiceID",
".",
"-",
"Returns",
"InvalidArgument",
"if",
"ServiceID",
"is",
"not",
"provided",
".",
"-",
"Returns",
"NotFound",
"if",
"the",
"Service",
"is",
"not",
"found",
".",
"-",
"Returns",... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/service.go#L874-L889 | train |
docker/swarmkit | manager/controlapi/service.go | ListServices | func (s *Server) ListServices(ctx context.Context, request *api.ListServicesRequest) (*api.ListServicesResponse, error) {
var (
services []*api.Service
err error
)
s.store.View(func(tx store.ReadTx) {
switch {
case request.Filters != nil && len(request.Filters.Names) > 0:
services, err = store.FindS... | go | func (s *Server) ListServices(ctx context.Context, request *api.ListServicesRequest) (*api.ListServicesResponse, error) {
var (
services []*api.Service
err error
)
s.store.View(func(tx store.ReadTx) {
switch {
case request.Filters != nil && len(request.Filters.Names) > 0:
services, err = store.FindS... | [
"func",
"(",
"s",
"*",
"Server",
")",
"ListServices",
"(",
"ctx",
"context",
".",
"Context",
",",
"request",
"*",
"api",
".",
"ListServicesRequest",
")",
"(",
"*",
"api",
".",
"ListServicesResponse",
",",
"error",
")",
"{",
"var",
"(",
"services",
"[",
... | // ListServices returns a list of all services. | [
"ListServices",
"returns",
"a",
"list",
"of",
"all",
"services",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/controlapi/service.go#L911-L970 | train |
docker/swarmkit | manager/logbroker/broker.go | Start | func (lb *LogBroker) Start(ctx context.Context) error {
lb.mu.Lock()
defer lb.mu.Unlock()
if lb.cancelAll != nil {
return errAlreadyRunning
}
lb.pctx, lb.cancelAll = context.WithCancel(ctx)
lb.logQueue = watch.NewQueue()
lb.subscriptionQueue = watch.NewQueue()
lb.registeredSubscriptions = make(map[string]*s... | go | func (lb *LogBroker) Start(ctx context.Context) error {
lb.mu.Lock()
defer lb.mu.Unlock()
if lb.cancelAll != nil {
return errAlreadyRunning
}
lb.pctx, lb.cancelAll = context.WithCancel(ctx)
lb.logQueue = watch.NewQueue()
lb.subscriptionQueue = watch.NewQueue()
lb.registeredSubscriptions = make(map[string]*s... | [
"func",
"(",
"lb",
"*",
"LogBroker",
")",
"Start",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"lb",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"lb",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"lb",
".",
"cancelAll",
... | // Start starts the log broker | [
"Start",
"starts",
"the",
"log",
"broker"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/logbroker/broker.go#L60-L74 | train |
docker/swarmkit | manager/logbroker/broker.go | Stop | func (lb *LogBroker) Stop() error {
lb.mu.Lock()
defer lb.mu.Unlock()
if lb.cancelAll == nil {
return errNotRunning
}
lb.cancelAll()
lb.cancelAll = nil
lb.logQueue.Close()
lb.subscriptionQueue.Close()
return nil
} | go | func (lb *LogBroker) Stop() error {
lb.mu.Lock()
defer lb.mu.Unlock()
if lb.cancelAll == nil {
return errNotRunning
}
lb.cancelAll()
lb.cancelAll = nil
lb.logQueue.Close()
lb.subscriptionQueue.Close()
return nil
} | [
"func",
"(",
"lb",
"*",
"LogBroker",
")",
"Stop",
"(",
")",
"error",
"{",
"lb",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"lb",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"lb",
".",
"cancelAll",
"==",
"nil",
"{",
"return",
"errNot... | // Stop stops the log broker | [
"Stop",
"stops",
"the",
"log",
"broker"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/logbroker/broker.go#L77-L91 | train |
docker/swarmkit | manager/logbroker/broker.go | watchSubscriptions | func (lb *LogBroker) watchSubscriptions(nodeID string) ([]*subscription, chan events.Event, func()) {
lb.mu.RLock()
defer lb.mu.RUnlock()
// Watch for subscription changes for this node.
ch, cancel := lb.subscriptionQueue.CallbackWatch(events.MatcherFunc(func(event events.Event) bool {
s := event.(*subscription)... | go | func (lb *LogBroker) watchSubscriptions(nodeID string) ([]*subscription, chan events.Event, func()) {
lb.mu.RLock()
defer lb.mu.RUnlock()
// Watch for subscription changes for this node.
ch, cancel := lb.subscriptionQueue.CallbackWatch(events.MatcherFunc(func(event events.Event) bool {
s := event.(*subscription)... | [
"func",
"(",
"lb",
"*",
"LogBroker",
")",
"watchSubscriptions",
"(",
"nodeID",
"string",
")",
"(",
"[",
"]",
"*",
"subscription",
",",
"chan",
"events",
".",
"Event",
",",
"func",
"(",
")",
")",
"{",
"lb",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
... | // watchSubscriptions grabs all current subscriptions and notifies of any
// subscription change for this node.
//
// Subscriptions may fire multiple times and the caller has to protect against
// dupes. | [
"watchSubscriptions",
"grabs",
"all",
"current",
"subscriptions",
"and",
"notifies",
"of",
"any",
"subscription",
"change",
"for",
"this",
"node",
".",
"Subscriptions",
"may",
"fire",
"multiple",
"times",
"and",
"the",
"caller",
"has",
"to",
"protect",
"against",
... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/logbroker/broker.go#L170-L189 | train |
docker/swarmkit | manager/logbroker/broker.go | SubscribeLogs | func (lb *LogBroker) SubscribeLogs(request *api.SubscribeLogsRequest, stream api.Logs_SubscribeLogsServer) error {
ctx := stream.Context()
if err := validateSelector(request.Selector); err != nil {
return err
}
lb.mu.Lock()
pctx := lb.pctx
lb.mu.Unlock()
if pctx == nil {
return errNotRunning
}
subscript... | go | func (lb *LogBroker) SubscribeLogs(request *api.SubscribeLogsRequest, stream api.Logs_SubscribeLogsServer) error {
ctx := stream.Context()
if err := validateSelector(request.Selector); err != nil {
return err
}
lb.mu.Lock()
pctx := lb.pctx
lb.mu.Unlock()
if pctx == nil {
return errNotRunning
}
subscript... | [
"func",
"(",
"lb",
"*",
"LogBroker",
")",
"SubscribeLogs",
"(",
"request",
"*",
"api",
".",
"SubscribeLogsRequest",
",",
"stream",
"api",
".",
"Logs_SubscribeLogsServer",
")",
"error",
"{",
"ctx",
":=",
"stream",
".",
"Context",
"(",
")",
"\n\n",
"if",
"er... | // SubscribeLogs creates a log subscription and streams back logs | [
"SubscribeLogs",
"creates",
"a",
"log",
"subscription",
"and",
"streams",
"back",
"logs"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/logbroker/broker.go#L224-L284 | train |
docker/swarmkit | manager/logbroker/broker.go | ListenSubscriptions | func (lb *LogBroker) ListenSubscriptions(request *api.ListenSubscriptionsRequest, stream api.LogBroker_ListenSubscriptionsServer) error {
remote, err := ca.RemoteNode(stream.Context())
if err != nil {
return err
}
lb.mu.Lock()
pctx := lb.pctx
lb.mu.Unlock()
if pctx == nil {
return errNotRunning
}
lb.node... | go | func (lb *LogBroker) ListenSubscriptions(request *api.ListenSubscriptionsRequest, stream api.LogBroker_ListenSubscriptionsServer) error {
remote, err := ca.RemoteNode(stream.Context())
if err != nil {
return err
}
lb.mu.Lock()
pctx := lb.pctx
lb.mu.Unlock()
if pctx == nil {
return errNotRunning
}
lb.node... | [
"func",
"(",
"lb",
"*",
"LogBroker",
")",
"ListenSubscriptions",
"(",
"request",
"*",
"api",
".",
"ListenSubscriptionsRequest",
",",
"stream",
"api",
".",
"LogBroker_ListenSubscriptionsServer",
")",
"error",
"{",
"remote",
",",
"err",
":=",
"ca",
".",
"RemoteNod... | // ListenSubscriptions returns a stream of matching subscriptions for the current node | [
"ListenSubscriptions",
"returns",
"a",
"stream",
"of",
"matching",
"subscriptions",
"for",
"the",
"current",
"node"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/logbroker/broker.go#L306-L377 | train |
docker/swarmkit | manager/logbroker/broker.go | PublishLogs | func (lb *LogBroker) PublishLogs(stream api.LogBroker_PublishLogsServer) (err error) {
remote, err := ca.RemoteNode(stream.Context())
if err != nil {
return err
}
var currentSubscription *subscription
defer func() {
if currentSubscription != nil {
lb.markDone(currentSubscription, remote.NodeID, err)
}
}... | go | func (lb *LogBroker) PublishLogs(stream api.LogBroker_PublishLogsServer) (err error) {
remote, err := ca.RemoteNode(stream.Context())
if err != nil {
return err
}
var currentSubscription *subscription
defer func() {
if currentSubscription != nil {
lb.markDone(currentSubscription, remote.NodeID, err)
}
}... | [
"func",
"(",
"lb",
"*",
"LogBroker",
")",
"PublishLogs",
"(",
"stream",
"api",
".",
"LogBroker_PublishLogsServer",
")",
"(",
"err",
"error",
")",
"{",
"remote",
",",
"err",
":=",
"ca",
".",
"RemoteNode",
"(",
"stream",
".",
"Context",
"(",
")",
")",
"\... | // PublishLogs publishes log messages for a given subscription | [
"PublishLogs",
"publishes",
"log",
"messages",
"for",
"a",
"given",
"subscription"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/logbroker/broker.go#L380-L435 | train |
docker/swarmkit | cmd/swarmctl/service/flagparser/secret.go | ParseAddSecret | func ParseAddSecret(cmd *cobra.Command, spec *api.ServiceSpec, flagName string) error {
flags := cmd.Flags()
if flags.Changed(flagName) {
secrets, err := flags.GetStringSlice(flagName)
if err != nil {
return err
}
container := spec.Task.GetContainer()
if container == nil {
spec.Task.Runtime = &api.T... | go | func ParseAddSecret(cmd *cobra.Command, spec *api.ServiceSpec, flagName string) error {
flags := cmd.Flags()
if flags.Changed(flagName) {
secrets, err := flags.GetStringSlice(flagName)
if err != nil {
return err
}
container := spec.Task.GetContainer()
if container == nil {
spec.Task.Runtime = &api.T... | [
"func",
"ParseAddSecret",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"spec",
"*",
"api",
".",
"ServiceSpec",
",",
"flagName",
"string",
")",
"error",
"{",
"flags",
":=",
"cmd",
".",
"Flags",
"(",
")",
"\n\n",
"if",
"flags",
".",
"Changed",
"(",
"... | // ParseAddSecret validates secrets passed on the command line | [
"ParseAddSecret",
"validates",
"secrets",
"passed",
"on",
"the",
"command",
"line"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/cmd/swarmctl/service/flagparser/secret.go#L36-L104 | train |
docker/swarmkit | cmd/swarmctl/service/flagparser/secret.go | ParseRemoveSecret | func ParseRemoveSecret(cmd *cobra.Command, spec *api.ServiceSpec, flagName string) error {
flags := cmd.Flags()
if flags.Changed(flagName) {
secrets, err := flags.GetStringSlice(flagName)
if err != nil {
return err
}
container := spec.Task.GetContainer()
if container == nil {
return nil
}
wantT... | go | func ParseRemoveSecret(cmd *cobra.Command, spec *api.ServiceSpec, flagName string) error {
flags := cmd.Flags()
if flags.Changed(flagName) {
secrets, err := flags.GetStringSlice(flagName)
if err != nil {
return err
}
container := spec.Task.GetContainer()
if container == nil {
return nil
}
wantT... | [
"func",
"ParseRemoveSecret",
"(",
"cmd",
"*",
"cobra",
".",
"Command",
",",
"spec",
"*",
"api",
".",
"ServiceSpec",
",",
"flagName",
"string",
")",
"error",
"{",
"flags",
":=",
"cmd",
".",
"Flags",
"(",
")",
"\n\n",
"if",
"flags",
".",
"Changed",
"(",
... | // ParseRemoveSecret removes a set of secrets from the task spec's secret references | [
"ParseRemoveSecret",
"removes",
"a",
"set",
"of",
"secrets",
"from",
"the",
"task",
"spec",
"s",
"secret",
"references"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/cmd/swarmctl/service/flagparser/secret.go#L107-L144 | train |
docker/swarmkit | manager/orchestrator/global/global.go | NewGlobalOrchestrator | func NewGlobalOrchestrator(store *store.MemoryStore) *Orchestrator {
restartSupervisor := restart.NewSupervisor(store)
updater := update.NewSupervisor(store, restartSupervisor)
return &Orchestrator{
store: store,
nodes: make(map[string]*api.Node),
globalServices: make(map[string]globalService... | go | func NewGlobalOrchestrator(store *store.MemoryStore) *Orchestrator {
restartSupervisor := restart.NewSupervisor(store)
updater := update.NewSupervisor(store, restartSupervisor)
return &Orchestrator{
store: store,
nodes: make(map[string]*api.Node),
globalServices: make(map[string]globalService... | [
"func",
"NewGlobalOrchestrator",
"(",
"store",
"*",
"store",
".",
"MemoryStore",
")",
"*",
"Orchestrator",
"{",
"restartSupervisor",
":=",
"restart",
".",
"NewSupervisor",
"(",
"store",
")",
"\n",
"updater",
":=",
"update",
".",
"NewSupervisor",
"(",
"store",
... | // NewGlobalOrchestrator creates a new global Orchestrator | [
"NewGlobalOrchestrator",
"creates",
"a",
"new",
"global",
"Orchestrator"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/orchestrator/global/global.go#L45-L58 | train |
docker/swarmkit | manager/orchestrator/global/global.go | FixTask | func (g *Orchestrator) FixTask(ctx context.Context, batch *store.Batch, t *api.Task) {
if _, exists := g.globalServices[t.ServiceID]; !exists {
return
}
// if a task's DesiredState has past running, the task has been processed
if t.DesiredState > api.TaskStateRunning {
return
}
var node *api.Node
if t.NodeI... | go | func (g *Orchestrator) FixTask(ctx context.Context, batch *store.Batch, t *api.Task) {
if _, exists := g.globalServices[t.ServiceID]; !exists {
return
}
// if a task's DesiredState has past running, the task has been processed
if t.DesiredState > api.TaskStateRunning {
return
}
var node *api.Node
if t.NodeI... | [
"func",
"(",
"g",
"*",
"Orchestrator",
")",
"FixTask",
"(",
"ctx",
"context",
".",
"Context",
",",
"batch",
"*",
"store",
".",
"Batch",
",",
"t",
"*",
"api",
".",
"Task",
")",
"{",
"if",
"_",
",",
"exists",
":=",
"g",
".",
"globalServices",
"[",
... | // FixTask validates a task with the current cluster settings, and takes
// action to make it conformant to node state and service constraint
// it's called at orchestrator initialization | [
"FixTask",
"validates",
"a",
"task",
"with",
"the",
"current",
"cluster",
"settings",
"and",
"takes",
"action",
"to",
"make",
"it",
"conformant",
"to",
"node",
"state",
"and",
"service",
"constraint",
"it",
"s",
"called",
"at",
"orchestrator",
"initialization"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/orchestrator/global/global.go#L177-L200 | train |
docker/swarmkit | manager/orchestrator/global/global.go | handleTaskChange | func (g *Orchestrator) handleTaskChange(ctx context.Context, t *api.Task) {
if _, exists := g.globalServices[t.ServiceID]; !exists {
return
}
// if a task's DesiredState has passed running, it
// means the task has been processed
if t.DesiredState > api.TaskStateRunning {
return
}
// if a task has passed ru... | go | func (g *Orchestrator) handleTaskChange(ctx context.Context, t *api.Task) {
if _, exists := g.globalServices[t.ServiceID]; !exists {
return
}
// if a task's DesiredState has passed running, it
// means the task has been processed
if t.DesiredState > api.TaskStateRunning {
return
}
// if a task has passed ru... | [
"func",
"(",
"g",
"*",
"Orchestrator",
")",
"handleTaskChange",
"(",
"ctx",
"context",
".",
"Context",
",",
"t",
"*",
"api",
".",
"Task",
")",
"{",
"if",
"_",
",",
"exists",
":=",
"g",
".",
"globalServices",
"[",
"t",
".",
"ServiceID",
"]",
";",
"!... | // handleTaskChange defines what orchestrator does when a task is updated by agent | [
"handleTaskChange",
"defines",
"what",
"orchestrator",
"does",
"when",
"a",
"task",
"is",
"updated",
"by",
"agent"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/orchestrator/global/global.go#L203-L217 | train |
docker/swarmkit | manager/orchestrator/global/global.go | updateNode | func (g *Orchestrator) updateNode(node *api.Node) {
if node.Spec.Availability == api.NodeAvailabilityDrain || node.Status.State == api.NodeStatus_DOWN {
delete(g.nodes, node.ID)
} else {
g.nodes[node.ID] = node
}
} | go | func (g *Orchestrator) updateNode(node *api.Node) {
if node.Spec.Availability == api.NodeAvailabilityDrain || node.Status.State == api.NodeStatus_DOWN {
delete(g.nodes, node.ID)
} else {
g.nodes[node.ID] = node
}
} | [
"func",
"(",
"g",
"*",
"Orchestrator",
")",
"updateNode",
"(",
"node",
"*",
"api",
".",
"Node",
")",
"{",
"if",
"node",
".",
"Spec",
".",
"Availability",
"==",
"api",
".",
"NodeAvailabilityDrain",
"||",
"node",
".",
"Status",
".",
"State",
"==",
"api",... | // updateNode updates g.nodes based on the current node value | [
"updateNode",
"updates",
"g",
".",
"nodes",
"based",
"on",
"the",
"current",
"node",
"value"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/orchestrator/global/global.go#L353-L359 | train |
docker/swarmkit | manager/orchestrator/global/global.go | updateService | func (g *Orchestrator) updateService(service *api.Service) {
var constraints []constraint.Constraint
if service.Spec.Task.Placement != nil && len(service.Spec.Task.Placement.Constraints) != 0 {
constraints, _ = constraint.Parse(service.Spec.Task.Placement.Constraints)
}
g.globalServices[service.ID] = globalServ... | go | func (g *Orchestrator) updateService(service *api.Service) {
var constraints []constraint.Constraint
if service.Spec.Task.Placement != nil && len(service.Spec.Task.Placement.Constraints) != 0 {
constraints, _ = constraint.Parse(service.Spec.Task.Placement.Constraints)
}
g.globalServices[service.ID] = globalServ... | [
"func",
"(",
"g",
"*",
"Orchestrator",
")",
"updateService",
"(",
"service",
"*",
"api",
".",
"Service",
")",
"{",
"var",
"constraints",
"[",
"]",
"constraint",
".",
"Constraint",
"\n\n",
"if",
"service",
".",
"Spec",
".",
"Task",
".",
"Placement",
"!=",... | // updateService updates g.globalServices based on the current service value | [
"updateService",
"updates",
"g",
".",
"globalServices",
"based",
"on",
"the",
"current",
"service",
"value"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/orchestrator/global/global.go#L362-L373 | train |
docker/swarmkit | manager/orchestrator/global/global.go | SlotTuple | func (g *Orchestrator) SlotTuple(t *api.Task) orchestrator.SlotTuple {
return orchestrator.SlotTuple{
ServiceID: t.ServiceID,
NodeID: t.NodeID,
}
} | go | func (g *Orchestrator) SlotTuple(t *api.Task) orchestrator.SlotTuple {
return orchestrator.SlotTuple{
ServiceID: t.ServiceID,
NodeID: t.NodeID,
}
} | [
"func",
"(",
"g",
"*",
"Orchestrator",
")",
"SlotTuple",
"(",
"t",
"*",
"api",
".",
"Task",
")",
"orchestrator",
".",
"SlotTuple",
"{",
"return",
"orchestrator",
".",
"SlotTuple",
"{",
"ServiceID",
":",
"t",
".",
"ServiceID",
",",
"NodeID",
":",
"t",
"... | // SlotTuple returns a slot tuple for the global service task. | [
"SlotTuple",
"returns",
"a",
"slot",
"tuple",
"for",
"the",
"global",
"service",
"task",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/orchestrator/global/global.go#L583-L588 | train |
docker/swarmkit | manager/scheduler/nodeinfo.go | removeTask | func (nodeInfo *NodeInfo) removeTask(t *api.Task) bool {
oldTask, ok := nodeInfo.Tasks[t.ID]
if !ok {
return false
}
delete(nodeInfo.Tasks, t.ID)
if oldTask.DesiredState <= api.TaskStateRunning {
nodeInfo.ActiveTasksCount--
nodeInfo.ActiveTasksCountByService[t.ServiceID]--
}
if t.Endpoint != nil {
for ... | go | func (nodeInfo *NodeInfo) removeTask(t *api.Task) bool {
oldTask, ok := nodeInfo.Tasks[t.ID]
if !ok {
return false
}
delete(nodeInfo.Tasks, t.ID)
if oldTask.DesiredState <= api.TaskStateRunning {
nodeInfo.ActiveTasksCount--
nodeInfo.ActiveTasksCountByService[t.ServiceID]--
}
if t.Endpoint != nil {
for ... | [
"func",
"(",
"nodeInfo",
"*",
"NodeInfo",
")",
"removeTask",
"(",
"t",
"*",
"api",
".",
"Task",
")",
"bool",
"{",
"oldTask",
",",
"ok",
":=",
"nodeInfo",
".",
"Tasks",
"[",
"t",
".",
"ID",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"false",
"\n",... | // removeTask removes a task from nodeInfo if it's tracked there, and returns true
// if nodeInfo was modified. | [
"removeTask",
"removes",
"a",
"task",
"from",
"nodeInfo",
"if",
"it",
"s",
"tracked",
"there",
"and",
"returns",
"true",
"if",
"nodeInfo",
"was",
"modified",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/scheduler/nodeinfo.go#L66-L104 | train |
docker/swarmkit | manager/scheduler/nodeinfo.go | addTask | func (nodeInfo *NodeInfo) addTask(t *api.Task) bool {
oldTask, ok := nodeInfo.Tasks[t.ID]
if ok {
if t.DesiredState <= api.TaskStateRunning && oldTask.DesiredState > api.TaskStateRunning {
nodeInfo.Tasks[t.ID] = t
nodeInfo.ActiveTasksCount++
nodeInfo.ActiveTasksCountByService[t.ServiceID]++
return true
... | go | func (nodeInfo *NodeInfo) addTask(t *api.Task) bool {
oldTask, ok := nodeInfo.Tasks[t.ID]
if ok {
if t.DesiredState <= api.TaskStateRunning && oldTask.DesiredState > api.TaskStateRunning {
nodeInfo.Tasks[t.ID] = t
nodeInfo.ActiveTasksCount++
nodeInfo.ActiveTasksCountByService[t.ServiceID]++
return true
... | [
"func",
"(",
"nodeInfo",
"*",
"NodeInfo",
")",
"addTask",
"(",
"t",
"*",
"api",
".",
"Task",
")",
"bool",
"{",
"oldTask",
",",
"ok",
":=",
"nodeInfo",
".",
"Tasks",
"[",
"t",
".",
"ID",
"]",
"\n",
"if",
"ok",
"{",
"if",
"t",
".",
"DesiredState",
... | // addTask adds or updates a task on nodeInfo, and returns true if nodeInfo was
// modified. | [
"addTask",
"adds",
"or",
"updates",
"a",
"task",
"on",
"nodeInfo",
"and",
"returns",
"true",
"if",
"nodeInfo",
"was",
"modified",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/scheduler/nodeinfo.go#L108-L154 | train |
docker/swarmkit | manager/scheduler/nodeinfo.go | taskFailed | func (nodeInfo *NodeInfo) taskFailed(ctx context.Context, t *api.Task) {
expired := 0
now := time.Now()
if now.Sub(nodeInfo.lastCleanup) >= monitorFailures {
nodeInfo.cleanupFailures(now)
}
versionedService := versionedService{serviceID: t.ServiceID}
if t.SpecVersion != nil {
versionedService.specVersion = ... | go | func (nodeInfo *NodeInfo) taskFailed(ctx context.Context, t *api.Task) {
expired := 0
now := time.Now()
if now.Sub(nodeInfo.lastCleanup) >= monitorFailures {
nodeInfo.cleanupFailures(now)
}
versionedService := versionedService{serviceID: t.ServiceID}
if t.SpecVersion != nil {
versionedService.specVersion = ... | [
"func",
"(",
"nodeInfo",
"*",
"NodeInfo",
")",
"taskFailed",
"(",
"ctx",
"context",
".",
"Context",
",",
"t",
"*",
"api",
".",
"Task",
")",
"{",
"expired",
":=",
"0",
"\n",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"if",
"now",
".",
"Sub... | // taskFailed records a task failure from a given service. | [
"taskFailed",
"records",
"a",
"task",
"failure",
"from",
"a",
"given",
"service",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/scheduler/nodeinfo.go#L177-L202 | train |
docker/swarmkit | manager/scheduler/nodeinfo.go | countRecentFailures | func (nodeInfo *NodeInfo) countRecentFailures(now time.Time, t *api.Task) int {
versionedService := versionedService{serviceID: t.ServiceID}
if t.SpecVersion != nil {
versionedService.specVersion = *t.SpecVersion
}
recentFailureCount := len(nodeInfo.recentFailures[versionedService])
for i := recentFailureCount ... | go | func (nodeInfo *NodeInfo) countRecentFailures(now time.Time, t *api.Task) int {
versionedService := versionedService{serviceID: t.ServiceID}
if t.SpecVersion != nil {
versionedService.specVersion = *t.SpecVersion
}
recentFailureCount := len(nodeInfo.recentFailures[versionedService])
for i := recentFailureCount ... | [
"func",
"(",
"nodeInfo",
"*",
"NodeInfo",
")",
"countRecentFailures",
"(",
"now",
"time",
".",
"Time",
",",
"t",
"*",
"api",
".",
"Task",
")",
"int",
"{",
"versionedService",
":=",
"versionedService",
"{",
"serviceID",
":",
"t",
".",
"ServiceID",
"}",
"\... | // countRecentFailures returns the number of times the service has failed on
// this node within the lookback window monitorFailures. | [
"countRecentFailures",
"returns",
"the",
"number",
"of",
"times",
"the",
"service",
"has",
"failed",
"on",
"this",
"node",
"within",
"the",
"lookback",
"window",
"monitorFailures",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/scheduler/nodeinfo.go#L206-L221 | train |
docker/swarmkit | agent/exec/dockerapi/docker_client_stub.go | ContainerCreate | func (sa *StubAPIClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networking *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error) {
sa.called()
return sa.ContainerCreateFn(ctx, config, hostConfig, networking, containerNa... | go | func (sa *StubAPIClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networking *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error) {
sa.called()
return sa.ContainerCreateFn(ctx, config, hostConfig, networking, containerNa... | [
"func",
"(",
"sa",
"*",
"StubAPIClient",
")",
"ContainerCreate",
"(",
"ctx",
"context",
".",
"Context",
",",
"config",
"*",
"container",
".",
"Config",
",",
"hostConfig",
"*",
"container",
".",
"HostConfig",
",",
"networking",
"*",
"network",
".",
"Networkin... | // ContainerCreate is part of the APIClient interface | [
"ContainerCreate",
"is",
"part",
"of",
"the",
"APIClient",
"interface"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/exec/dockerapi/docker_client_stub.go#L54-L57 | train |
docker/swarmkit | agent/exec/dockerapi/docker_client_stub.go | ContainerInspect | func (sa *StubAPIClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) {
sa.called()
return sa.ContainerInspectFn(ctx, containerID)
} | go | func (sa *StubAPIClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) {
sa.called()
return sa.ContainerInspectFn(ctx, containerID)
} | [
"func",
"(",
"sa",
"*",
"StubAPIClient",
")",
"ContainerInspect",
"(",
"ctx",
"context",
".",
"Context",
",",
"containerID",
"string",
")",
"(",
"types",
".",
"ContainerJSON",
",",
"error",
")",
"{",
"sa",
".",
"called",
"(",
")",
"\n",
"return",
"sa",
... | // ContainerInspect is part of the APIClient interface | [
"ContainerInspect",
"is",
"part",
"of",
"the",
"APIClient",
"interface"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/exec/dockerapi/docker_client_stub.go#L60-L63 | train |
docker/swarmkit | agent/exec/dockerapi/docker_client_stub.go | ContainerKill | func (sa *StubAPIClient) ContainerKill(ctx context.Context, containerID, signal string) error {
sa.called()
return sa.ContainerKillFn(ctx, containerID, signal)
} | go | func (sa *StubAPIClient) ContainerKill(ctx context.Context, containerID, signal string) error {
sa.called()
return sa.ContainerKillFn(ctx, containerID, signal)
} | [
"func",
"(",
"sa",
"*",
"StubAPIClient",
")",
"ContainerKill",
"(",
"ctx",
"context",
".",
"Context",
",",
"containerID",
",",
"signal",
"string",
")",
"error",
"{",
"sa",
".",
"called",
"(",
")",
"\n",
"return",
"sa",
".",
"ContainerKillFn",
"(",
"ctx",... | // ContainerKill is part of the APIClient interface | [
"ContainerKill",
"is",
"part",
"of",
"the",
"APIClient",
"interface"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/exec/dockerapi/docker_client_stub.go#L66-L69 | train |
docker/swarmkit | agent/exec/dockerapi/docker_client_stub.go | ContainerRemove | func (sa *StubAPIClient) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error {
sa.called()
return sa.ContainerRemoveFn(ctx, containerID, options)
} | go | func (sa *StubAPIClient) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error {
sa.called()
return sa.ContainerRemoveFn(ctx, containerID, options)
} | [
"func",
"(",
"sa",
"*",
"StubAPIClient",
")",
"ContainerRemove",
"(",
"ctx",
"context",
".",
"Context",
",",
"containerID",
"string",
",",
"options",
"types",
".",
"ContainerRemoveOptions",
")",
"error",
"{",
"sa",
".",
"called",
"(",
")",
"\n",
"return",
... | // ContainerRemove is part of the APIClient interface | [
"ContainerRemove",
"is",
"part",
"of",
"the",
"APIClient",
"interface"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/exec/dockerapi/docker_client_stub.go#L72-L75 | train |
docker/swarmkit | agent/exec/dockerapi/docker_client_stub.go | ContainerStart | func (sa *StubAPIClient) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error {
sa.called()
return sa.ContainerStartFn(ctx, containerID, options)
} | go | func (sa *StubAPIClient) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error {
sa.called()
return sa.ContainerStartFn(ctx, containerID, options)
} | [
"func",
"(",
"sa",
"*",
"StubAPIClient",
")",
"ContainerStart",
"(",
"ctx",
"context",
".",
"Context",
",",
"containerID",
"string",
",",
"options",
"types",
".",
"ContainerStartOptions",
")",
"error",
"{",
"sa",
".",
"called",
"(",
")",
"\n",
"return",
"s... | // ContainerStart is part of the APIClient interface | [
"ContainerStart",
"is",
"part",
"of",
"the",
"APIClient",
"interface"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/exec/dockerapi/docker_client_stub.go#L78-L81 | train |
docker/swarmkit | agent/exec/dockerapi/docker_client_stub.go | ContainerStop | func (sa *StubAPIClient) ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error {
sa.called()
return sa.ContainerStopFn(ctx, containerID, timeout)
} | go | func (sa *StubAPIClient) ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error {
sa.called()
return sa.ContainerStopFn(ctx, containerID, timeout)
} | [
"func",
"(",
"sa",
"*",
"StubAPIClient",
")",
"ContainerStop",
"(",
"ctx",
"context",
".",
"Context",
",",
"containerID",
"string",
",",
"timeout",
"*",
"time",
".",
"Duration",
")",
"error",
"{",
"sa",
".",
"called",
"(",
")",
"\n",
"return",
"sa",
".... | // ContainerStop is part of the APIClient interface | [
"ContainerStop",
"is",
"part",
"of",
"the",
"APIClient",
"interface"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/exec/dockerapi/docker_client_stub.go#L84-L87 | train |
docker/swarmkit | agent/exec/dockerapi/docker_client_stub.go | ImagePull | func (sa *StubAPIClient) ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) {
sa.called()
return sa.ImagePullFn(ctx, refStr, options)
} | go | func (sa *StubAPIClient) ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) {
sa.called()
return sa.ImagePullFn(ctx, refStr, options)
} | [
"func",
"(",
"sa",
"*",
"StubAPIClient",
")",
"ImagePull",
"(",
"ctx",
"context",
".",
"Context",
",",
"refStr",
"string",
",",
"options",
"types",
".",
"ImagePullOptions",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"sa",
".",
"called",
... | // ImagePull is part of the APIClient interface | [
"ImagePull",
"is",
"part",
"of",
"the",
"APIClient",
"interface"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/exec/dockerapi/docker_client_stub.go#L90-L93 | train |
docker/swarmkit | agent/exec/dockerapi/docker_client_stub.go | Events | func (sa *StubAPIClient) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) {
sa.called()
return sa.EventsFn(ctx, options)
} | go | func (sa *StubAPIClient) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) {
sa.called()
return sa.EventsFn(ctx, options)
} | [
"func",
"(",
"sa",
"*",
"StubAPIClient",
")",
"Events",
"(",
"ctx",
"context",
".",
"Context",
",",
"options",
"types",
".",
"EventsOptions",
")",
"(",
"<-",
"chan",
"events",
".",
"Message",
",",
"<-",
"chan",
"error",
")",
"{",
"sa",
".",
"called",
... | // Events is part of the APIClient interface | [
"Events",
"is",
"part",
"of",
"the",
"APIClient",
"interface"
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/exec/dockerapi/docker_client_stub.go#L96-L99 | train |
docker/swarmkit | manager/watchapi/watch.go | Watch | func (s *Server) Watch(request *api.WatchRequest, stream api.Watch_WatchServer) error {
ctx := stream.Context()
s.mu.Lock()
pctx := s.pctx
s.mu.Unlock()
if pctx == nil {
return errNotRunning
}
watchArgs, err := api.ConvertWatchArgs(request.Entries)
if err != nil {
return status.Errorf(codes.InvalidArgumen... | go | func (s *Server) Watch(request *api.WatchRequest, stream api.Watch_WatchServer) error {
ctx := stream.Context()
s.mu.Lock()
pctx := s.pctx
s.mu.Unlock()
if pctx == nil {
return errNotRunning
}
watchArgs, err := api.ConvertWatchArgs(request.Entries)
if err != nil {
return status.Errorf(codes.InvalidArgumen... | [
"func",
"(",
"s",
"*",
"Server",
")",
"Watch",
"(",
"request",
"*",
"api",
".",
"WatchRequest",
",",
"stream",
"api",
".",
"Watch_WatchServer",
")",
"error",
"{",
"ctx",
":=",
"stream",
".",
"Context",
"(",
")",
"\n\n",
"s",
".",
"mu",
".",
"Lock",
... | // Watch starts a stream that returns any changes to objects that match
// the specified selectors. When the stream begins, it immediately sends
// an empty message back to the client. It is important to wait for
// this message before taking any actions that depend on an established
// stream of changes for consistenc... | [
"Watch",
"starts",
"a",
"stream",
"that",
"returns",
"any",
"changes",
"to",
"objects",
"that",
"match",
"the",
"specified",
"selectors",
".",
"When",
"the",
"stream",
"begins",
"it",
"immediately",
"sends",
"an",
"empty",
"message",
"back",
"to",
"the",
"cl... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/watchapi/watch.go#L16-L64 | train |
docker/swarmkit | template/expand.go | ExpandContainerSpec | func ExpandContainerSpec(n *api.NodeDescription, t *api.Task) (*api.ContainerSpec, error) {
container := t.Spec.GetContainer()
if container == nil {
return nil, errors.Errorf("task missing ContainerSpec to expand")
}
container = container.Copy()
ctx := NewContext(n, t)
var err error
container.Env, err = expa... | go | func ExpandContainerSpec(n *api.NodeDescription, t *api.Task) (*api.ContainerSpec, error) {
container := t.Spec.GetContainer()
if container == nil {
return nil, errors.Errorf("task missing ContainerSpec to expand")
}
container = container.Copy()
ctx := NewContext(n, t)
var err error
container.Env, err = expa... | [
"func",
"ExpandContainerSpec",
"(",
"n",
"*",
"api",
".",
"NodeDescription",
",",
"t",
"*",
"api",
".",
"Task",
")",
"(",
"*",
"api",
".",
"ContainerSpec",
",",
"error",
")",
"{",
"container",
":=",
"t",
".",
"Spec",
".",
"GetContainer",
"(",
")",
"\... | // ExpandContainerSpec expands templated fields in the runtime using the task
// state and the node where it is scheduled to run.
// Templating is all evaluated on the agent-side, before execution.
//
// Note that these are projected only on runtime values, since active task
// values are typically manipulated in the m... | [
"ExpandContainerSpec",
"expands",
"templated",
"fields",
"in",
"the",
"runtime",
"using",
"the",
"task",
"state",
"and",
"the",
"node",
"where",
"it",
"is",
"scheduled",
"to",
"run",
".",
"Templating",
"is",
"all",
"evaluated",
"on",
"the",
"agent",
"-",
"si... | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/template/expand.go#L18-L41 | train |
docker/swarmkit | template/expand.go | ExpandSecretSpec | func ExpandSecretSpec(s *api.Secret, node *api.NodeDescription, t *api.Task, dependencies exec.DependencyGetter) (*api.SecretSpec, error) {
if s.Spec.Templating == nil {
return &s.Spec, nil
}
if s.Spec.Templating.Name == "golang" {
ctx := NewPayloadContextFromTask(node, t, dependencies)
secretSpec := s.Spec.Co... | go | func ExpandSecretSpec(s *api.Secret, node *api.NodeDescription, t *api.Task, dependencies exec.DependencyGetter) (*api.SecretSpec, error) {
if s.Spec.Templating == nil {
return &s.Spec, nil
}
if s.Spec.Templating.Name == "golang" {
ctx := NewPayloadContextFromTask(node, t, dependencies)
secretSpec := s.Spec.Co... | [
"func",
"ExpandSecretSpec",
"(",
"s",
"*",
"api",
".",
"Secret",
",",
"node",
"*",
"api",
".",
"NodeDescription",
",",
"t",
"*",
"api",
".",
"Task",
",",
"dependencies",
"exec",
".",
"DependencyGetter",
")",
"(",
"*",
"api",
".",
"SecretSpec",
",",
"er... | // ExpandSecretSpec expands the template inside the secret payload, if any.
// Templating is evaluated on the agent-side. | [
"ExpandSecretSpec",
"expands",
"the",
"template",
"inside",
"the",
"secret",
"payload",
"if",
"any",
".",
"Templating",
"is",
"evaluated",
"on",
"the",
"agent",
"-",
"side",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/template/expand.go#L132-L145 | train |
docker/swarmkit | template/expand.go | ExpandConfigSpec | func ExpandConfigSpec(c *api.Config, node *api.NodeDescription, t *api.Task, dependencies exec.DependencyGetter) (*api.ConfigSpec, bool, error) {
if c.Spec.Templating == nil {
return &c.Spec, false, nil
}
if c.Spec.Templating.Name == "golang" {
ctx := NewPayloadContextFromTask(node, t, dependencies)
configSpec... | go | func ExpandConfigSpec(c *api.Config, node *api.NodeDescription, t *api.Task, dependencies exec.DependencyGetter) (*api.ConfigSpec, bool, error) {
if c.Spec.Templating == nil {
return &c.Spec, false, nil
}
if c.Spec.Templating.Name == "golang" {
ctx := NewPayloadContextFromTask(node, t, dependencies)
configSpec... | [
"func",
"ExpandConfigSpec",
"(",
"c",
"*",
"api",
".",
"Config",
",",
"node",
"*",
"api",
".",
"NodeDescription",
",",
"t",
"*",
"api",
".",
"Task",
",",
"dependencies",
"exec",
".",
"DependencyGetter",
")",
"(",
"*",
"api",
".",
"ConfigSpec",
",",
"bo... | // ExpandConfigSpec expands the template inside the config payload, if any.
// Templating is evaluated on the agent-side. | [
"ExpandConfigSpec",
"expands",
"the",
"template",
"inside",
"the",
"config",
"payload",
"if",
"any",
".",
"Templating",
"is",
"evaluated",
"on",
"the",
"agent",
"-",
"side",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/template/expand.go#L149-L162 | train |
docker/swarmkit | agent/secrets/secrets.go | Get | func (s *secrets) Get(secretID string) (*api.Secret, error) {
s.mu.RLock()
defer s.mu.RUnlock()
if s, ok := s.m[secretID]; ok {
return s, nil
}
return nil, fmt.Errorf("secret %s not found", secretID)
} | go | func (s *secrets) Get(secretID string) (*api.Secret, error) {
s.mu.RLock()
defer s.mu.RUnlock()
if s, ok := s.m[secretID]; ok {
return s, nil
}
return nil, fmt.Errorf("secret %s not found", secretID)
} | [
"func",
"(",
"s",
"*",
"secrets",
")",
"Get",
"(",
"secretID",
"string",
")",
"(",
"*",
"api",
".",
"Secret",
",",
"error",
")",
"{",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"if",... | // Get returns a secret by ID. If the secret doesn't exist, returns nil. | [
"Get",
"returns",
"a",
"secret",
"by",
"ID",
".",
"If",
"the",
"secret",
"doesn",
"t",
"exist",
"returns",
"nil",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/secrets/secrets.go#L27-L34 | train |
docker/swarmkit | agent/secrets/secrets.go | Add | func (s *secrets) Add(secrets ...api.Secret) {
s.mu.Lock()
defer s.mu.Unlock()
for _, secret := range secrets {
s.m[secret.ID] = secret.Copy()
}
} | go | func (s *secrets) Add(secrets ...api.Secret) {
s.mu.Lock()
defer s.mu.Unlock()
for _, secret := range secrets {
s.m[secret.ID] = secret.Copy()
}
} | [
"func",
"(",
"s",
"*",
"secrets",
")",
"Add",
"(",
"secrets",
"...",
"api",
".",
"Secret",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"for",
"_",
",",
"secret",
":=",
"range"... | // Add adds one or more secrets to the secret map. | [
"Add",
"adds",
"one",
"or",
"more",
"secrets",
"to",
"the",
"secret",
"map",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/secrets/secrets.go#L37-L43 | train |
docker/swarmkit | agent/secrets/secrets.go | Remove | func (s *secrets) Remove(secrets []string) {
s.mu.Lock()
defer s.mu.Unlock()
for _, secret := range secrets {
delete(s.m, secret)
}
} | go | func (s *secrets) Remove(secrets []string) {
s.mu.Lock()
defer s.mu.Unlock()
for _, secret := range secrets {
delete(s.m, secret)
}
} | [
"func",
"(",
"s",
"*",
"secrets",
")",
"Remove",
"(",
"secrets",
"[",
"]",
"string",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"for",
"_",
",",
"secret",
":=",
"range",
"sec... | // Remove removes one or more secrets by ID from the secret map. Succeeds
// whether or not the given IDs are in the map. | [
"Remove",
"removes",
"one",
"or",
"more",
"secrets",
"by",
"ID",
"from",
"the",
"secret",
"map",
".",
"Succeeds",
"whether",
"or",
"not",
"the",
"given",
"IDs",
"are",
"in",
"the",
"map",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/secrets/secrets.go#L47-L53 | train |
docker/swarmkit | agent/secrets/secrets.go | Reset | func (s *secrets) Reset() {
s.mu.Lock()
defer s.mu.Unlock()
s.m = make(map[string]*api.Secret)
} | go | func (s *secrets) Reset() {
s.mu.Lock()
defer s.mu.Unlock()
s.m = make(map[string]*api.Secret)
} | [
"func",
"(",
"s",
"*",
"secrets",
")",
"Reset",
"(",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"s",
".",
"m",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"api",
".... | // Reset removes all the secrets. | [
"Reset",
"removes",
"all",
"the",
"secrets",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/secrets/secrets.go#L56-L60 | train |
docker/swarmkit | agent/secrets/secrets.go | Restrict | func Restrict(secrets exec.SecretGetter, t *api.Task) exec.SecretGetter {
sids := map[string]struct{}{}
container := t.Spec.GetContainer()
if container != nil {
for _, ref := range container.Secrets {
sids[ref.SecretID] = struct{}{}
}
}
return &taskRestrictedSecretsProvider{secrets: secrets, secretIDs: si... | go | func Restrict(secrets exec.SecretGetter, t *api.Task) exec.SecretGetter {
sids := map[string]struct{}{}
container := t.Spec.GetContainer()
if container != nil {
for _, ref := range container.Secrets {
sids[ref.SecretID] = struct{}{}
}
}
return &taskRestrictedSecretsProvider{secrets: secrets, secretIDs: si... | [
"func",
"Restrict",
"(",
"secrets",
"exec",
".",
"SecretGetter",
",",
"t",
"*",
"api",
".",
"Task",
")",
"exec",
".",
"SecretGetter",
"{",
"sids",
":=",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
"{",
"}",
"\n\n",
"container",
":=",
"t",
".",
"... | // Restrict provides a getter that only allows access to the secrets
// referenced by the task. | [
"Restrict",
"provides",
"a",
"getter",
"that",
"only",
"allows",
"access",
"to",
"the",
"secrets",
"referenced",
"by",
"the",
"task",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/agent/secrets/secrets.go#L90-L101 | train |
docker/swarmkit | manager/orchestrator/service.go | IsReplicatedService | func IsReplicatedService(service *api.Service) bool {
// service nil validation is required as there are scenarios
// where service is removed from store
if service == nil {
return false
}
_, ok := service.Spec.GetMode().(*api.ServiceSpec_Replicated)
return ok
} | go | func IsReplicatedService(service *api.Service) bool {
// service nil validation is required as there are scenarios
// where service is removed from store
if service == nil {
return false
}
_, ok := service.Spec.GetMode().(*api.ServiceSpec_Replicated)
return ok
} | [
"func",
"IsReplicatedService",
"(",
"service",
"*",
"api",
".",
"Service",
")",
"bool",
"{",
"// service nil validation is required as there are scenarios",
"// where service is removed from store",
"if",
"service",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
... | // IsReplicatedService checks if a service is a replicated service. | [
"IsReplicatedService",
"checks",
"if",
"a",
"service",
"is",
"a",
"replicated",
"service",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/orchestrator/service.go#L12-L20 | train |
docker/swarmkit | manager/orchestrator/service.go | IsGlobalService | func IsGlobalService(service *api.Service) bool {
if service == nil {
return false
}
_, ok := service.Spec.GetMode().(*api.ServiceSpec_Global)
return ok
} | go | func IsGlobalService(service *api.Service) bool {
if service == nil {
return false
}
_, ok := service.Spec.GetMode().(*api.ServiceSpec_Global)
return ok
} | [
"func",
"IsGlobalService",
"(",
"service",
"*",
"api",
".",
"Service",
")",
"bool",
"{",
"if",
"service",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"_",
",",
"ok",
":=",
"service",
".",
"Spec",
".",
"GetMode",
"(",
")",
".",
"(",
"*",
... | // IsGlobalService checks if the service is a global service. | [
"IsGlobalService",
"checks",
"if",
"the",
"service",
"is",
"a",
"global",
"service",
"."
] | 59163bf75df38489d4a10392265d27156dc473c5 | https://github.com/docker/swarmkit/blob/59163bf75df38489d4a10392265d27156dc473c5/manager/orchestrator/service.go#L23-L29 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.