id int32 0 167k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
132,500 | hashicorp/nomad | client/allocrunner/alloc_runner_hooks.go | postrun | func (ar *allocRunner) postrun() error {
if ar.logger.IsTrace() {
start := time.Now()
ar.logger.Trace("running post-run hooks", "start", start)
defer func() {
end := time.Now()
ar.logger.Trace("finished post-run hooks", "end", end, "duration", end.Sub(start))
}()
}
for _, hook := range ar.runnerHooks ... | go | func (ar *allocRunner) postrun() error {
if ar.logger.IsTrace() {
start := time.Now()
ar.logger.Trace("running post-run hooks", "start", start)
defer func() {
end := time.Now()
ar.logger.Trace("finished post-run hooks", "end", end, "duration", end.Sub(start))
}()
}
for _, hook := range ar.runnerHooks ... | [
"func",
"(",
"ar",
"*",
"allocRunner",
")",
"postrun",
"(",
")",
"error",
"{",
"if",
"ar",
".",
"logger",
".",
"IsTrace",
"(",
")",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"ar",
".",
"logger",
".",
"Trace",
"(",
"\"",
"\"",
",",... | // postrun is used to run the runners postrun hooks. | [
"postrun",
"is",
"used",
"to",
"run",
"the",
"runners",
"postrun",
"hooks",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/alloc_runner_hooks.go#L176-L210 |
132,501 | hashicorp/nomad | client/allocrunner/alloc_runner_hooks.go | destroy | func (ar *allocRunner) destroy() error {
if ar.logger.IsTrace() {
start := time.Now()
ar.logger.Trace("running destroy hooks", "start", start)
defer func() {
end := time.Now()
ar.logger.Trace("finished destroy hooks", "end", end, "duration", end.Sub(start))
}()
}
var merr multierror.Error
for _, hook... | go | func (ar *allocRunner) destroy() error {
if ar.logger.IsTrace() {
start := time.Now()
ar.logger.Trace("running destroy hooks", "start", start)
defer func() {
end := time.Now()
ar.logger.Trace("finished destroy hooks", "end", end, "duration", end.Sub(start))
}()
}
var merr multierror.Error
for _, hook... | [
"func",
"(",
"ar",
"*",
"allocRunner",
")",
"destroy",
"(",
")",
"error",
"{",
"if",
"ar",
".",
"logger",
".",
"IsTrace",
"(",
")",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"ar",
".",
"logger",
".",
"Trace",
"(",
"\"",
"\"",
",",... | // destroy is used to run the runners destroy hooks. All hooks are run and
// errors are returned as a multierror. | [
"destroy",
"is",
"used",
"to",
"run",
"the",
"runners",
"destroy",
"hooks",
".",
"All",
"hooks",
"are",
"run",
"and",
"errors",
"are",
"returned",
"as",
"a",
"multierror",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/alloc_runner_hooks.go#L214-L249 |
132,502 | hashicorp/nomad | client/alloc_endpoint.go | GarbageCollect | func (a *Allocations) GarbageCollect(args *nstructs.AllocSpecificRequest, reply *nstructs.GenericResponse) error {
defer metrics.MeasureSince([]string{"client", "allocations", "garbage_collect"}, time.Now())
// Check submit job permissions
if aclObj, err := a.c.ResolveToken(args.AuthToken); err != nil {
return er... | go | func (a *Allocations) GarbageCollect(args *nstructs.AllocSpecificRequest, reply *nstructs.GenericResponse) error {
defer metrics.MeasureSince([]string{"client", "allocations", "garbage_collect"}, time.Now())
// Check submit job permissions
if aclObj, err := a.c.ResolveToken(args.AuthToken); err != nil {
return er... | [
"func",
"(",
"a",
"*",
"Allocations",
")",
"GarbageCollect",
"(",
"args",
"*",
"nstructs",
".",
"AllocSpecificRequest",
",",
"reply",
"*",
"nstructs",
".",
"GenericResponse",
")",
"error",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string"... | // GarbageCollect is used to garbage collect an allocation on a client. | [
"GarbageCollect",
"is",
"used",
"to",
"garbage",
"collect",
"an",
"allocation",
"on",
"a",
"client",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/alloc_endpoint.go#L33-L49 |
132,503 | hashicorp/nomad | client/alloc_endpoint.go | Signal | func (a *Allocations) Signal(args *nstructs.AllocSignalRequest, reply *nstructs.GenericResponse) error {
defer metrics.MeasureSince([]string{"client", "allocations", "signal"}, time.Now())
// Check alloc-lifecycle permissions
if aclObj, err := a.c.ResolveToken(args.AuthToken); err != nil {
return err
} else if a... | go | func (a *Allocations) Signal(args *nstructs.AllocSignalRequest, reply *nstructs.GenericResponse) error {
defer metrics.MeasureSince([]string{"client", "allocations", "signal"}, time.Now())
// Check alloc-lifecycle permissions
if aclObj, err := a.c.ResolveToken(args.AuthToken); err != nil {
return err
} else if a... | [
"func",
"(",
"a",
"*",
"Allocations",
")",
"Signal",
"(",
"args",
"*",
"nstructs",
".",
"AllocSignalRequest",
",",
"reply",
"*",
"nstructs",
".",
"GenericResponse",
")",
"error",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
... | // Signal is used to send a signal to an allocation's tasks on a client. | [
"Signal",
"is",
"used",
"to",
"send",
"a",
"signal",
"to",
"an",
"allocation",
"s",
"tasks",
"on",
"a",
"client",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/alloc_endpoint.go#L52-L63 |
132,504 | hashicorp/nomad | client/alloc_endpoint.go | Restart | func (a *Allocations) Restart(args *nstructs.AllocRestartRequest, reply *nstructs.GenericResponse) error {
defer metrics.MeasureSince([]string{"client", "allocations", "restart"}, time.Now())
if aclObj, err := a.c.ResolveToken(args.AuthToken); err != nil {
return err
} else if aclObj != nil && !aclObj.AllowNsOp(a... | go | func (a *Allocations) Restart(args *nstructs.AllocRestartRequest, reply *nstructs.GenericResponse) error {
defer metrics.MeasureSince([]string{"client", "allocations", "restart"}, time.Now())
if aclObj, err := a.c.ResolveToken(args.AuthToken); err != nil {
return err
} else if aclObj != nil && !aclObj.AllowNsOp(a... | [
"func",
"(",
"a",
"*",
"Allocations",
")",
"Restart",
"(",
"args",
"*",
"nstructs",
".",
"AllocRestartRequest",
",",
"reply",
"*",
"nstructs",
".",
"GenericResponse",
")",
"error",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",... | // Restart is used to trigger a restart of an allocation or a subtask on a client. | [
"Restart",
"is",
"used",
"to",
"trigger",
"a",
"restart",
"of",
"an",
"allocation",
"or",
"a",
"subtask",
"on",
"a",
"client",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/alloc_endpoint.go#L66-L76 |
132,505 | hashicorp/nomad | client/alloc_endpoint.go | Stats | func (a *Allocations) Stats(args *cstructs.AllocStatsRequest, reply *cstructs.AllocStatsResponse) error {
defer metrics.MeasureSince([]string{"client", "allocations", "stats"}, time.Now())
// Check read job permissions
if aclObj, err := a.c.ResolveToken(args.AuthToken); err != nil {
return err
} else if aclObj !... | go | func (a *Allocations) Stats(args *cstructs.AllocStatsRequest, reply *cstructs.AllocStatsResponse) error {
defer metrics.MeasureSince([]string{"client", "allocations", "stats"}, time.Now())
// Check read job permissions
if aclObj, err := a.c.ResolveToken(args.AuthToken); err != nil {
return err
} else if aclObj !... | [
"func",
"(",
"a",
"*",
"Allocations",
")",
"Stats",
"(",
"args",
"*",
"cstructs",
".",
"AllocStatsRequest",
",",
"reply",
"*",
"cstructs",
".",
"AllocStatsResponse",
")",
"error",
"{",
"defer",
"metrics",
".",
"MeasureSince",
"(",
"[",
"]",
"string",
"{",
... | // Stats is used to collect allocation statistics | [
"Stats",
"is",
"used",
"to",
"collect",
"allocation",
"statistics"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/alloc_endpoint.go#L79-L102 |
132,506 | hashicorp/nomad | client/rpc.go | ClientRPC | func (c *Client) ClientRPC(method string, args interface{}, reply interface{}) error {
codec := &inmem.InmemCodec{
Method: method,
Args: args,
Reply: reply,
}
if err := c.rpcServer.ServeRequest(codec); err != nil {
return err
}
return codec.Err
} | go | func (c *Client) ClientRPC(method string, args interface{}, reply interface{}) error {
codec := &inmem.InmemCodec{
Method: method,
Args: args,
Reply: reply,
}
if err := c.rpcServer.ServeRequest(codec); err != nil {
return err
}
return codec.Err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ClientRPC",
"(",
"method",
"string",
",",
"args",
"interface",
"{",
"}",
",",
"reply",
"interface",
"{",
"}",
")",
"error",
"{",
"codec",
":=",
"&",
"inmem",
".",
"InmemCodec",
"{",
"Method",
":",
"method",
",",... | // ClientRPC is used to make a local, client only RPC call | [
"ClientRPC",
"is",
"used",
"to",
"make",
"a",
"local",
"client",
"only",
"RPC",
"call"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L29-L39 |
132,507 | hashicorp/nomad | client/rpc.go | StreamingRpcHandler | func (c *Client) StreamingRpcHandler(method string) (structs.StreamingRpcHandler, error) {
return c.streamingRpcs.GetHandler(method)
} | go | func (c *Client) StreamingRpcHandler(method string) (structs.StreamingRpcHandler, error) {
return c.streamingRpcs.GetHandler(method)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"StreamingRpcHandler",
"(",
"method",
"string",
")",
"(",
"structs",
".",
"StreamingRpcHandler",
",",
"error",
")",
"{",
"return",
"c",
".",
"streamingRpcs",
".",
"GetHandler",
"(",
"method",
")",
"\n",
"}"
] | // StreamingRpcHandler is used to make a local, client only streaming RPC
// call. | [
"StreamingRpcHandler",
"is",
"used",
"to",
"make",
"a",
"local",
"client",
"only",
"streaming",
"RPC",
"call",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L43-L45 |
132,508 | hashicorp/nomad | client/rpc.go | RPC | func (c *Client) RPC(method string, args interface{}, reply interface{}) error {
// Invoke the RPCHandler if it exists
if c.config.RPCHandler != nil {
return c.config.RPCHandler.RPC(method, args, reply)
}
// This is subtle but we start measuring the time on the client side
// right at the time of the first requ... | go | func (c *Client) RPC(method string, args interface{}, reply interface{}) error {
// Invoke the RPCHandler if it exists
if c.config.RPCHandler != nil {
return c.config.RPCHandler.RPC(method, args, reply)
}
// This is subtle but we start measuring the time on the client side
// right at the time of the first requ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"RPC",
"(",
"method",
"string",
",",
"args",
"interface",
"{",
"}",
",",
"reply",
"interface",
"{",
"}",
")",
"error",
"{",
"// Invoke the RPCHandler if it exists",
"if",
"c",
".",
"config",
".",
"RPCHandler",
"!=",
... | // RPC is used to forward an RPC call to a nomad server, or fail if no servers. | [
"RPC",
"is",
"used",
"to",
"forward",
"an",
"RPC",
"call",
"to",
"a",
"nomad",
"server",
"or",
"fail",
"if",
"no",
"servers",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L48-L98 |
132,509 | hashicorp/nomad | client/rpc.go | RemoteStreamingRpcHandler | func (c *Client) RemoteStreamingRpcHandler(method string) (structs.StreamingRpcHandler, error) {
server := c.servers.FindServer()
if server == nil {
return nil, noServersErr
}
conn, err := c.streamingRpcConn(server, method)
if err != nil {
// Move off to another server
c.rpcLogger.Error("error performing RP... | go | func (c *Client) RemoteStreamingRpcHandler(method string) (structs.StreamingRpcHandler, error) {
server := c.servers.FindServer()
if server == nil {
return nil, noServersErr
}
conn, err := c.streamingRpcConn(server, method)
if err != nil {
// Move off to another server
c.rpcLogger.Error("error performing RP... | [
"func",
"(",
"c",
"*",
"Client",
")",
"RemoteStreamingRpcHandler",
"(",
"method",
"string",
")",
"(",
"structs",
".",
"StreamingRpcHandler",
",",
"error",
")",
"{",
"server",
":=",
"c",
".",
"servers",
".",
"FindServer",
"(",
")",
"\n",
"if",
"server",
"... | // RemoteStreamingRpcHandler is used to make a streaming RPC call to a remote
// server. | [
"RemoteStreamingRpcHandler",
"is",
"used",
"to",
"make",
"a",
"streaming",
"RPC",
"call",
"to",
"a",
"remote",
"server",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L120-L135 |
132,510 | hashicorp/nomad | client/rpc.go | bridgedStreamingRpcHandler | func bridgedStreamingRpcHandler(sideA io.ReadWriteCloser) structs.StreamingRpcHandler {
return func(sideB io.ReadWriteCloser) {
defer sideA.Close()
defer sideB.Close()
structs.Bridge(sideA, sideB)
}
} | go | func bridgedStreamingRpcHandler(sideA io.ReadWriteCloser) structs.StreamingRpcHandler {
return func(sideB io.ReadWriteCloser) {
defer sideA.Close()
defer sideB.Close()
structs.Bridge(sideA, sideB)
}
} | [
"func",
"bridgedStreamingRpcHandler",
"(",
"sideA",
"io",
".",
"ReadWriteCloser",
")",
"structs",
".",
"StreamingRpcHandler",
"{",
"return",
"func",
"(",
"sideB",
"io",
".",
"ReadWriteCloser",
")",
"{",
"defer",
"sideA",
".",
"Close",
"(",
")",
"\n",
"defer",
... | // bridgedStreamingRpcHandler creates a bridged streaming RPC handler by copying
// data between the two sides. | [
"bridgedStreamingRpcHandler",
"creates",
"a",
"bridged",
"streaming",
"RPC",
"handler",
"by",
"copying",
"data",
"between",
"the",
"two",
"sides",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L139-L145 |
132,511 | hashicorp/nomad | client/rpc.go | streamingRpcConn | func (c *Client) streamingRpcConn(server *servers.Server, method string) (net.Conn, error) {
// Dial the server
conn, err := net.DialTimeout("tcp", server.Addr.String(), 10*time.Second)
if err != nil {
return nil, err
}
// Cast to TCPConn
if tcp, ok := conn.(*net.TCPConn); ok {
tcp.SetKeepAlive(true)
tcp.S... | go | func (c *Client) streamingRpcConn(server *servers.Server, method string) (net.Conn, error) {
// Dial the server
conn, err := net.DialTimeout("tcp", server.Addr.String(), 10*time.Second)
if err != nil {
return nil, err
}
// Cast to TCPConn
if tcp, ok := conn.(*net.TCPConn); ok {
tcp.SetKeepAlive(true)
tcp.S... | [
"func",
"(",
"c",
"*",
"Client",
")",
"streamingRpcConn",
"(",
"server",
"*",
"servers",
".",
"Server",
",",
"method",
"string",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"// Dial the server",
"conn",
",",
"err",
":=",
"net",
".",
"DialTime... | // streamingRpcConn is used to retrieve a connection to a server to conduct a
// streaming RPC. | [
"streamingRpcConn",
"is",
"used",
"to",
"retrieve",
"a",
"connection",
"to",
"a",
"server",
"to",
"conduct",
"a",
"streaming",
"RPC",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L149-L213 |
132,512 | hashicorp/nomad | client/rpc.go | setupClientRpc | func (c *Client) setupClientRpc() {
// Initialize the RPC handlers
c.endpoints.ClientStats = &ClientStats{c}
c.endpoints.FileSystem = NewFileSystemEndpoint(c)
c.endpoints.Allocations = &Allocations{c}
// Create the RPC Server
c.rpcServer = rpc.NewServer()
// Register the endpoints with the RPC server
c.setupC... | go | func (c *Client) setupClientRpc() {
// Initialize the RPC handlers
c.endpoints.ClientStats = &ClientStats{c}
c.endpoints.FileSystem = NewFileSystemEndpoint(c)
c.endpoints.Allocations = &Allocations{c}
// Create the RPC Server
c.rpcServer = rpc.NewServer()
// Register the endpoints with the RPC server
c.setupC... | [
"func",
"(",
"c",
"*",
"Client",
")",
"setupClientRpc",
"(",
")",
"{",
"// Initialize the RPC handlers",
"c",
".",
"endpoints",
".",
"ClientStats",
"=",
"&",
"ClientStats",
"{",
"c",
"}",
"\n",
"c",
".",
"endpoints",
".",
"FileSystem",
"=",
"NewFileSystemEnd... | // setupClientRpc is used to setup the Client's RPC endpoints | [
"setupClientRpc",
"is",
"used",
"to",
"setup",
"the",
"Client",
"s",
"RPC",
"endpoints"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L216-L229 |
132,513 | hashicorp/nomad | client/rpc.go | setupClientRpcServer | func (c *Client) setupClientRpcServer(server *rpc.Server) {
// Register the endpoints
server.Register(c.endpoints.ClientStats)
server.Register(c.endpoints.FileSystem)
server.Register(c.endpoints.Allocations)
} | go | func (c *Client) setupClientRpcServer(server *rpc.Server) {
// Register the endpoints
server.Register(c.endpoints.ClientStats)
server.Register(c.endpoints.FileSystem)
server.Register(c.endpoints.Allocations)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"setupClientRpcServer",
"(",
"server",
"*",
"rpc",
".",
"Server",
")",
"{",
"// Register the endpoints",
"server",
".",
"Register",
"(",
"c",
".",
"endpoints",
".",
"ClientStats",
")",
"\n",
"server",
".",
"Register",
... | // setupClientRpcServer is used to populate a client RPC server with endpoints. | [
"setupClientRpcServer",
"is",
"used",
"to",
"populate",
"a",
"client",
"RPC",
"server",
"with",
"endpoints",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L232-L237 |
132,514 | hashicorp/nomad | client/rpc.go | rpcConnListener | func (c *Client) rpcConnListener() {
// Make a channel for new connections.
conns := make(chan *yamux.Session, 4)
c.connPool.SetConnListener(conns)
for {
select {
case <-c.shutdownCh:
return
case session, ok := <-conns:
if !ok {
continue
}
go c.listenConn(session)
}
}
} | go | func (c *Client) rpcConnListener() {
// Make a channel for new connections.
conns := make(chan *yamux.Session, 4)
c.connPool.SetConnListener(conns)
for {
select {
case <-c.shutdownCh:
return
case session, ok := <-conns:
if !ok {
continue
}
go c.listenConn(session)
}
}
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"rpcConnListener",
"(",
")",
"{",
"// Make a channel for new connections.",
"conns",
":=",
"make",
"(",
"chan",
"*",
"yamux",
".",
"Session",
",",
"4",
")",
"\n",
"c",
".",
"connPool",
".",
"SetConnListener",
"(",
"con... | // rpcConnListener is a long lived function that listens for new connections
// being made on the connection pool and starts an RPC listener for each
// connection. | [
"rpcConnListener",
"is",
"a",
"long",
"lived",
"function",
"that",
"listens",
"for",
"new",
"connections",
"being",
"made",
"on",
"the",
"connection",
"pool",
"and",
"starts",
"an",
"RPC",
"listener",
"for",
"each",
"connection",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L242-L259 |
132,515 | hashicorp/nomad | client/rpc.go | listenConn | func (c *Client) listenConn(s *yamux.Session) {
for {
conn, err := s.Accept()
if err != nil {
if s.IsClosed() {
return
}
c.rpcLogger.Error("failed to accept RPC conn", "error", err)
continue
}
go c.handleConn(conn)
metrics.IncrCounter([]string{"client", "rpc", "accept_conn"}, 1)
}
} | go | func (c *Client) listenConn(s *yamux.Session) {
for {
conn, err := s.Accept()
if err != nil {
if s.IsClosed() {
return
}
c.rpcLogger.Error("failed to accept RPC conn", "error", err)
continue
}
go c.handleConn(conn)
metrics.IncrCounter([]string{"client", "rpc", "accept_conn"}, 1)
}
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"listenConn",
"(",
"s",
"*",
"yamux",
".",
"Session",
")",
"{",
"for",
"{",
"conn",
",",
"err",
":=",
"s",
".",
"Accept",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"s",
".",
"IsClosed",
"(",
")... | // listenConn is used to listen for connections being made from the server on
// pre-existing connection. This should be called in a goroutine. | [
"listenConn",
"is",
"used",
"to",
"listen",
"for",
"connections",
"being",
"made",
"from",
"the",
"server",
"on",
"pre",
"-",
"existing",
"connection",
".",
"This",
"should",
"be",
"called",
"in",
"a",
"goroutine",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L263-L278 |
132,516 | hashicorp/nomad | client/rpc.go | handleConn | func (c *Client) handleConn(conn net.Conn) {
// Read a single byte
buf := make([]byte, 1)
if _, err := conn.Read(buf); err != nil {
if err != io.EOF {
c.rpcLogger.Error("error reading byte", "error", err)
}
conn.Close()
return
}
// Switch on the byte
switch pool.RPCType(buf[0]) {
case pool.RpcNomad:
... | go | func (c *Client) handleConn(conn net.Conn) {
// Read a single byte
buf := make([]byte, 1)
if _, err := conn.Read(buf); err != nil {
if err != io.EOF {
c.rpcLogger.Error("error reading byte", "error", err)
}
conn.Close()
return
}
// Switch on the byte
switch pool.RPCType(buf[0]) {
case pool.RpcNomad:
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"handleConn",
"(",
"conn",
"net",
".",
"Conn",
")",
"{",
"// Read a single byte",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"conn",
".",
"Read",
"(",
"buf",... | // handleConn is used to determine if this is a RPC or Streaming RPC connection and
// invoke the correct handler | [
"handleConn",
"is",
"used",
"to",
"determine",
"if",
"this",
"is",
"a",
"RPC",
"or",
"Streaming",
"RPC",
"connection",
"and",
"invoke",
"the",
"correct",
"handler"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L282-L306 |
132,517 | hashicorp/nomad | client/rpc.go | handleNomadConn | func (c *Client) handleNomadConn(conn net.Conn) {
defer conn.Close()
rpcCodec := pool.NewServerCodec(conn)
for {
select {
case <-c.shutdownCh:
return
default:
}
if err := c.rpcServer.ServeRequest(rpcCodec); err != nil {
if err != io.EOF && !strings.Contains(err.Error(), "closed") {
c.rpcLogger.E... | go | func (c *Client) handleNomadConn(conn net.Conn) {
defer conn.Close()
rpcCodec := pool.NewServerCodec(conn)
for {
select {
case <-c.shutdownCh:
return
default:
}
if err := c.rpcServer.ServeRequest(rpcCodec); err != nil {
if err != io.EOF && !strings.Contains(err.Error(), "closed") {
c.rpcLogger.E... | [
"func",
"(",
"c",
"*",
"Client",
")",
"handleNomadConn",
"(",
"conn",
"net",
".",
"Conn",
")",
"{",
"defer",
"conn",
".",
"Close",
"(",
")",
"\n",
"rpcCodec",
":=",
"pool",
".",
"NewServerCodec",
"(",
"conn",
")",
"\n",
"for",
"{",
"select",
"{",
"... | // handleNomadConn is used to handle a single Nomad RPC connection. | [
"handleNomadConn",
"is",
"used",
"to",
"handle",
"a",
"single",
"Nomad",
"RPC",
"connection",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L309-L328 |
132,518 | hashicorp/nomad | client/rpc.go | resolveServer | func resolveServer(s string) (net.Addr, error) {
const defaultClientPort = "4647" // default client RPC port
host, port, err := net.SplitHostPort(s)
if err != nil {
if strings.Contains(err.Error(), "missing port") {
host = s
port = defaultClientPort
} else {
return nil, err
}
}
return net.ResolveTCP... | go | func resolveServer(s string) (net.Addr, error) {
const defaultClientPort = "4647" // default client RPC port
host, port, err := net.SplitHostPort(s)
if err != nil {
if strings.Contains(err.Error(), "missing port") {
host = s
port = defaultClientPort
} else {
return nil, err
}
}
return net.ResolveTCP... | [
"func",
"resolveServer",
"(",
"s",
"string",
")",
"(",
"net",
".",
"Addr",
",",
"error",
")",
"{",
"const",
"defaultClientPort",
"=",
"\"",
"\"",
"// default client RPC port",
"\n",
"host",
",",
"port",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
... | // resolveServer given a sever's address as a string, return it's resolved
// net.Addr or an error. | [
"resolveServer",
"given",
"a",
"sever",
"s",
"address",
"as",
"a",
"string",
"return",
"it",
"s",
"resolved",
"net",
".",
"Addr",
"or",
"an",
"error",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L372-L384 |
132,519 | hashicorp/nomad | client/rpc.go | Ping | func (c *Client) Ping(srv net.Addr) error {
var reply struct{}
err := c.connPool.RPC(c.Region(), srv, c.RPCMajorVersion(), "Status.Ping", struct{}{}, &reply)
return err
} | go | func (c *Client) Ping(srv net.Addr) error {
var reply struct{}
err := c.connPool.RPC(c.Region(), srv, c.RPCMajorVersion(), "Status.Ping", struct{}{}, &reply)
return err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Ping",
"(",
"srv",
"net",
".",
"Addr",
")",
"error",
"{",
"var",
"reply",
"struct",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
"connPool",
".",
"RPC",
"(",
"c",
".",
"Region",
"(",
")",
",",
"srv",
",",
"c",... | // Ping is used to ping a particular server and returns whether it is healthy or
// a potential error. | [
"Ping",
"is",
"used",
"to",
"ping",
"a",
"particular",
"server",
"and",
"returns",
"whether",
"it",
"is",
"healthy",
"or",
"a",
"potential",
"error",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L388-L392 |
132,520 | hashicorp/nomad | client/rpc.go | rpcRetryWatcher | func (c *Client) rpcRetryWatcher() <-chan struct{} {
c.rpcRetryLock.Lock()
defer c.rpcRetryLock.Unlock()
if c.rpcRetryCh == nil {
c.rpcRetryCh = make(chan struct{})
}
return c.rpcRetryCh
} | go | func (c *Client) rpcRetryWatcher() <-chan struct{} {
c.rpcRetryLock.Lock()
defer c.rpcRetryLock.Unlock()
if c.rpcRetryCh == nil {
c.rpcRetryCh = make(chan struct{})
}
return c.rpcRetryCh
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"rpcRetryWatcher",
"(",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"c",
".",
"rpcRetryLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"rpcRetryLock",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"c",
".",
"... | // rpcRetryWatcher returns a channel that will be closed if an event happens
// such that we expect the next RPC to be successful. | [
"rpcRetryWatcher",
"returns",
"a",
"channel",
"that",
"will",
"be",
"closed",
"if",
"an",
"event",
"happens",
"such",
"that",
"we",
"expect",
"the",
"next",
"RPC",
"to",
"be",
"successful",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L396-L405 |
132,521 | hashicorp/nomad | client/rpc.go | fireRpcRetryWatcher | func (c *Client) fireRpcRetryWatcher() {
c.rpcRetryLock.Lock()
defer c.rpcRetryLock.Unlock()
if c.rpcRetryCh != nil {
close(c.rpcRetryCh)
c.rpcRetryCh = nil
}
} | go | func (c *Client) fireRpcRetryWatcher() {
c.rpcRetryLock.Lock()
defer c.rpcRetryLock.Unlock()
if c.rpcRetryCh != nil {
close(c.rpcRetryCh)
c.rpcRetryCh = nil
}
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"fireRpcRetryWatcher",
"(",
")",
"{",
"c",
".",
"rpcRetryLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"rpcRetryLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"c",
".",
"rpcRetryCh",
"!=",
"nil",
"{",
"cl... | // fireRpcRetryWatcher causes any RPC retryloops to retry their RPCs because we
// believe the will be successful. | [
"fireRpcRetryWatcher",
"causes",
"any",
"RPC",
"retryloops",
"to",
"retry",
"their",
"RPCs",
"because",
"we",
"believe",
"the",
"will",
"be",
"successful",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/rpc.go#L409-L416 |
132,522 | hashicorp/nomad | helper/pluginutils/catalog/register.go | init | func init() {
RegisterDeferredConfig(rawexec.PluginID, rawexec.PluginConfig, rawexec.PluginLoader)
Register(exec.PluginID, exec.PluginConfig)
Register(qemu.PluginID, qemu.PluginConfig)
Register(java.PluginID, java.PluginConfig)
RegisterDeferredConfig(docker.PluginID, docker.PluginConfig, docker.PluginLoader)
} | go | func init() {
RegisterDeferredConfig(rawexec.PluginID, rawexec.PluginConfig, rawexec.PluginLoader)
Register(exec.PluginID, exec.PluginConfig)
Register(qemu.PluginID, qemu.PluginConfig)
Register(java.PluginID, java.PluginConfig)
RegisterDeferredConfig(docker.PluginID, docker.PluginConfig, docker.PluginLoader)
} | [
"func",
"init",
"(",
")",
"{",
"RegisterDeferredConfig",
"(",
"rawexec",
".",
"PluginID",
",",
"rawexec",
".",
"PluginConfig",
",",
"rawexec",
".",
"PluginLoader",
")",
"\n",
"Register",
"(",
"exec",
".",
"PluginID",
",",
"exec",
".",
"PluginConfig",
")",
... | // This file is where all builtin plugins should be registered in the catalog.
// Plugins with build restrictions should be placed in the appropriate
// register_XXX.go file. | [
"This",
"file",
"is",
"where",
"all",
"builtin",
"plugins",
"should",
"be",
"registered",
"in",
"the",
"catalog",
".",
"Plugins",
"with",
"build",
"restrictions",
"should",
"be",
"placed",
"in",
"the",
"appropriate",
"register_XXX",
".",
"go",
"file",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/catalog/register.go#L14-L20 |
132,523 | hashicorp/nomad | command/agent/consul/structs.go | Copy | func (t *TaskServices) Copy() *TaskServices {
newTS := new(TaskServices)
*newTS = *t
// Deep copy Services
newTS.Services = make([]*structs.Service, len(t.Services))
for i := range t.Services {
newTS.Services[i] = t.Services[i].Copy()
}
return newTS
} | go | func (t *TaskServices) Copy() *TaskServices {
newTS := new(TaskServices)
*newTS = *t
// Deep copy Services
newTS.Services = make([]*structs.Service, len(t.Services))
for i := range t.Services {
newTS.Services[i] = t.Services[i].Copy()
}
return newTS
} | [
"func",
"(",
"t",
"*",
"TaskServices",
")",
"Copy",
"(",
")",
"*",
"TaskServices",
"{",
"newTS",
":=",
"new",
"(",
"TaskServices",
")",
"\n",
"*",
"newTS",
"=",
"*",
"t",
"\n\n",
"// Deep copy Services",
"newTS",
".",
"Services",
"=",
"make",
"(",
"[",... | // Copy method for easing tests | [
"Copy",
"method",
"for",
"easing",
"tests"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/agent/consul/structs.go#L62-L72 |
132,524 | hashicorp/nomad | e2e/cli/command/util.go | fetchBinary | func fetchBinary(bin string) (string, error) {
nomadBinaryDir, err := ioutil.TempDir("", "")
if err != nil {
return "", fmt.Errorf("failed to create temp dir: %v", err)
}
if bin == "" {
bin, err = discover.NomadExecutable()
if err != nil {
return "", fmt.Errorf("failed to discover nomad binary: %v", err)
... | go | func fetchBinary(bin string) (string, error) {
nomadBinaryDir, err := ioutil.TempDir("", "")
if err != nil {
return "", fmt.Errorf("failed to create temp dir: %v", err)
}
if bin == "" {
bin, err = discover.NomadExecutable()
if err != nil {
return "", fmt.Errorf("failed to discover nomad binary: %v", err)
... | [
"func",
"fetchBinary",
"(",
"bin",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"nomadBinaryDir",
",",
"err",
":=",
"ioutil",
".",
"TempDir",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",... | // fetchBinary fetches the nomad binary and returns the temporary directory where it exists | [
"fetchBinary",
"fetches",
"the",
"nomad",
"binary",
"and",
"returns",
"the",
"temporary",
"directory",
"where",
"it",
"exists"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/e2e/cli/command/util.go#L16-L39 |
132,525 | hashicorp/nomad | nomad/plan_endpoint.go | Submit | func (p *Plan) Submit(args *structs.PlanRequest, reply *structs.PlanResponse) error {
if done, err := p.srv.forward("Plan.Submit", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "plan", "submit"}, time.Now())
// Pause the Nack timer for the eval as it is making progress as l... | go | func (p *Plan) Submit(args *structs.PlanRequest, reply *structs.PlanResponse) error {
if done, err := p.srv.forward("Plan.Submit", args, args, reply); done {
return err
}
defer metrics.MeasureSince([]string{"nomad", "plan", "submit"}, time.Now())
// Pause the Nack timer for the eval as it is making progress as l... | [
"func",
"(",
"p",
"*",
"Plan",
")",
"Submit",
"(",
"args",
"*",
"structs",
".",
"PlanRequest",
",",
"reply",
"*",
"structs",
".",
"PlanResponse",
")",
"error",
"{",
"if",
"done",
",",
"err",
":=",
"p",
".",
"srv",
".",
"forward",
"(",
"\"",
"\"",
... | // Submit is used to submit a plan to the leader | [
"Submit",
"is",
"used",
"to",
"submit",
"a",
"plan",
"to",
"the",
"leader"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/plan_endpoint.go#L19-L52 |
132,526 | hashicorp/nomad | client/acl.go | init | func (c *clientACLResolver) init() error {
// Create the ACL object cache
var err error
c.aclCache, err = lru.New2Q(aclCacheSize)
if err != nil {
return err
}
c.policyCache, err = lru.New2Q(policyCacheSize)
if err != nil {
return err
}
c.tokenCache, err = lru.New2Q(tokenCacheSize)
if err != nil {
return... | go | func (c *clientACLResolver) init() error {
// Create the ACL object cache
var err error
c.aclCache, err = lru.New2Q(aclCacheSize)
if err != nil {
return err
}
c.policyCache, err = lru.New2Q(policyCacheSize)
if err != nil {
return err
}
c.tokenCache, err = lru.New2Q(tokenCacheSize)
if err != nil {
return... | [
"func",
"(",
"c",
"*",
"clientACLResolver",
")",
"init",
"(",
")",
"error",
"{",
"// Create the ACL object cache",
"var",
"err",
"error",
"\n",
"c",
".",
"aclCache",
",",
"err",
"=",
"lru",
".",
"New2Q",
"(",
"aclCacheSize",
")",
"\n",
"if",
"err",
"!=",... | // init is used to setup the client resolver state | [
"init",
"is",
"used",
"to",
"setup",
"the",
"client",
"resolver",
"state"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/acl.go#L40-L56 |
132,527 | hashicorp/nomad | client/acl.go | resolveTokenValue | func (c *Client) resolveTokenValue(secretID string) (*structs.ACLToken, error) {
// Hot-path the anonymous token
if secretID == "" {
return structs.AnonymousACLToken, nil
}
// Lookup the token in the cache
raw, ok := c.tokenCache.Get(secretID)
if ok {
cached := raw.(*cachedACLValue)
if cached.Age() <= c.co... | go | func (c *Client) resolveTokenValue(secretID string) (*structs.ACLToken, error) {
// Hot-path the anonymous token
if secretID == "" {
return structs.AnonymousACLToken, nil
}
// Lookup the token in the cache
raw, ok := c.tokenCache.Get(secretID)
if ok {
cached := raw.(*cachedACLValue)
if cached.Age() <= c.co... | [
"func",
"(",
"c",
"*",
"Client",
")",
"resolveTokenValue",
"(",
"secretID",
"string",
")",
"(",
"*",
"structs",
".",
"ACLToken",
",",
"error",
")",
"{",
"// Hot-path the anonymous token",
"if",
"secretID",
"==",
"\"",
"\"",
"{",
"return",
"structs",
".",
"... | // resolveTokenValue is used to translate a secret ID into an ACL token with caching
// We use a local cache up to the TTL limit, and then resolve via a server. If we cannot
// reach a server, but have a cached value we extend the TTL to gracefully handle outages. | [
"resolveTokenValue",
"is",
"used",
"to",
"translate",
"a",
"secret",
"ID",
"into",
"an",
"ACL",
"token",
"with",
"caching",
"We",
"use",
"a",
"local",
"cache",
"up",
"to",
"the",
"TTL",
"limit",
"and",
"then",
"resolve",
"via",
"a",
"server",
".",
"If",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/acl.go#L110-L150 |
132,528 | hashicorp/nomad | client/acl.go | resolvePolicies | func (c *Client) resolvePolicies(secretID string, policies []string) ([]*structs.ACLPolicy, error) {
var out []*structs.ACLPolicy
var expired []*structs.ACLPolicy
var missing []string
// Scan the cache for each policy
for _, policyName := range policies {
// Lookup the policy in the cache
raw, ok := c.policyC... | go | func (c *Client) resolvePolicies(secretID string, policies []string) ([]*structs.ACLPolicy, error) {
var out []*structs.ACLPolicy
var expired []*structs.ACLPolicy
var missing []string
// Scan the cache for each policy
for _, policyName := range policies {
// Lookup the policy in the cache
raw, ok := c.policyC... | [
"func",
"(",
"c",
"*",
"Client",
")",
"resolvePolicies",
"(",
"secretID",
"string",
",",
"policies",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"*",
"structs",
".",
"ACLPolicy",
",",
"error",
")",
"{",
"var",
"out",
"[",
"]",
"*",
"structs",
".",
"ACL... | // resolvePolicies is used to translate a set of named ACL policies into the objects.
// We cache the policies locally, and fault them from a server as necessary. Policies
// are cached for a TTL, and then refreshed. If a server cannot be reached, the cache TTL
// will be ignored to gracefully handle outages. | [
"resolvePolicies",
"is",
"used",
"to",
"translate",
"a",
"set",
"of",
"named",
"ACL",
"policies",
"into",
"the",
"objects",
".",
"We",
"cache",
"the",
"policies",
"locally",
"and",
"fault",
"them",
"from",
"a",
"server",
"as",
"necessary",
".",
"Policies",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/acl.go#L156-L219 |
132,529 | hashicorp/nomad | client/allocrunner/taskrunner/template_hook.go | Update | func (h *templateHook) Update(ctx context.Context, req *interfaces.TaskUpdateRequest, resp *interfaces.TaskUpdateResponse) error {
h.managerLock.Lock()
defer h.managerLock.Unlock()
// Nothing to do
if h.templateManager == nil {
return nil
}
// Check if the Vault token has changed
if req.VaultToken == h.vault... | go | func (h *templateHook) Update(ctx context.Context, req *interfaces.TaskUpdateRequest, resp *interfaces.TaskUpdateResponse) error {
h.managerLock.Lock()
defer h.managerLock.Unlock()
// Nothing to do
if h.templateManager == nil {
return nil
}
// Check if the Vault token has changed
if req.VaultToken == h.vault... | [
"func",
"(",
"h",
"*",
"templateHook",
")",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"interfaces",
".",
"TaskUpdateRequest",
",",
"resp",
"*",
"interfaces",
".",
"TaskUpdateResponse",
")",
"error",
"{",
"h",
".",
"managerLock",
"."... | // Handle new Vault token | [
"Handle",
"new",
"Vault",
"token"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocrunner/taskrunner/template_hook.go#L127-L158 |
132,530 | hashicorp/nomad | plugins/device/mock.go | StaticFingerprinter | func StaticFingerprinter(devices []*DeviceGroup) FingerprintFn {
return func(_ context.Context) (<-chan *FingerprintResponse, error) {
outCh := make(chan *FingerprintResponse, 1)
outCh <- &FingerprintResponse{
Devices: devices,
}
return outCh, nil
}
} | go | func StaticFingerprinter(devices []*DeviceGroup) FingerprintFn {
return func(_ context.Context) (<-chan *FingerprintResponse, error) {
outCh := make(chan *FingerprintResponse, 1)
outCh <- &FingerprintResponse{
Devices: devices,
}
return outCh, nil
}
} | [
"func",
"StaticFingerprinter",
"(",
"devices",
"[",
"]",
"*",
"DeviceGroup",
")",
"FingerprintFn",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
")",
"(",
"<-",
"chan",
"*",
"FingerprintResponse",
",",
"error",
")",
"{",
"outCh",
":=",
"make"... | // Below are static implementations of the device functions
// StaticFingerprinter fingerprints the passed devices just once | [
"Below",
"are",
"static",
"implementations",
"of",
"the",
"device",
"functions",
"StaticFingerprinter",
"fingerprints",
"the",
"passed",
"devices",
"just",
"once"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/mock.go#L39-L47 |
132,531 | hashicorp/nomad | plugins/device/mock.go | ErrorChFingerprinter | func ErrorChFingerprinter(err error) FingerprintFn {
return func(_ context.Context) (<-chan *FingerprintResponse, error) {
outCh := make(chan *FingerprintResponse, 1)
outCh <- &FingerprintResponse{
Error: err,
}
return outCh, nil
}
} | go | func ErrorChFingerprinter(err error) FingerprintFn {
return func(_ context.Context) (<-chan *FingerprintResponse, error) {
outCh := make(chan *FingerprintResponse, 1)
outCh <- &FingerprintResponse{
Error: err,
}
return outCh, nil
}
} | [
"func",
"ErrorChFingerprinter",
"(",
"err",
"error",
")",
"FingerprintFn",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
")",
"(",
"<-",
"chan",
"*",
"FingerprintResponse",
",",
"error",
")",
"{",
"outCh",
":=",
"make",
"(",
"chan",
"*",
"F... | // ErrorChFingerprinter returns an error fingerprinting over the channel | [
"ErrorChFingerprinter",
"returns",
"an",
"error",
"fingerprinting",
"over",
"the",
"channel"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/mock.go#L50-L58 |
132,532 | hashicorp/nomad | plugins/device/mock.go | StaticReserve | func StaticReserve(out *ContainerReservation) ReserveFn {
return func(_ []string) (*ContainerReservation, error) {
return out, nil
}
} | go | func StaticReserve(out *ContainerReservation) ReserveFn {
return func(_ []string) (*ContainerReservation, error) {
return out, nil
}
} | [
"func",
"StaticReserve",
"(",
"out",
"*",
"ContainerReservation",
")",
"ReserveFn",
"{",
"return",
"func",
"(",
"_",
"[",
"]",
"string",
")",
"(",
"*",
"ContainerReservation",
",",
"error",
")",
"{",
"return",
"out",
",",
"nil",
"\n",
"}",
"\n",
"}"
] | // StaticReserve returns the passed container reservation | [
"StaticReserve",
"returns",
"the",
"passed",
"container",
"reservation"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/mock.go#L61-L65 |
132,533 | hashicorp/nomad | plugins/device/mock.go | ErrorReserve | func ErrorReserve(err error) ReserveFn {
return func(_ []string) (*ContainerReservation, error) {
return nil, err
}
} | go | func ErrorReserve(err error) ReserveFn {
return func(_ []string) (*ContainerReservation, error) {
return nil, err
}
} | [
"func",
"ErrorReserve",
"(",
"err",
"error",
")",
"ReserveFn",
"{",
"return",
"func",
"(",
"_",
"[",
"]",
"string",
")",
"(",
"*",
"ContainerReservation",
",",
"error",
")",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}"
] | // ErrorReserve returns the passed error | [
"ErrorReserve",
"returns",
"the",
"passed",
"error"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/mock.go#L68-L72 |
132,534 | hashicorp/nomad | plugins/device/mock.go | StaticStats | func StaticStats(out []*DeviceGroupStats) StatsFn {
return func(ctx context.Context, intv time.Duration) (<-chan *StatsResponse, error) {
outCh := make(chan *StatsResponse, 1)
go func() {
ticker := time.NewTimer(0)
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
ticker.Reset(... | go | func StaticStats(out []*DeviceGroupStats) StatsFn {
return func(ctx context.Context, intv time.Duration) (<-chan *StatsResponse, error) {
outCh := make(chan *StatsResponse, 1)
go func() {
ticker := time.NewTimer(0)
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
ticker.Reset(... | [
"func",
"StaticStats",
"(",
"out",
"[",
"]",
"*",
"DeviceGroupStats",
")",
"StatsFn",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"intv",
"time",
".",
"Duration",
")",
"(",
"<-",
"chan",
"*",
"StatsResponse",
",",
"error",
")",
"... | // StaticStats returns the passed statistics | [
"StaticStats",
"returns",
"the",
"passed",
"statistics"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/mock.go#L75-L97 |
132,535 | hashicorp/nomad | plugins/device/mock.go | ErrorChStats | func ErrorChStats(err error) StatsFn {
return func(_ context.Context, _ time.Duration) (<-chan *StatsResponse, error) {
outCh := make(chan *StatsResponse, 1)
outCh <- &StatsResponse{
Error: err,
}
return outCh, nil
}
} | go | func ErrorChStats(err error) StatsFn {
return func(_ context.Context, _ time.Duration) (<-chan *StatsResponse, error) {
outCh := make(chan *StatsResponse, 1)
outCh <- &StatsResponse{
Error: err,
}
return outCh, nil
}
} | [
"func",
"ErrorChStats",
"(",
"err",
"error",
")",
"StatsFn",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"time",
".",
"Duration",
")",
"(",
"<-",
"chan",
"*",
"StatsResponse",
",",
"error",
")",
"{",
"outCh",
":=",
"make",
"... | // ErrorChStats returns an error collecting stats over the channel | [
"ErrorChStats",
"returns",
"an",
"error",
"collecting",
"stats",
"over",
"the",
"channel"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/plugins/device/mock.go#L100-L108 |
132,536 | hashicorp/nomad | drivers/rkt/driver.go | setFingerprintSuccess | func (d *Driver) setFingerprintSuccess() {
d.fingerprintLock.Lock()
d.fingerprintSuccess = helper.BoolToPtr(true)
d.fingerprintLock.Unlock()
} | go | func (d *Driver) setFingerprintSuccess() {
d.fingerprintLock.Lock()
d.fingerprintSuccess = helper.BoolToPtr(true)
d.fingerprintLock.Unlock()
} | [
"func",
"(",
"d",
"*",
"Driver",
")",
"setFingerprintSuccess",
"(",
")",
"{",
"d",
".",
"fingerprintLock",
".",
"Lock",
"(",
")",
"\n",
"d",
".",
"fingerprintSuccess",
"=",
"helper",
".",
"BoolToPtr",
"(",
"true",
")",
"\n",
"d",
".",
"fingerprintLock",
... | // setFingerprintSuccess marks the driver as having fingerprinted successfully | [
"setFingerprintSuccess",
"marks",
"the",
"driver",
"as",
"having",
"fingerprinted",
"successfully"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/rkt/driver.go#L271-L275 |
132,537 | hashicorp/nomad | drivers/rkt/driver.go | setFingerprintFailure | func (d *Driver) setFingerprintFailure() {
d.fingerprintLock.Lock()
d.fingerprintSuccess = helper.BoolToPtr(false)
d.fingerprintLock.Unlock()
} | go | func (d *Driver) setFingerprintFailure() {
d.fingerprintLock.Lock()
d.fingerprintSuccess = helper.BoolToPtr(false)
d.fingerprintLock.Unlock()
} | [
"func",
"(",
"d",
"*",
"Driver",
")",
"setFingerprintFailure",
"(",
")",
"{",
"d",
".",
"fingerprintLock",
".",
"Lock",
"(",
")",
"\n",
"d",
".",
"fingerprintSuccess",
"=",
"helper",
".",
"BoolToPtr",
"(",
"false",
")",
"\n",
"d",
".",
"fingerprintLock",... | // setFingerprintFailure marks the driver as having failed fingerprinting | [
"setFingerprintFailure",
"marks",
"the",
"driver",
"as",
"having",
"failed",
"fingerprinting"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/rkt/driver.go#L278-L282 |
132,538 | hashicorp/nomad | drivers/rkt/driver.go | fingerprintSuccessful | func (d *Driver) fingerprintSuccessful() bool {
d.fingerprintLock.Lock()
defer d.fingerprintLock.Unlock()
return d.fingerprintSuccess == nil || *d.fingerprintSuccess
} | go | func (d *Driver) fingerprintSuccessful() bool {
d.fingerprintLock.Lock()
defer d.fingerprintLock.Unlock()
return d.fingerprintSuccess == nil || *d.fingerprintSuccess
} | [
"func",
"(",
"d",
"*",
"Driver",
")",
"fingerprintSuccessful",
"(",
")",
"bool",
"{",
"d",
".",
"fingerprintLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"fingerprintLock",
".",
"Unlock",
"(",
")",
"\n",
"return",
"d",
".",
"fingerprintSuccess",... | // fingerprintSuccessful returns true if the driver has
// never fingerprinted or has successfully fingerprinted | [
"fingerprintSuccessful",
"returns",
"true",
"if",
"the",
"driver",
"has",
"never",
"fingerprinted",
"or",
"has",
"successfully",
"fingerprinted"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/rkt/driver.go#L286-L290 |
132,539 | hashicorp/nomad | drivers/rkt/driver.go | rktGetStatus | func rktGetStatus(uuid string, logger hclog.Logger) (*Pod, error) {
statusArgs := []string{
"status",
"--format=json",
uuid,
}
var outBuf, errBuf bytes.Buffer
cmd := exec.Command(rktCmd, statusArgs...)
cmd.Stdout = &outBuf
cmd.Stderr = &errBuf
if err := cmd.Run(); err != nil {
if outBuf.Len() > 0 {
lo... | go | func rktGetStatus(uuid string, logger hclog.Logger) (*Pod, error) {
statusArgs := []string{
"status",
"--format=json",
uuid,
}
var outBuf, errBuf bytes.Buffer
cmd := exec.Command(rktCmd, statusArgs...)
cmd.Stdout = &outBuf
cmd.Stderr = &errBuf
if err := cmd.Run(); err != nil {
if outBuf.Len() > 0 {
lo... | [
"func",
"rktGetStatus",
"(",
"uuid",
"string",
",",
"logger",
"hclog",
".",
"Logger",
")",
"(",
"*",
"Pod",
",",
"error",
")",
"{",
"statusArgs",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"uuid",
",",
"}",
"\n",
"var",
"out... | // Retrieve pod status for the pod with the given UUID. | [
"Retrieve",
"pod",
"status",
"for",
"the",
"pod",
"with",
"the",
"given",
"UUID",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/rkt/driver.go#L984-L1009 |
132,540 | hashicorp/nomad | drivers/rkt/driver.go | rktGetManifest | func rktGetManifest(uuid string) (*appcschema.PodManifest, error) {
statusArgs := []string{
"cat-manifest",
uuid,
}
var outBuf bytes.Buffer
cmd := exec.Command(rktCmd, statusArgs...)
cmd.Stdout = &outBuf
cmd.Stderr = ioutil.Discard
if err := cmd.Run(); err != nil {
return nil, err
}
var manifest appcsche... | go | func rktGetManifest(uuid string) (*appcschema.PodManifest, error) {
statusArgs := []string{
"cat-manifest",
uuid,
}
var outBuf bytes.Buffer
cmd := exec.Command(rktCmd, statusArgs...)
cmd.Stdout = &outBuf
cmd.Stderr = ioutil.Discard
if err := cmd.Run(); err != nil {
return nil, err
}
var manifest appcsche... | [
"func",
"rktGetManifest",
"(",
"uuid",
"string",
")",
"(",
"*",
"appcschema",
".",
"PodManifest",
",",
"error",
")",
"{",
"statusArgs",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"uuid",
",",
"}",
"\n",
"var",
"outBuf",
"bytes",
".",
"Buffer",
"... | // Retrieves a pod manifest | [
"Retrieves",
"a",
"pod",
"manifest"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/rkt/driver.go#L1012-L1029 |
132,541 | hashicorp/nomad | drivers/rkt/driver.go | elideToLen | func elideToLen(inBuf bytes.Buffer, length int) bytes.Buffer {
if inBuf.Len() > length {
inBuf.Truncate(length)
inBuf.WriteString("...")
}
return inBuf
} | go | func elideToLen(inBuf bytes.Buffer, length int) bytes.Buffer {
if inBuf.Len() > length {
inBuf.Truncate(length)
inBuf.WriteString("...")
}
return inBuf
} | [
"func",
"elideToLen",
"(",
"inBuf",
"bytes",
".",
"Buffer",
",",
"length",
"int",
")",
"bytes",
".",
"Buffer",
"{",
"if",
"inBuf",
".",
"Len",
"(",
")",
">",
"length",
"{",
"inBuf",
".",
"Truncate",
"(",
"length",
")",
"\n",
"inBuf",
".",
"WriteStrin... | // Conditionally elide a buffer to an arbitrary length | [
"Conditionally",
"elide",
"a",
"buffer",
"to",
"an",
"arbitrary",
"length"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/rkt/driver.go#L1037-L1043 |
132,542 | hashicorp/nomad | drivers/rkt/driver.go | elide | func elide(inBuf bytes.Buffer) string {
tempBuf := elideToLen(inBuf, 80)
return tempBuf.String()
} | go | func elide(inBuf bytes.Buffer) string {
tempBuf := elideToLen(inBuf, 80)
return tempBuf.String()
} | [
"func",
"elide",
"(",
"inBuf",
"bytes",
".",
"Buffer",
")",
"string",
"{",
"tempBuf",
":=",
"elideToLen",
"(",
"inBuf",
",",
"80",
")",
"\n",
"return",
"tempBuf",
".",
"String",
"(",
")",
"\n",
"}"
] | // Conditionally elide a buffer to an 80 character string | [
"Conditionally",
"elide",
"a",
"buffer",
"to",
"an",
"80",
"character",
"string"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/rkt/driver.go#L1046-L1049 |
132,543 | hashicorp/nomad | e2e/execagent/execagent.go | Stop | func (n *NomadAgent) Stop() error {
if err := n.Cmd.Process.Signal(os.Interrupt); err != nil {
return err
}
return n.Cmd.Wait()
} | go | func (n *NomadAgent) Stop() error {
if err := n.Cmd.Process.Signal(os.Interrupt); err != nil {
return err
}
return n.Cmd.Wait()
} | [
"func",
"(",
"n",
"*",
"NomadAgent",
")",
"Stop",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"n",
".",
"Cmd",
".",
"Process",
".",
"Signal",
"(",
"os",
".",
"Interrupt",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"re... | // Stop sends an interrupt signal and returns the command's Wait error. | [
"Stop",
"sends",
"an",
"interrupt",
"signal",
"and",
"returns",
"the",
"command",
"s",
"Wait",
"error",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/e2e/execagent/execagent.go#L229-L235 |
132,544 | hashicorp/nomad | e2e/execagent/execagent.go | Destroy | func (n *NomadAgent) Destroy() error {
if err := n.Stop(); err != nil {
return err
}
return os.RemoveAll(n.DataDir)
} | go | func (n *NomadAgent) Destroy() error {
if err := n.Stop(); err != nil {
return err
}
return os.RemoveAll(n.DataDir)
} | [
"func",
"(",
"n",
"*",
"NomadAgent",
")",
"Destroy",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"n",
".",
"Stop",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"os",
".",
"RemoveAll",
"(",
"n",
".",
"DataDi... | // Destroy stops the agent and removes the data dir. | [
"Destroy",
"stops",
"the",
"agent",
"and",
"removes",
"the",
"data",
"dir",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/e2e/execagent/execagent.go#L238-L243 |
132,545 | hashicorp/nomad | e2e/execagent/execagent.go | Client | func (n *NomadAgent) Client() (*api.Client, error) {
conf := api.DefaultConfig()
conf.Address = fmt.Sprintf("http://127.0.0.1:%d", n.Vars.HTTP)
return api.NewClient(conf)
} | go | func (n *NomadAgent) Client() (*api.Client, error) {
conf := api.DefaultConfig()
conf.Address = fmt.Sprintf("http://127.0.0.1:%d", n.Vars.HTTP)
return api.NewClient(conf)
} | [
"func",
"(",
"n",
"*",
"NomadAgent",
")",
"Client",
"(",
")",
"(",
"*",
"api",
".",
"Client",
",",
"error",
")",
"{",
"conf",
":=",
"api",
".",
"DefaultConfig",
"(",
")",
"\n",
"conf",
".",
"Address",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
... | // Client returns an api.Client for the agent. | [
"Client",
"returns",
"an",
"api",
".",
"Client",
"for",
"the",
"agent",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/e2e/execagent/execagent.go#L246-L250 |
132,546 | hashicorp/nomad | nomad/system_endpoint.go | GarbageCollect | func (s *System) GarbageCollect(args *structs.GenericRequest, reply *structs.GenericResponse) error {
if done, err := s.srv.forward("System.GarbageCollect", args, args, reply); done {
return err
}
// Check management level permissions
if acl, err := s.srv.ResolveToken(args.AuthToken); err != nil {
return err
... | go | func (s *System) GarbageCollect(args *structs.GenericRequest, reply *structs.GenericResponse) error {
if done, err := s.srv.forward("System.GarbageCollect", args, args, reply); done {
return err
}
// Check management level permissions
if acl, err := s.srv.ResolveToken(args.AuthToken); err != nil {
return err
... | [
"func",
"(",
"s",
"*",
"System",
")",
"GarbageCollect",
"(",
"args",
"*",
"structs",
".",
"GenericRequest",
",",
"reply",
"*",
"structs",
".",
"GenericResponse",
")",
"error",
"{",
"if",
"done",
",",
"err",
":=",
"s",
".",
"srv",
".",
"forward",
"(",
... | // GarbageCollect is used to trigger the system to immediately garbage collect nodes, evals
// and jobs. | [
"GarbageCollect",
"is",
"used",
"to",
"trigger",
"the",
"system",
"to",
"immediately",
"garbage",
"collect",
"nodes",
"evals",
"and",
"jobs",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/system_endpoint.go#L19-L39 |
132,547 | hashicorp/nomad | nomad/system_endpoint.go | ReconcileJobSummaries | func (s *System) ReconcileJobSummaries(args *structs.GenericRequest, reply *structs.GenericResponse) error {
if done, err := s.srv.forward("System.ReconcileJobSummaries", args, args, reply); done {
return err
}
// Check management level permissions
if acl, err := s.srv.ResolveToken(args.AuthToken); err != nil {
... | go | func (s *System) ReconcileJobSummaries(args *structs.GenericRequest, reply *structs.GenericResponse) error {
if done, err := s.srv.forward("System.ReconcileJobSummaries", args, args, reply); done {
return err
}
// Check management level permissions
if acl, err := s.srv.ResolveToken(args.AuthToken); err != nil {
... | [
"func",
"(",
"s",
"*",
"System",
")",
"ReconcileJobSummaries",
"(",
"args",
"*",
"structs",
".",
"GenericRequest",
",",
"reply",
"*",
"structs",
".",
"GenericResponse",
")",
"error",
"{",
"if",
"done",
",",
"err",
":=",
"s",
".",
"srv",
".",
"forward",
... | // ReconcileSummaries reconciles the summaries of all the jobs in the state
// store | [
"ReconcileSummaries",
"reconciles",
"the",
"summaries",
"of",
"all",
"the",
"jobs",
"in",
"the",
"state",
"store"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/system_endpoint.go#L43-L61 |
132,548 | hashicorp/nomad | command/commands.go | Run | func (c *DeprecatedCommand) Run(args []string) int {
c.warn()
return c.Command.Run(args)
} | go | func (c *DeprecatedCommand) Run(args []string) int {
c.warn()
return c.Command.Run(args)
} | [
"func",
"(",
"c",
"*",
"DeprecatedCommand",
")",
"Run",
"(",
"args",
"[",
"]",
"string",
")",
"int",
"{",
"c",
".",
"warn",
"(",
")",
"\n",
"return",
"c",
".",
"Command",
".",
"Run",
"(",
"args",
")",
"\n",
"}"
] | // Run wraps the embedded Run command and prints a warning about deprecation. | [
"Run",
"wraps",
"the",
"embedded",
"Run",
"command",
"and",
"prints",
"a",
"warning",
"about",
"deprecation",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/commands.go#L37-L40 |
132,549 | hashicorp/nomad | jobspec/parse.go | Parse | func Parse(r io.Reader) (*api.Job, error) {
// Copy the reader into an in-memory buffer first since HCL requires it.
var buf bytes.Buffer
if _, err := io.Copy(&buf, r); err != nil {
return nil, err
}
// Parse the buffer
root, err := hcl.Parse(buf.String())
if err != nil {
return nil, fmt.Errorf("error parsi... | go | func Parse(r io.Reader) (*api.Job, error) {
// Copy the reader into an in-memory buffer first since HCL requires it.
var buf bytes.Buffer
if _, err := io.Copy(&buf, r); err != nil {
return nil, err
}
// Parse the buffer
root, err := hcl.Parse(buf.String())
if err != nil {
return nil, fmt.Errorf("error parsi... | [
"func",
"Parse",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"*",
"api",
".",
"Job",
",",
"error",
")",
"{",
"// Copy the reader into an in-memory buffer first since HCL requires it.",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"if",
"_",
",",
"err",
":=",
"io... | // Parse parses the job spec from the given io.Reader.
//
// Due to current internal limitations, the entire contents of the
// io.Reader will be copied into memory first before parsing. | [
"Parse",
"parses",
"the",
"job",
"spec",
"from",
"the",
"given",
"io",
".",
"Reader",
".",
"Due",
"to",
"current",
"internal",
"limitations",
"the",
"entire",
"contents",
"of",
"the",
"io",
".",
"Reader",
"will",
"be",
"copied",
"into",
"memory",
"first",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/jobspec/parse.go#L30-L70 |
132,550 | hashicorp/nomad | jobspec/parse.go | ParseFile | func ParseFile(path string) (*api.Job, error) {
path, err := filepath.Abs(path)
if err != nil {
return nil, err
}
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
return Parse(f)
} | go | func ParseFile(path string) (*api.Job, error) {
path, err := filepath.Abs(path)
if err != nil {
return nil, err
}
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
return Parse(f)
} | [
"func",
"ParseFile",
"(",
"path",
"string",
")",
"(",
"*",
"api",
".",
"Job",
",",
"error",
")",
"{",
"path",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}... | // ParseFile parses the given path as a job spec. | [
"ParseFile",
"parses",
"the",
"given",
"path",
"as",
"a",
"job",
"spec",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/jobspec/parse.go#L73-L86 |
132,551 | hashicorp/nomad | jobspec/parse.go | parseBool | func parseBool(value interface{}) (bool, error) {
var enabled bool
var err error
switch value.(type) {
case string:
enabled, err = strconv.ParseBool(value.(string))
case bool:
enabled = value.(bool)
default:
err = fmt.Errorf("%v couldn't be converted to boolean value", value)
}
return enabled, err
} | go | func parseBool(value interface{}) (bool, error) {
var enabled bool
var err error
switch value.(type) {
case string:
enabled, err = strconv.ParseBool(value.(string))
case bool:
enabled = value.(bool)
default:
err = fmt.Errorf("%v couldn't be converted to boolean value", value)
}
return enabled, err
} | [
"func",
"parseBool",
"(",
"value",
"interface",
"{",
"}",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"enabled",
"bool",
"\n",
"var",
"err",
"error",
"\n",
"switch",
"value",
".",
"(",
"type",
")",
"{",
"case",
"string",
":",
"enabled",
",",
"... | // parseBool takes an interface value and tries to convert it to a boolean and
// returns an error if the type can't be converted. | [
"parseBool",
"takes",
"an",
"interface",
"value",
"and",
"tries",
"to",
"convert",
"it",
"to",
"a",
"boolean",
"and",
"returns",
"an",
"error",
"if",
"the",
"type",
"can",
"t",
"be",
"converted",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/jobspec/parse.go#L817-L830 |
132,552 | hashicorp/nomad | drivers/shared/executor/utils.go | CreateExecutor | func CreateExecutor(logger hclog.Logger, driverConfig *base.ClientDriverConfig,
executorConfig *ExecutorConfig) (Executor, *plugin.Client, error) {
c, err := json.Marshal(executorConfig)
if err != nil {
return nil, nil, fmt.Errorf("unable to create executor config: %v", err)
}
bin, err := discover.NomadExecutab... | go | func CreateExecutor(logger hclog.Logger, driverConfig *base.ClientDriverConfig,
executorConfig *ExecutorConfig) (Executor, *plugin.Client, error) {
c, err := json.Marshal(executorConfig)
if err != nil {
return nil, nil, fmt.Errorf("unable to create executor config: %v", err)
}
bin, err := discover.NomadExecutab... | [
"func",
"CreateExecutor",
"(",
"logger",
"hclog",
".",
"Logger",
",",
"driverConfig",
"*",
"base",
".",
"ClientDriverConfig",
",",
"executorConfig",
"*",
"ExecutorConfig",
")",
"(",
"Executor",
",",
"*",
"plugin",
".",
"Client",
",",
"error",
")",
"{",
"c",
... | // CreateExecutor launches an executor plugin and returns an instance of the
// Executor interface | [
"CreateExecutor",
"launches",
"an",
"executor",
"plugin",
"and",
"returns",
"an",
"instance",
"of",
"the",
"Executor",
"interface"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/utils.go#L28-L68 |
132,553 | hashicorp/nomad | drivers/shared/executor/utils.go | ReattachToExecutor | func ReattachToExecutor(reattachConfig *plugin.ReattachConfig, logger hclog.Logger) (Executor, *plugin.Client, error) {
config := &plugin.ClientConfig{
HandshakeConfig: base.Handshake,
Reattach: reattachConfig,
Plugins: GetPluginMap(logger, false),
AllowedProtocols: []plugin.Protocol{plugin.P... | go | func ReattachToExecutor(reattachConfig *plugin.ReattachConfig, logger hclog.Logger) (Executor, *plugin.Client, error) {
config := &plugin.ClientConfig{
HandshakeConfig: base.Handshake,
Reattach: reattachConfig,
Plugins: GetPluginMap(logger, false),
AllowedProtocols: []plugin.Protocol{plugin.P... | [
"func",
"ReattachToExecutor",
"(",
"reattachConfig",
"*",
"plugin",
".",
"ReattachConfig",
",",
"logger",
"hclog",
".",
"Logger",
")",
"(",
"Executor",
",",
"*",
"plugin",
".",
"Client",
",",
"error",
")",
"{",
"config",
":=",
"&",
"plugin",
".",
"ClientCo... | // ReattachToExecutor launches a plugin with a given plugin config | [
"ReattachToExecutor",
"launches",
"a",
"plugin",
"with",
"a",
"given",
"plugin",
"config"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/utils.go#L71-L81 |
132,554 | hashicorp/nomad | drivers/shared/executor/utils.go | ReattachToPre09Executor | func ReattachToPre09Executor(reattachConfig *plugin.ReattachConfig, logger hclog.Logger) (Executor, *plugin.Client, error) {
config := &plugin.ClientConfig{
HandshakeConfig: base.Handshake,
Reattach: reattachConfig,
Plugins: GetPre09PluginMap(logger, false),
AllowedProtocols: []plugin.Protoco... | go | func ReattachToPre09Executor(reattachConfig *plugin.ReattachConfig, logger hclog.Logger) (Executor, *plugin.Client, error) {
config := &plugin.ClientConfig{
HandshakeConfig: base.Handshake,
Reattach: reattachConfig,
Plugins: GetPre09PluginMap(logger, false),
AllowedProtocols: []plugin.Protoco... | [
"func",
"ReattachToPre09Executor",
"(",
"reattachConfig",
"*",
"plugin",
".",
"ReattachConfig",
",",
"logger",
"hclog",
".",
"Logger",
")",
"(",
"Executor",
",",
"*",
"plugin",
".",
"Client",
",",
"error",
")",
"{",
"config",
":=",
"&",
"plugin",
".",
"Cli... | // ReattachToPre09Executor creates a plugin client that reattaches to an existing
// pre 0.9 Nomad executor | [
"ReattachToPre09Executor",
"creates",
"a",
"plugin",
"client",
"that",
"reattaches",
"to",
"an",
"existing",
"pre",
"0",
".",
"9",
"Nomad",
"executor"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/drivers/shared/executor/utils.go#L85-L94 |
132,555 | hashicorp/nomad | nomad/drainer/drain_heap.go | NewDeadlineHeap | func NewDeadlineHeap(ctx context.Context, coalesceWindow time.Duration) *deadlineHeap {
d := &deadlineHeap{
ctx: ctx,
coalesceWindow: coalesceWindow,
batch: make(chan []string),
nodes: make(map[string]time.Time, 64),
trigger: make(chan struct{}, 1),
}
go d.watch()
retu... | go | func NewDeadlineHeap(ctx context.Context, coalesceWindow time.Duration) *deadlineHeap {
d := &deadlineHeap{
ctx: ctx,
coalesceWindow: coalesceWindow,
batch: make(chan []string),
nodes: make(map[string]time.Time, 64),
trigger: make(chan struct{}, 1),
}
go d.watch()
retu... | [
"func",
"NewDeadlineHeap",
"(",
"ctx",
"context",
".",
"Context",
",",
"coalesceWindow",
"time",
".",
"Duration",
")",
"*",
"deadlineHeap",
"{",
"d",
":=",
"&",
"deadlineHeap",
"{",
"ctx",
":",
"ctx",
",",
"coalesceWindow",
":",
"coalesceWindow",
",",
"batch... | // NewDeadlineHeap returns a new deadline heap that coalesces for the given
// duration and will stop watching when the passed context is cancelled. | [
"NewDeadlineHeap",
"returns",
"a",
"new",
"deadline",
"heap",
"that",
"coalesces",
"for",
"the",
"given",
"duration",
"and",
"will",
"stop",
"watching",
"when",
"the",
"passed",
"context",
"is",
"cancelled",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/drain_heap.go#L37-L48 |
132,556 | hashicorp/nomad | nomad/drainer/drain_heap.go | calculateNextDeadline | func (d *deadlineHeap) calculateNextDeadline() (time.Time, bool) {
d.mu.Lock()
defer d.mu.Unlock()
if len(d.nodes) == 0 {
return time.Time{}, false
}
// Calculate the new timer value
var deadline time.Time
for _, v := range d.nodes {
if deadline.IsZero() || v.Before(deadline) {
deadline = v
}
}
var... | go | func (d *deadlineHeap) calculateNextDeadline() (time.Time, bool) {
d.mu.Lock()
defer d.mu.Unlock()
if len(d.nodes) == 0 {
return time.Time{}, false
}
// Calculate the new timer value
var deadline time.Time
for _, v := range d.nodes {
if deadline.IsZero() || v.Before(deadline) {
deadline = v
}
}
var... | [
"func",
"(",
"d",
"*",
"deadlineHeap",
")",
"calculateNextDeadline",
"(",
")",
"(",
"time",
".",
"Time",
",",
"bool",
")",
"{",
"d",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"len",
... | // calculateNextDeadline returns the next deadline in which to scan for
// deadlined nodes. It applies the coalesce window. | [
"calculateNextDeadline",
"returns",
"the",
"next",
"deadline",
"in",
"which",
"to",
"scan",
"for",
"deadlined",
"nodes",
".",
"It",
"applies",
"the",
"coalesce",
"window",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/drainer/drain_heap.go#L106-L133 |
132,557 | hashicorp/nomad | helper/pluginutils/singleton/singleton.go | NewSingletonLoader | func NewSingletonLoader(logger log.Logger, catalog loader.PluginCatalog) *SingletonLoader {
return &SingletonLoader{
loader: catalog,
logger: logger.Named("singleton_plugin_loader"),
instances: make(map[loader.PluginID]*future, 4),
}
} | go | func NewSingletonLoader(logger log.Logger, catalog loader.PluginCatalog) *SingletonLoader {
return &SingletonLoader{
loader: catalog,
logger: logger.Named("singleton_plugin_loader"),
instances: make(map[loader.PluginID]*future, 4),
}
} | [
"func",
"NewSingletonLoader",
"(",
"logger",
"log",
".",
"Logger",
",",
"catalog",
"loader",
".",
"PluginCatalog",
")",
"*",
"SingletonLoader",
"{",
"return",
"&",
"SingletonLoader",
"{",
"loader",
":",
"catalog",
",",
"logger",
":",
"logger",
".",
"Named",
... | // NewSingletonLoader wraps a plugin catalog and provides singleton behavior on
// top by caching running instances. | [
"NewSingletonLoader",
"wraps",
"a",
"plugin",
"catalog",
"and",
"provides",
"singleton",
"behavior",
"on",
"top",
"by",
"caching",
"running",
"instances",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/singleton/singleton.go#L37-L43 |
132,558 | hashicorp/nomad | helper/pluginutils/singleton/singleton.go | Dispense | func (s *SingletonLoader) Dispense(name, pluginType string, config *base.AgentConfig, logger log.Logger) (loader.PluginInstance, error) {
return s.getPlugin(false, name, pluginType, logger, config, nil)
} | go | func (s *SingletonLoader) Dispense(name, pluginType string, config *base.AgentConfig, logger log.Logger) (loader.PluginInstance, error) {
return s.getPlugin(false, name, pluginType, logger, config, nil)
} | [
"func",
"(",
"s",
"*",
"SingletonLoader",
")",
"Dispense",
"(",
"name",
",",
"pluginType",
"string",
",",
"config",
"*",
"base",
".",
"AgentConfig",
",",
"logger",
"log",
".",
"Logger",
")",
"(",
"loader",
".",
"PluginInstance",
",",
"error",
")",
"{",
... | // Dispense returns the plugin given its name and type. This will also
// configure the plugin. If there is an instance of an already running plugin,
// this is used. | [
"Dispense",
"returns",
"the",
"plugin",
"given",
"its",
"name",
"and",
"type",
".",
"This",
"will",
"also",
"configure",
"the",
"plugin",
".",
"If",
"there",
"is",
"an",
"instance",
"of",
"an",
"already",
"running",
"plugin",
"this",
"is",
"used",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/singleton/singleton.go#L53-L55 |
132,559 | hashicorp/nomad | helper/pluginutils/singleton/singleton.go | Reattach | func (s *SingletonLoader) Reattach(name, pluginType string, config *plugin.ReattachConfig) (loader.PluginInstance, error) {
return s.getPlugin(true, name, pluginType, nil, nil, config)
} | go | func (s *SingletonLoader) Reattach(name, pluginType string, config *plugin.ReattachConfig) (loader.PluginInstance, error) {
return s.getPlugin(true, name, pluginType, nil, nil, config)
} | [
"func",
"(",
"s",
"*",
"SingletonLoader",
")",
"Reattach",
"(",
"name",
",",
"pluginType",
"string",
",",
"config",
"*",
"plugin",
".",
"ReattachConfig",
")",
"(",
"loader",
".",
"PluginInstance",
",",
"error",
")",
"{",
"return",
"s",
".",
"getPlugin",
... | // Reattach is used to reattach to a previously launched external plugin. | [
"Reattach",
"is",
"used",
"to",
"reattach",
"to",
"a",
"previously",
"launched",
"external",
"plugin",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/singleton/singleton.go#L58-L60 |
132,560 | hashicorp/nomad | helper/pluginutils/singleton/singleton.go | getPlugin | func (s *SingletonLoader) getPlugin(reattach bool, name, pluginType string, logger log.Logger,
nomadConfig *base.AgentConfig, config *plugin.ReattachConfig) (loader.PluginInstance, error) {
// Lock the instance map to prevent races
s.instanceLock.Lock()
// Check if there is a future already
id := loader.PluginID... | go | func (s *SingletonLoader) getPlugin(reattach bool, name, pluginType string, logger log.Logger,
nomadConfig *base.AgentConfig, config *plugin.ReattachConfig) (loader.PluginInstance, error) {
// Lock the instance map to prevent races
s.instanceLock.Lock()
// Check if there is a future already
id := loader.PluginID... | [
"func",
"(",
"s",
"*",
"SingletonLoader",
")",
"getPlugin",
"(",
"reattach",
"bool",
",",
"name",
",",
"pluginType",
"string",
",",
"logger",
"log",
".",
"Logger",
",",
"nomadConfig",
"*",
"base",
".",
"AgentConfig",
",",
"config",
"*",
"plugin",
".",
"R... | // getPlugin is a helper that either dispenses or reattaches to a plugin using
// futures to ensure only a single instance is retrieved | [
"getPlugin",
"is",
"a",
"helper",
"that",
"either",
"dispenses",
"or",
"reattaches",
"to",
"a",
"plugin",
"using",
"futures",
"to",
"ensure",
"only",
"a",
"single",
"instance",
"is",
"retrieved"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/singleton/singleton.go#L64-L101 |
132,561 | hashicorp/nomad | helper/pluginutils/singleton/singleton.go | dispense | func (s *SingletonLoader) dispense(f *future, name, pluginType string, config *base.AgentConfig, logger log.Logger) {
i, err := s.loader.Dispense(name, pluginType, config, logger)
f.set(i, err)
} | go | func (s *SingletonLoader) dispense(f *future, name, pluginType string, config *base.AgentConfig, logger log.Logger) {
i, err := s.loader.Dispense(name, pluginType, config, logger)
f.set(i, err)
} | [
"func",
"(",
"s",
"*",
"SingletonLoader",
")",
"dispense",
"(",
"f",
"*",
"future",
",",
"name",
",",
"pluginType",
"string",
",",
"config",
"*",
"base",
".",
"AgentConfig",
",",
"logger",
"log",
".",
"Logger",
")",
"{",
"i",
",",
"err",
":=",
"s",
... | // dispense should be called in a go routine to not block and creates the
// desired plugin, setting the results in the future. | [
"dispense",
"should",
"be",
"called",
"in",
"a",
"go",
"routine",
"to",
"not",
"block",
"and",
"creates",
"the",
"desired",
"plugin",
"setting",
"the",
"results",
"in",
"the",
"future",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/singleton/singleton.go#L105-L108 |
132,562 | hashicorp/nomad | helper/pluginutils/singleton/singleton.go | reattach | func (s *SingletonLoader) reattach(f *future, name, pluginType string, config *plugin.ReattachConfig) {
i, err := s.loader.Reattach(name, pluginType, config)
f.set(i, err)
} | go | func (s *SingletonLoader) reattach(f *future, name, pluginType string, config *plugin.ReattachConfig) {
i, err := s.loader.Reattach(name, pluginType, config)
f.set(i, err)
} | [
"func",
"(",
"s",
"*",
"SingletonLoader",
")",
"reattach",
"(",
"f",
"*",
"future",
",",
"name",
",",
"pluginType",
"string",
",",
"config",
"*",
"plugin",
".",
"ReattachConfig",
")",
"{",
"i",
",",
"err",
":=",
"s",
".",
"loader",
".",
"Reattach",
"... | // reattach should be called in a go routine to not block and reattaches to the
// desired plugin, setting the results in the future. | [
"reattach",
"should",
"be",
"called",
"in",
"a",
"go",
"routine",
"to",
"not",
"block",
"and",
"reattaches",
"to",
"the",
"desired",
"plugin",
"setting",
"the",
"results",
"in",
"the",
"future",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/singleton/singleton.go#L112-L115 |
132,563 | hashicorp/nomad | helper/pluginutils/singleton/singleton.go | clearFuture | func (s *SingletonLoader) clearFuture(id loader.PluginID, f *future) {
s.instanceLock.Lock()
defer s.instanceLock.Unlock()
if f.equal(s.instances[id]) {
delete(s.instances, id)
}
} | go | func (s *SingletonLoader) clearFuture(id loader.PluginID, f *future) {
s.instanceLock.Lock()
defer s.instanceLock.Unlock()
if f.equal(s.instances[id]) {
delete(s.instances, id)
}
} | [
"func",
"(",
"s",
"*",
"SingletonLoader",
")",
"clearFuture",
"(",
"id",
"loader",
".",
"PluginID",
",",
"f",
"*",
"future",
")",
"{",
"s",
".",
"instanceLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"instanceLock",
".",
"Unlock",
"(",
")",
... | // clearFuture clears the future from the instances map only if the futures
// match. This prevents clearing the unintented instance. | [
"clearFuture",
"clears",
"the",
"future",
"from",
"the",
"instances",
"map",
"only",
"if",
"the",
"futures",
"match",
".",
"This",
"prevents",
"clearing",
"the",
"unintented",
"instance",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/helper/pluginutils/singleton/singleton.go#L119-L125 |
132,564 | hashicorp/nomad | client/allocdir/task_dir_linux.go | unmountSpecialDirs | func (t *TaskDir) unmountSpecialDirs() error {
errs := new(multierror.Error)
dev := filepath.Join(t.Dir, "dev")
if pathExists(dev) {
if err := unlinkDir(dev); err != nil {
errs = multierror.Append(errs, fmt.Errorf("Failed to unmount dev %q: %v", dev, err))
} else if err := os.RemoveAll(dev); err != nil {
e... | go | func (t *TaskDir) unmountSpecialDirs() error {
errs := new(multierror.Error)
dev := filepath.Join(t.Dir, "dev")
if pathExists(dev) {
if err := unlinkDir(dev); err != nil {
errs = multierror.Append(errs, fmt.Errorf("Failed to unmount dev %q: %v", dev, err))
} else if err := os.RemoveAll(dev); err != nil {
e... | [
"func",
"(",
"t",
"*",
"TaskDir",
")",
"unmountSpecialDirs",
"(",
")",
"error",
"{",
"errs",
":=",
"new",
"(",
"multierror",
".",
"Error",
")",
"\n",
"dev",
":=",
"filepath",
".",
"Join",
"(",
"t",
".",
"Dir",
",",
"\"",
"\"",
")",
"\n",
"if",
"p... | // unmountSpecialDirs unmounts the dev and proc file system from the chroot. No
// error is returned if the directories do not exist or have already been
// unmounted. | [
"unmountSpecialDirs",
"unmounts",
"the",
"dev",
"and",
"proc",
"file",
"system",
"from",
"the",
"chroot",
".",
"No",
"error",
"is",
"returned",
"if",
"the",
"directories",
"do",
"not",
"exist",
"or",
"have",
"already",
"been",
"unmounted",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/allocdir/task_dir_linux.go#L14-L36 |
132,565 | hashicorp/nomad | client/devicemanager/manager.go | New | func New(c *Config) *manager {
ctx, cancel := context.WithCancel(context.Background())
return &manager{
logger: c.Logger.Named("device_mgr"),
state: c.State,
ctx: ctx,
cancel: cancel,
loader: c.Loader,
pluginConfig: c.PluginConfig,
updater: ... | go | func New(c *Config) *manager {
ctx, cancel := context.WithCancel(context.Background())
return &manager{
logger: c.Logger.Named("device_mgr"),
state: c.State,
ctx: ctx,
cancel: cancel,
loader: c.Loader,
pluginConfig: c.PluginConfig,
updater: ... | [
"func",
"New",
"(",
"c",
"*",
"Config",
")",
"*",
"manager",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"context",
".",
"Background",
"(",
")",
")",
"\n",
"return",
"&",
"manager",
"{",
"logger",
":",
"c",
".",
"Logger",
".... | // New returns a new device manager | [
"New",
"returns",
"a",
"new",
"device",
"manager"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/manager.go#L111-L125 |
132,566 | hashicorp/nomad | client/devicemanager/manager.go | Run | func (m *manager) Run() {
// Check if there are any plugins that didn't get cleanly shutdown before
// and if there are shut them down.
m.cleanupStalePlugins()
// Get device plugins
devices := m.loader.Catalog()[base.PluginTypeDevice]
if len(devices) == 0 {
m.logger.Debug("exiting since there are no device plu... | go | func (m *manager) Run() {
// Check if there are any plugins that didn't get cleanly shutdown before
// and if there are shut them down.
m.cleanupStalePlugins()
// Get device plugins
devices := m.loader.Catalog()[base.PluginTypeDevice]
if len(devices) == 0 {
m.logger.Debug("exiting since there are no device plu... | [
"func",
"(",
"m",
"*",
"manager",
")",
"Run",
"(",
")",
"{",
"// Check if there are any plugins that didn't get cleanly shutdown before",
"// and if there are shut them down.",
"m",
".",
"cleanupStalePlugins",
"(",
")",
"\n\n",
"// Get device plugins",
"devices",
":=",
"m",... | // Run starts thed device manager. The manager will shutdown any previously
// launched plugin and then begin fingerprinting and stats collection on all new
// device plugins. | [
"Run",
"starts",
"thed",
"device",
"manager",
".",
"The",
"manager",
"will",
"shutdown",
"any",
"previously",
"launched",
"plugin",
"and",
"then",
"begin",
"fingerprinting",
"and",
"stats",
"collection",
"on",
"all",
"new",
"device",
"plugins",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/manager.go#L133-L166 |
132,567 | hashicorp/nomad | client/devicemanager/manager.go | fingerprint | func (m *manager) fingerprint() {
for {
select {
case <-m.ctx.Done():
return
case <-m.fingerprintResCh:
}
// Collect the data
var fingerprinted []*device.DeviceGroup
for _, i := range m.instances {
fingerprinted = append(fingerprinted, i.Devices()...)
}
// Convert and update
out := make([]*... | go | func (m *manager) fingerprint() {
for {
select {
case <-m.ctx.Done():
return
case <-m.fingerprintResCh:
}
// Collect the data
var fingerprinted []*device.DeviceGroup
for _, i := range m.instances {
fingerprinted = append(fingerprinted, i.Devices()...)
}
// Convert and update
out := make([]*... | [
"func",
"(",
"m",
"*",
"manager",
")",
"fingerprint",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"m",
".",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"\n",
"case",
"<-",
"m",
".",
"fingerprintResCh",
":",
"}",
"\n\n",
"// Collect the... | // fingerprint is the main fingerprint loop | [
"fingerprint",
"is",
"the",
"main",
"fingerprint",
"loop"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/manager.go#L169-L192 |
132,568 | hashicorp/nomad | client/devicemanager/manager.go | Reserve | func (m *manager) Reserve(d *structs.AllocatedDeviceResource) (*device.ContainerReservation, error) {
// Go through each plugin and see if it can reserve the resources
for _, i := range m.instances {
if !i.HasDevices(d) {
continue
}
// We found a match so reserve
return i.Reserve(d)
}
return nil, Unkno... | go | func (m *manager) Reserve(d *structs.AllocatedDeviceResource) (*device.ContainerReservation, error) {
// Go through each plugin and see if it can reserve the resources
for _, i := range m.instances {
if !i.HasDevices(d) {
continue
}
// We found a match so reserve
return i.Reserve(d)
}
return nil, Unkno... | [
"func",
"(",
"m",
"*",
"manager",
")",
"Reserve",
"(",
"d",
"*",
"structs",
".",
"AllocatedDeviceResource",
")",
"(",
"*",
"device",
".",
"ContainerReservation",
",",
"error",
")",
"{",
"// Go through each plugin and see if it can reserve the resources",
"for",
"_",... | // Reserve reserves the given allocated device. If the device is unknown, an
// UnknownDeviceErr is returned. | [
"Reserve",
"reserves",
"the",
"given",
"allocated",
"device",
".",
"If",
"the",
"device",
"is",
"unknown",
"an",
"UnknownDeviceErr",
"is",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/manager.go#L224-L236 |
132,569 | hashicorp/nomad | client/devicemanager/manager.go | AllStats | func (m *manager) AllStats() []*device.DeviceGroupStats {
// Go through each plugin and collect stats
var stats []*device.DeviceGroupStats
for _, i := range m.instances {
stats = append(stats, i.AllStats()...)
}
return stats
} | go | func (m *manager) AllStats() []*device.DeviceGroupStats {
// Go through each plugin and collect stats
var stats []*device.DeviceGroupStats
for _, i := range m.instances {
stats = append(stats, i.AllStats()...)
}
return stats
} | [
"func",
"(",
"m",
"*",
"manager",
")",
"AllStats",
"(",
")",
"[",
"]",
"*",
"device",
".",
"DeviceGroupStats",
"{",
"// Go through each plugin and collect stats",
"var",
"stats",
"[",
"]",
"*",
"device",
".",
"DeviceGroupStats",
"\n",
"for",
"_",
",",
"i",
... | // AllStats returns statistics for all the devices | [
"AllStats",
"returns",
"statistics",
"for",
"all",
"the",
"devices"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/manager.go#L239-L247 |
132,570 | hashicorp/nomad | client/devicemanager/manager.go | DeviceStats | func (m *manager) DeviceStats(d *structs.AllocatedDeviceResource) (*device.DeviceGroupStats, error) {
// Go through each plugin and see if it has the requested devices
for _, i := range m.instances {
if !i.HasDevices(d) {
continue
}
// We found a match so reserve
return i.DeviceStats(d), nil
}
return n... | go | func (m *manager) DeviceStats(d *structs.AllocatedDeviceResource) (*device.DeviceGroupStats, error) {
// Go through each plugin and see if it has the requested devices
for _, i := range m.instances {
if !i.HasDevices(d) {
continue
}
// We found a match so reserve
return i.DeviceStats(d), nil
}
return n... | [
"func",
"(",
"m",
"*",
"manager",
")",
"DeviceStats",
"(",
"d",
"*",
"structs",
".",
"AllocatedDeviceResource",
")",
"(",
"*",
"device",
".",
"DeviceGroupStats",
",",
"error",
")",
"{",
"// Go through each plugin and see if it has the requested devices",
"for",
"_",... | // DeviceStats returns the statistics for the passed devices. If the device is unknown, an
// UnknownDeviceErr is returned. | [
"DeviceStats",
"returns",
"the",
"statistics",
"for",
"the",
"passed",
"devices",
".",
"If",
"the",
"device",
"is",
"unknown",
"an",
"UnknownDeviceErr",
"is",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/manager.go#L251-L263 |
132,571 | hashicorp/nomad | client/devicemanager/manager.go | cleanupStalePlugins | func (m *manager) cleanupStalePlugins() error {
// Read the old plugin state
s, err := m.state.GetDevicePluginState()
if err != nil {
return fmt.Errorf("failed to read plugin state: %v", err)
}
// No state was stored so there is nothing to do.
if s == nil {
return nil
}
// For each plugin go through and ... | go | func (m *manager) cleanupStalePlugins() error {
// Read the old plugin state
s, err := m.state.GetDevicePluginState()
if err != nil {
return fmt.Errorf("failed to read plugin state: %v", err)
}
// No state was stored so there is nothing to do.
if s == nil {
return nil
}
// For each plugin go through and ... | [
"func",
"(",
"m",
"*",
"manager",
")",
"cleanupStalePlugins",
"(",
")",
"error",
"{",
"// Read the old plugin state",
"s",
",",
"err",
":=",
"m",
".",
"state",
".",
"GetDevicePluginState",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
"... | // cleanupStalePlugins reads the device managers state and shuts down any
// previously launched plugin. | [
"cleanupStalePlugins",
"reads",
"the",
"device",
"managers",
"state",
"and",
"shuts",
"down",
"any",
"previously",
"launched",
"plugin",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/manager.go#L267-L300 |
132,572 | hashicorp/nomad | client/devicemanager/manager.go | storePluginReattachConfig | func (m *manager) storePluginReattachConfig(id loader.PluginID, c *plugin.ReattachConfig) error {
m.reattachConfigLock.Lock()
defer m.reattachConfigLock.Unlock()
// Store the new reattach config
m.reattachConfigs[id] = pstructs.ReattachConfigFromGoPlugin(c)
// Persist the state
s := &state.PluginState{
Reatta... | go | func (m *manager) storePluginReattachConfig(id loader.PluginID, c *plugin.ReattachConfig) error {
m.reattachConfigLock.Lock()
defer m.reattachConfigLock.Unlock()
// Store the new reattach config
m.reattachConfigs[id] = pstructs.ReattachConfigFromGoPlugin(c)
// Persist the state
s := &state.PluginState{
Reatta... | [
"func",
"(",
"m",
"*",
"manager",
")",
"storePluginReattachConfig",
"(",
"id",
"loader",
".",
"PluginID",
",",
"c",
"*",
"plugin",
".",
"ReattachConfig",
")",
"error",
"{",
"m",
".",
"reattachConfigLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
... | // storePluginReattachConfig is used as a callback to the instance managers and
// persists thhe plugin reattach configurations. | [
"storePluginReattachConfig",
"is",
"used",
"as",
"a",
"callback",
"to",
"the",
"instance",
"managers",
"and",
"persists",
"thhe",
"plugin",
"reattach",
"configurations",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/client/devicemanager/manager.go#L304-L321 |
132,573 | hashicorp/nomad | command/namespace_status.go | formatNamespaceBasics | func formatNamespaceBasics(ns *api.Namespace) string {
basic := []string{
fmt.Sprintf("Name|%s", ns.Name),
fmt.Sprintf("Description|%s", ns.Description),
fmt.Sprintf("Quota|%s", ns.Quota),
}
return formatKV(basic)
} | go | func formatNamespaceBasics(ns *api.Namespace) string {
basic := []string{
fmt.Sprintf("Name|%s", ns.Name),
fmt.Sprintf("Description|%s", ns.Description),
fmt.Sprintf("Quota|%s", ns.Quota),
}
return formatKV(basic)
} | [
"func",
"formatNamespaceBasics",
"(",
"ns",
"*",
"api",
".",
"Namespace",
")",
"string",
"{",
"basic",
":=",
"[",
"]",
"string",
"{",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ns",
".",
"Name",
")",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
... | // formatNamespaceBasics formats the basic information of the namespace | [
"formatNamespaceBasics",
"formats",
"the",
"basic",
"information",
"of",
"the",
"namespace"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/command/namespace_status.go#L110-L118 |
132,574 | hashicorp/nomad | api/namespace.go | List | func (n *Namespaces) List(q *QueryOptions) ([]*Namespace, *QueryMeta, error) {
var resp []*Namespace
qm, err := n.client.query("/v1/namespaces", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(NamespaceIndexSort(resp))
return resp, qm, nil
} | go | func (n *Namespaces) List(q *QueryOptions) ([]*Namespace, *QueryMeta, error) {
var resp []*Namespace
qm, err := n.client.query("/v1/namespaces", &resp, q)
if err != nil {
return nil, nil, err
}
sort.Sort(NamespaceIndexSort(resp))
return resp, qm, nil
} | [
"func",
"(",
"n",
"*",
"Namespaces",
")",
"List",
"(",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"Namespace",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"[",
"]",
"*",
"Namespace",
"\n",
"qm",
",",
"err",
":=",
"n",
... | // List is used to dump all of the namespaces. | [
"List",
"is",
"used",
"to",
"dump",
"all",
"of",
"the",
"namespaces",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/namespace.go#L19-L27 |
132,575 | hashicorp/nomad | api/namespace.go | PrefixList | func (n *Namespaces) PrefixList(prefix string, q *QueryOptions) ([]*Namespace, *QueryMeta, error) {
if q == nil {
q = &QueryOptions{Prefix: prefix}
} else {
q.Prefix = prefix
}
return n.List(q)
} | go | func (n *Namespaces) PrefixList(prefix string, q *QueryOptions) ([]*Namespace, *QueryMeta, error) {
if q == nil {
q = &QueryOptions{Prefix: prefix}
} else {
q.Prefix = prefix
}
return n.List(q)
} | [
"func",
"(",
"n",
"*",
"Namespaces",
")",
"PrefixList",
"(",
"prefix",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"[",
"]",
"*",
"Namespace",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"if",
"q",
"==",
"nil",
"{",
"q",
"=",
"&",
"Quer... | // PrefixList is used to do a PrefixList search over namespaces | [
"PrefixList",
"is",
"used",
"to",
"do",
"a",
"PrefixList",
"search",
"over",
"namespaces"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/namespace.go#L30-L38 |
132,576 | hashicorp/nomad | api/namespace.go | Info | func (n *Namespaces) Info(name string, q *QueryOptions) (*Namespace, *QueryMeta, error) {
var resp Namespace
qm, err := n.client.query("/v1/namespace/"+name, &resp, q)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | go | func (n *Namespaces) Info(name string, q *QueryOptions) (*Namespace, *QueryMeta, error) {
var resp Namespace
qm, err := n.client.query("/v1/namespace/"+name, &resp, q)
if err != nil {
return nil, nil, err
}
return &resp, qm, nil
} | [
"func",
"(",
"n",
"*",
"Namespaces",
")",
"Info",
"(",
"name",
"string",
",",
"q",
"*",
"QueryOptions",
")",
"(",
"*",
"Namespace",
",",
"*",
"QueryMeta",
",",
"error",
")",
"{",
"var",
"resp",
"Namespace",
"\n",
"qm",
",",
"err",
":=",
"n",
".",
... | // Info is used to query a single namespace by its name. | [
"Info",
"is",
"used",
"to",
"query",
"a",
"single",
"namespace",
"by",
"its",
"name",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/namespace.go#L41-L48 |
132,577 | hashicorp/nomad | api/namespace.go | Register | func (n *Namespaces) Register(namespace *Namespace, q *WriteOptions) (*WriteMeta, error) {
wm, err := n.client.write("/v1/namespace", namespace, nil, q)
if err != nil {
return nil, err
}
return wm, nil
} | go | func (n *Namespaces) Register(namespace *Namespace, q *WriteOptions) (*WriteMeta, error) {
wm, err := n.client.write("/v1/namespace", namespace, nil, q)
if err != nil {
return nil, err
}
return wm, nil
} | [
"func",
"(",
"n",
"*",
"Namespaces",
")",
"Register",
"(",
"namespace",
"*",
"Namespace",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"wm",
",",
"err",
":=",
"n",
".",
"client",
".",
"write",
"(",
"\"",
"\"",
... | // Register is used to register a namespace. | [
"Register",
"is",
"used",
"to",
"register",
"a",
"namespace",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/namespace.go#L51-L57 |
132,578 | hashicorp/nomad | api/namespace.go | Delete | func (n *Namespaces) Delete(namespace string, q *WriteOptions) (*WriteMeta, error) {
wm, err := n.client.delete(fmt.Sprintf("/v1/namespace/%s", namespace), nil, q)
if err != nil {
return nil, err
}
return wm, nil
} | go | func (n *Namespaces) Delete(namespace string, q *WriteOptions) (*WriteMeta, error) {
wm, err := n.client.delete(fmt.Sprintf("/v1/namespace/%s", namespace), nil, q)
if err != nil {
return nil, err
}
return wm, nil
} | [
"func",
"(",
"n",
"*",
"Namespaces",
")",
"Delete",
"(",
"namespace",
"string",
",",
"q",
"*",
"WriteOptions",
")",
"(",
"*",
"WriteMeta",
",",
"error",
")",
"{",
"wm",
",",
"err",
":=",
"n",
".",
"client",
".",
"delete",
"(",
"fmt",
".",
"Sprintf"... | // Delete is used to delete a namespace | [
"Delete",
"is",
"used",
"to",
"delete",
"a",
"namespace"
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/api/namespace.go#L60-L66 |
132,579 | hashicorp/nomad | nomad/structs/diff.go | taskGroupDiffs | func taskGroupDiffs(old, new []*TaskGroup, contextual bool) ([]*TaskGroupDiff, error) {
oldMap := make(map[string]*TaskGroup, len(old))
newMap := make(map[string]*TaskGroup, len(new))
for _, o := range old {
oldMap[o.Name] = o
}
for _, n := range new {
newMap[n.Name] = n
}
var diffs []*TaskGroupDiff
for na... | go | func taskGroupDiffs(old, new []*TaskGroup, contextual bool) ([]*TaskGroupDiff, error) {
oldMap := make(map[string]*TaskGroup, len(old))
newMap := make(map[string]*TaskGroup, len(new))
for _, o := range old {
oldMap[o.Name] = o
}
for _, n := range new {
newMap[n.Name] = n
}
var diffs []*TaskGroupDiff
for na... | [
"func",
"taskGroupDiffs",
"(",
"old",
",",
"new",
"[",
"]",
"*",
"TaskGroup",
",",
"contextual",
"bool",
")",
"(",
"[",
"]",
"*",
"TaskGroupDiff",
",",
"error",
")",
"{",
"oldMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"TaskGroup",
",",
... | // TaskGroupDiffs diffs two sets of task groups. If contextual diff is enabled,
// objects' fields will be stored even if no diff occurred as long as one field
// changed. | [
"TaskGroupDiffs",
"diffs",
"two",
"sets",
"of",
"task",
"groups",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"objects",
"fields",
"will",
"be",
"stored",
"even",
"if",
"no",
"diff",
"occurred",
"as",
"long",
"as",
"one",
"field",
"changed",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L316-L349 |
132,580 | hashicorp/nomad | nomad/structs/diff.go | taskDiffs | func taskDiffs(old, new []*Task, contextual bool) ([]*TaskDiff, error) {
oldMap := make(map[string]*Task, len(old))
newMap := make(map[string]*Task, len(new))
for _, o := range old {
oldMap[o.Name] = o
}
for _, n := range new {
newMap[n.Name] = n
}
var diffs []*TaskDiff
for name, oldGroup := range oldMap {... | go | func taskDiffs(old, new []*Task, contextual bool) ([]*TaskDiff, error) {
oldMap := make(map[string]*Task, len(old))
newMap := make(map[string]*Task, len(new))
for _, o := range old {
oldMap[o.Name] = o
}
for _, n := range new {
newMap[n.Name] = n
}
var diffs []*TaskDiff
for name, oldGroup := range oldMap {... | [
"func",
"taskDiffs",
"(",
"old",
",",
"new",
"[",
"]",
"*",
"Task",
",",
"contextual",
"bool",
")",
"(",
"[",
"]",
"*",
"TaskDiff",
",",
"error",
")",
"{",
"oldMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Task",
",",
"len",
"(",
"o... | // taskDiffs diffs a set of tasks. If contextual diff is enabled, unchanged
// fields within objects nested in the tasks will be returned. | [
"taskDiffs",
"diffs",
"a",
"set",
"of",
"tasks",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"unchanged",
"fields",
"within",
"objects",
"nested",
"in",
"the",
"tasks",
"will",
"be",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L502-L535 |
132,581 | hashicorp/nomad | nomad/structs/diff.go | serviceDiff | func serviceDiff(old, new *Service, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Service"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
if reflect.DeepEqual(old, new) {
return nil
} else if old == nil {
old = &Service{}
diff.Type = DiffTypeAdded
newPrimitiveFlat... | go | func serviceDiff(old, new *Service, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Service"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
if reflect.DeepEqual(old, new) {
return nil
} else if old == nil {
old = &Service{}
diff.Type = DiffTypeAdded
newPrimitiveFlat... | [
"func",
"serviceDiff",
"(",
"old",
",",
"new",
"*",
"Service",
",",
"contextual",
"bool",
")",
"*",
"ObjectDiff",
"{",
"diff",
":=",
"&",
"ObjectDiff",
"{",
"Type",
":",
"DiffTypeNone",
",",
"Name",
":",
"\"",
"\"",
"}",
"\n",
"var",
"oldPrimitiveFlat",
... | // serviceDiff returns the diff of two service objects. If contextual diff is
// enabled, all fields will be returned, even if no diff occurred. | [
"serviceDiff",
"returns",
"the",
"diff",
"of",
"two",
"service",
"objects",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"all",
"fields",
"will",
"be",
"returned",
"even",
"if",
"no",
"diff",
"occurred",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L546-L584 |
132,582 | hashicorp/nomad | nomad/structs/diff.go | serviceDiffs | func serviceDiffs(old, new []*Service, contextual bool) []*ObjectDiff {
oldMap := make(map[string]*Service, len(old))
newMap := make(map[string]*Service, len(new))
for _, o := range old {
oldMap[o.Name] = o
}
for _, n := range new {
newMap[n.Name] = n
}
var diffs []*ObjectDiff
for name, oldService := range... | go | func serviceDiffs(old, new []*Service, contextual bool) []*ObjectDiff {
oldMap := make(map[string]*Service, len(old))
newMap := make(map[string]*Service, len(new))
for _, o := range old {
oldMap[o.Name] = o
}
for _, n := range new {
newMap[n.Name] = n
}
var diffs []*ObjectDiff
for name, oldService := range... | [
"func",
"serviceDiffs",
"(",
"old",
",",
"new",
"[",
"]",
"*",
"Service",
",",
"contextual",
"bool",
")",
"[",
"]",
"*",
"ObjectDiff",
"{",
"oldMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Service",
",",
"len",
"(",
"old",
")",
")",
... | // serviceDiffs diffs a set of services. If contextual diff is enabled, unchanged
// fields within objects nested in the tasks will be returned. | [
"serviceDiffs",
"diffs",
"a",
"set",
"of",
"services",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"unchanged",
"fields",
"within",
"objects",
"nested",
"in",
"the",
"tasks",
"will",
"be",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L588-L617 |
132,583 | hashicorp/nomad | nomad/structs/diff.go | serviceCheckDiff | func serviceCheckDiff(old, new *ServiceCheck, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Check"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
if reflect.DeepEqual(old, new) {
return nil
} else if old == nil {
old = &ServiceCheck{}
diff.Type = DiffTypeAdded
new... | go | func serviceCheckDiff(old, new *ServiceCheck, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Check"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
if reflect.DeepEqual(old, new) {
return nil
} else if old == nil {
old = &ServiceCheck{}
diff.Type = DiffTypeAdded
new... | [
"func",
"serviceCheckDiff",
"(",
"old",
",",
"new",
"*",
"ServiceCheck",
",",
"contextual",
"bool",
")",
"*",
"ObjectDiff",
"{",
"diff",
":=",
"&",
"ObjectDiff",
"{",
"Type",
":",
"DiffTypeNone",
",",
"Name",
":",
"\"",
"\"",
"}",
"\n",
"var",
"oldPrimit... | // serviceCheckDiff returns the diff of two service check objects. If contextual
// diff is enabled, all fields will be returned, even if no diff occurred. | [
"serviceCheckDiff",
"returns",
"the",
"diff",
"of",
"two",
"service",
"check",
"objects",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"all",
"fields",
"will",
"be",
"returned",
"even",
"if",
"no",
"diff",
"occurred",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L621-L655 |
132,584 | hashicorp/nomad | nomad/structs/diff.go | checkHeaderDiff | func checkHeaderDiff(old, new map[string][]string, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Header"}
var oldFlat, newFlat map[string]string
if reflect.DeepEqual(old, new) {
return nil
} else if len(old) == 0 {
diff.Type = DiffTypeAdded
newFlat = flatmap.Flatten(new, nil, ... | go | func checkHeaderDiff(old, new map[string][]string, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Header"}
var oldFlat, newFlat map[string]string
if reflect.DeepEqual(old, new) {
return nil
} else if len(old) == 0 {
diff.Type = DiffTypeAdded
newFlat = flatmap.Flatten(new, nil, ... | [
"func",
"checkHeaderDiff",
"(",
"old",
",",
"new",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"contextual",
"bool",
")",
"*",
"ObjectDiff",
"{",
"diff",
":=",
"&",
"ObjectDiff",
"{",
"Type",
":",
"DiffTypeNone",
",",
"Name",
":",
"\"",
"\"",
... | // checkHeaderDiff returns the diff of two service check header objects. If
// contextual diff is enabled, all fields will be returned, even if no diff
// occurred. | [
"checkHeaderDiff",
"returns",
"the",
"diff",
"of",
"two",
"service",
"check",
"header",
"objects",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"all",
"fields",
"will",
"be",
"returned",
"even",
"if",
"no",
"diff",
"occurred",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L660-L680 |
132,585 | hashicorp/nomad | nomad/structs/diff.go | checkRestartDiff | func checkRestartDiff(old, new *CheckRestart, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "CheckRestart"}
var oldFlat, newFlat map[string]string
if reflect.DeepEqual(old, new) {
return nil
} else if old == nil {
diff.Type = DiffTypeAdded
newFlat = flatmap.Flatten(new, nil, tr... | go | func checkRestartDiff(old, new *CheckRestart, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "CheckRestart"}
var oldFlat, newFlat map[string]string
if reflect.DeepEqual(old, new) {
return nil
} else if old == nil {
diff.Type = DiffTypeAdded
newFlat = flatmap.Flatten(new, nil, tr... | [
"func",
"checkRestartDiff",
"(",
"old",
",",
"new",
"*",
"CheckRestart",
",",
"contextual",
"bool",
")",
"*",
"ObjectDiff",
"{",
"diff",
":=",
"&",
"ObjectDiff",
"{",
"Type",
":",
"DiffTypeNone",
",",
"Name",
":",
"\"",
"\"",
"}",
"\n",
"var",
"oldFlat",... | // checkRestartDiff returns the diff of two service check check_restart
// objects. If contextual diff is enabled, all fields will be returned, even if
// no diff occurred. | [
"checkRestartDiff",
"returns",
"the",
"diff",
"of",
"two",
"service",
"check",
"check_restart",
"objects",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"all",
"fields",
"will",
"be",
"returned",
"even",
"if",
"no",
"diff",
"occurred",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L685-L706 |
132,586 | hashicorp/nomad | nomad/structs/diff.go | serviceCheckDiffs | func serviceCheckDiffs(old, new []*ServiceCheck, contextual bool) []*ObjectDiff {
oldMap := make(map[string]*ServiceCheck, len(old))
newMap := make(map[string]*ServiceCheck, len(new))
for _, o := range old {
oldMap[o.Name] = o
}
for _, n := range new {
newMap[n.Name] = n
}
var diffs []*ObjectDiff
for name,... | go | func serviceCheckDiffs(old, new []*ServiceCheck, contextual bool) []*ObjectDiff {
oldMap := make(map[string]*ServiceCheck, len(old))
newMap := make(map[string]*ServiceCheck, len(new))
for _, o := range old {
oldMap[o.Name] = o
}
for _, n := range new {
newMap[n.Name] = n
}
var diffs []*ObjectDiff
for name,... | [
"func",
"serviceCheckDiffs",
"(",
"old",
",",
"new",
"[",
"]",
"*",
"ServiceCheck",
",",
"contextual",
"bool",
")",
"[",
"]",
"*",
"ObjectDiff",
"{",
"oldMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"ServiceCheck",
",",
"len",
"(",
"old",
... | // serviceCheckDiffs diffs a set of service checks. If contextual diff is
// enabled, unchanged fields within objects nested in the tasks will be
// returned. | [
"serviceCheckDiffs",
"diffs",
"a",
"set",
"of",
"service",
"checks",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"unchanged",
"fields",
"within",
"objects",
"nested",
"in",
"the",
"tasks",
"will",
"be",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L711-L740 |
132,587 | hashicorp/nomad | nomad/structs/diff.go | vaultDiff | func vaultDiff(old, new *Vault, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Vault"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
if reflect.DeepEqual(old, new) {
return nil
} else if old == nil {
old = &Vault{}
diff.Type = DiffTypeAdded
newPrimitiveFlat = flatm... | go | func vaultDiff(old, new *Vault, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Vault"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
if reflect.DeepEqual(old, new) {
return nil
} else if old == nil {
old = &Vault{}
diff.Type = DiffTypeAdded
newPrimitiveFlat = flatm... | [
"func",
"vaultDiff",
"(",
"old",
",",
"new",
"*",
"Vault",
",",
"contextual",
"bool",
")",
"*",
"ObjectDiff",
"{",
"diff",
":=",
"&",
"ObjectDiff",
"{",
"Type",
":",
"DiffTypeNone",
",",
"Name",
":",
"\"",
"\"",
"}",
"\n",
"var",
"oldPrimitiveFlat",
",... | // vaultDiff returns the diff of two vault objects. If contextual diff is
// enabled, all fields will be returned, even if no diff occurred. | [
"vaultDiff",
"returns",
"the",
"diff",
"of",
"two",
"vault",
"objects",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"all",
"fields",
"will",
"be",
"returned",
"even",
"if",
"no",
"diff",
"occurred",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L744-L773 |
132,588 | hashicorp/nomad | nomad/structs/diff.go | parameterizedJobDiff | func parameterizedJobDiff(old, new *ParameterizedJobConfig, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "ParameterizedJob"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
if reflect.DeepEqual(old, new) {
return nil
} else if old == nil {
old = &ParameterizedJobConfig{... | go | func parameterizedJobDiff(old, new *ParameterizedJobConfig, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "ParameterizedJob"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
if reflect.DeepEqual(old, new) {
return nil
} else if old == nil {
old = &ParameterizedJobConfig{... | [
"func",
"parameterizedJobDiff",
"(",
"old",
",",
"new",
"*",
"ParameterizedJobConfig",
",",
"contextual",
"bool",
")",
"*",
"ObjectDiff",
"{",
"diff",
":=",
"&",
"ObjectDiff",
"{",
"Type",
":",
"DiffTypeNone",
",",
"Name",
":",
"\"",
"\"",
"}",
"\n",
"var"... | // parameterizedJobDiff returns the diff of two parameterized job objects. If
// contextual diff is enabled, all fields will be returned, even if no diff
// occurred. | [
"parameterizedJobDiff",
"returns",
"the",
"diff",
"of",
"two",
"parameterized",
"job",
"objects",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"all",
"fields",
"will",
"be",
"returned",
"even",
"if",
"no",
"diff",
"occurred",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L778-L811 |
132,589 | hashicorp/nomad | nomad/structs/diff.go | Diff | func (r *Resources) Diff(other *Resources, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Resources"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
if reflect.DeepEqual(r, other) {
return nil
} else if r == nil {
r = &Resources{}
diff.Type = DiffTypeAdded
newPrimit... | go | func (r *Resources) Diff(other *Resources, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Resources"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
if reflect.DeepEqual(r, other) {
return nil
} else if r == nil {
r = &Resources{}
diff.Type = DiffTypeAdded
newPrimit... | [
"func",
"(",
"r",
"*",
"Resources",
")",
"Diff",
"(",
"other",
"*",
"Resources",
",",
"contextual",
"bool",
")",
"*",
"ObjectDiff",
"{",
"diff",
":=",
"&",
"ObjectDiff",
"{",
"Type",
":",
"DiffTypeNone",
",",
"Name",
":",
"\"",
"\"",
"}",
"\n",
"var"... | // Diff returns a diff of two resource objects. If contextual diff is enabled,
// non-changed fields will still be returned. | [
"Diff",
"returns",
"a",
"diff",
"of",
"two",
"resource",
"objects",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"non",
"-",
"changed",
"fields",
"will",
"still",
"be",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L815-L849 |
132,590 | hashicorp/nomad | nomad/structs/diff.go | Diff | func (r *NetworkResource) Diff(other *NetworkResource, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Network"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
filter := []string{"Device", "CIDR", "IP"}
if reflect.DeepEqual(r, other) {
return nil
} else if r == nil {
r ... | go | func (r *NetworkResource) Diff(other *NetworkResource, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Network"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
filter := []string{"Device", "CIDR", "IP"}
if reflect.DeepEqual(r, other) {
return nil
} else if r == nil {
r ... | [
"func",
"(",
"r",
"*",
"NetworkResource",
")",
"Diff",
"(",
"other",
"*",
"NetworkResource",
",",
"contextual",
"bool",
")",
"*",
"ObjectDiff",
"{",
"diff",
":=",
"&",
"ObjectDiff",
"{",
"Type",
":",
"DiffTypeNone",
",",
"Name",
":",
"\"",
"\"",
"}",
"... | // Diff returns a diff of two network resources. If contextual diff is enabled,
// non-changed fields will still be returned. | [
"Diff",
"returns",
"a",
"diff",
"of",
"two",
"network",
"resources",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"non",
"-",
"changed",
"fields",
"will",
"still",
"be",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L853-L888 |
132,591 | hashicorp/nomad | nomad/structs/diff.go | networkResourceDiffs | func networkResourceDiffs(old, new []*NetworkResource, contextual bool) []*ObjectDiff {
makeSet := func(objects []*NetworkResource) map[string]*NetworkResource {
objMap := make(map[string]*NetworkResource, len(objects))
for _, obj := range objects {
hash, err := hashstructure.Hash(obj, nil)
if err != nil {
... | go | func networkResourceDiffs(old, new []*NetworkResource, contextual bool) []*ObjectDiff {
makeSet := func(objects []*NetworkResource) map[string]*NetworkResource {
objMap := make(map[string]*NetworkResource, len(objects))
for _, obj := range objects {
hash, err := hashstructure.Hash(obj, nil)
if err != nil {
... | [
"func",
"networkResourceDiffs",
"(",
"old",
",",
"new",
"[",
"]",
"*",
"NetworkResource",
",",
"contextual",
"bool",
")",
"[",
"]",
"*",
"ObjectDiff",
"{",
"makeSet",
":=",
"func",
"(",
"objects",
"[",
"]",
"*",
"NetworkResource",
")",
"map",
"[",
"strin... | // networkResourceDiffs diffs a set of NetworkResources. If contextual diff is enabled,
// non-changed fields will still be returned. | [
"networkResourceDiffs",
"diffs",
"a",
"set",
"of",
"NetworkResources",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"non",
"-",
"changed",
"fields",
"will",
"still",
"be",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L892-L928 |
132,592 | hashicorp/nomad | nomad/structs/diff.go | portDiffs | func portDiffs(old, new []Port, dynamic bool, contextual bool) []*ObjectDiff {
makeSet := func(ports []Port) map[string]Port {
portMap := make(map[string]Port, len(ports))
for _, port := range ports {
portMap[port.Label] = port
}
return portMap
}
oldPorts := makeSet(old)
newPorts := makeSet(new)
var ... | go | func portDiffs(old, new []Port, dynamic bool, contextual bool) []*ObjectDiff {
makeSet := func(ports []Port) map[string]Port {
portMap := make(map[string]Port, len(ports))
for _, port := range ports {
portMap[port.Label] = port
}
return portMap
}
oldPorts := makeSet(old)
newPorts := makeSet(new)
var ... | [
"func",
"portDiffs",
"(",
"old",
",",
"new",
"[",
"]",
"Port",
",",
"dynamic",
"bool",
",",
"contextual",
"bool",
")",
"[",
"]",
"*",
"ObjectDiff",
"{",
"makeSet",
":=",
"func",
"(",
"ports",
"[",
"]",
"Port",
")",
"map",
"[",
"string",
"]",
"Port"... | // portDiffs returns the diff of two sets of ports. The dynamic flag marks the
// set of ports as being Dynamic ports versus Static ports. If contextual diff is enabled,
// non-changed fields will still be returned. | [
"portDiffs",
"returns",
"the",
"diff",
"of",
"two",
"sets",
"of",
"ports",
".",
"The",
"dynamic",
"flag",
"marks",
"the",
"set",
"of",
"ports",
"as",
"being",
"Dynamic",
"ports",
"versus",
"Static",
"ports",
".",
"If",
"contextual",
"diff",
"is",
"enabled"... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L933-L981 |
132,593 | hashicorp/nomad | nomad/structs/diff.go | Diff | func (r *RequestedDevice) Diff(other *RequestedDevice, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Device"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
if reflect.DeepEqual(r, other) {
return nil
} else if r == nil {
diff.Type = DiffTypeAdded
newPrimitiveFlat = ... | go | func (r *RequestedDevice) Diff(other *RequestedDevice, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Device"}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
if reflect.DeepEqual(r, other) {
return nil
} else if r == nil {
diff.Type = DiffTypeAdded
newPrimitiveFlat = ... | [
"func",
"(",
"r",
"*",
"RequestedDevice",
")",
"Diff",
"(",
"other",
"*",
"RequestedDevice",
",",
"contextual",
"bool",
")",
"*",
"ObjectDiff",
"{",
"diff",
":=",
"&",
"ObjectDiff",
"{",
"Type",
":",
"DiffTypeNone",
",",
"Name",
":",
"\"",
"\"",
"}",
"... | // Diff returns a diff of two requested devices. If contextual diff is enabled,
// non-changed fields will still be returned. | [
"Diff",
"returns",
"a",
"diff",
"of",
"two",
"requested",
"devices",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"non",
"-",
"changed",
"fields",
"will",
"still",
"be",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L985-L1007 |
132,594 | hashicorp/nomad | nomad/structs/diff.go | requestedDevicesDiffs | func requestedDevicesDiffs(old, new []*RequestedDevice, contextual bool) []*ObjectDiff {
makeSet := func(devices []*RequestedDevice) map[string]*RequestedDevice {
deviceMap := make(map[string]*RequestedDevice, len(devices))
for _, d := range devices {
deviceMap[d.Name] = d
}
return deviceMap
}
oldSet :=... | go | func requestedDevicesDiffs(old, new []*RequestedDevice, contextual bool) []*ObjectDiff {
makeSet := func(devices []*RequestedDevice) map[string]*RequestedDevice {
deviceMap := make(map[string]*RequestedDevice, len(devices))
for _, d := range devices {
deviceMap[d.Name] = d
}
return deviceMap
}
oldSet :=... | [
"func",
"requestedDevicesDiffs",
"(",
"old",
",",
"new",
"[",
"]",
"*",
"RequestedDevice",
",",
"contextual",
"bool",
")",
"[",
"]",
"*",
"ObjectDiff",
"{",
"makeSet",
":=",
"func",
"(",
"devices",
"[",
"]",
"*",
"RequestedDevice",
")",
"map",
"[",
"stri... | // requestedDevicesDiffs diffs a set of RequestedDevices. If contextual diff is enabled,
// non-changed fields will still be returned. | [
"requestedDevicesDiffs",
"diffs",
"a",
"set",
"of",
"RequestedDevices",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"non",
"-",
"changed",
"fields",
"will",
"still",
"be",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L1011-L1042 |
132,595 | hashicorp/nomad | nomad/structs/diff.go | configDiff | func configDiff(old, new map[string]interface{}, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Config"}
if reflect.DeepEqual(old, new) {
return nil
} else if len(old) == 0 {
diff.Type = DiffTypeAdded
} else if len(new) == 0 {
diff.Type = DiffTypeDeleted
} else {
diff.Type = ... | go | func configDiff(old, new map[string]interface{}, contextual bool) *ObjectDiff {
diff := &ObjectDiff{Type: DiffTypeNone, Name: "Config"}
if reflect.DeepEqual(old, new) {
return nil
} else if len(old) == 0 {
diff.Type = DiffTypeAdded
} else if len(new) == 0 {
diff.Type = DiffTypeDeleted
} else {
diff.Type = ... | [
"func",
"configDiff",
"(",
"old",
",",
"new",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"contextual",
"bool",
")",
"*",
"ObjectDiff",
"{",
"diff",
":=",
"&",
"ObjectDiff",
"{",
"Type",
":",
"DiffTypeNone",
",",
"Name",
":",
"\"",
"\"",
"... | // configDiff returns the diff of two Task Config objects. If contextual diff is
// enabled, all fields will be returned, even if no diff occurred. | [
"configDiff",
"returns",
"the",
"diff",
"of",
"two",
"Task",
"Config",
"objects",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"all",
"fields",
"will",
"be",
"returned",
"even",
"if",
"no",
"diff",
"occurred",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L1046-L1063 |
132,596 | hashicorp/nomad | nomad/structs/diff.go | fieldDiff | func fieldDiff(old, new, name string, contextual bool) *FieldDiff {
diff := &FieldDiff{Name: name, Type: DiffTypeNone}
if old == new {
if !contextual {
return nil
}
diff.Old, diff.New = old, new
return diff
}
if old == "" {
diff.Type = DiffTypeAdded
diff.New = new
} else if new == "" {
diff.Type ... | go | func fieldDiff(old, new, name string, contextual bool) *FieldDiff {
diff := &FieldDiff{Name: name, Type: DiffTypeNone}
if old == new {
if !contextual {
return nil
}
diff.Old, diff.New = old, new
return diff
}
if old == "" {
diff.Type = DiffTypeAdded
diff.New = new
} else if new == "" {
diff.Type ... | [
"func",
"fieldDiff",
"(",
"old",
",",
"new",
",",
"name",
"string",
",",
"contextual",
"bool",
")",
"*",
"FieldDiff",
"{",
"diff",
":=",
"&",
"FieldDiff",
"{",
"Name",
":",
"name",
",",
"Type",
":",
"DiffTypeNone",
"}",
"\n",
"if",
"old",
"==",
"new"... | // fieldDiff returns a FieldDiff if old and new are different otherwise, it
// returns nil. If contextual diff is enabled, even non-changed fields will be
// returned. | [
"fieldDiff",
"returns",
"a",
"FieldDiff",
"if",
"old",
"and",
"new",
"are",
"different",
"otherwise",
"it",
"returns",
"nil",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"even",
"non",
"-",
"changed",
"fields",
"will",
"be",
"returned",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L1149-L1171 |
132,597 | hashicorp/nomad | nomad/structs/diff.go | fieldDiffs | func fieldDiffs(old, new map[string]string, contextual bool) []*FieldDiff {
var diffs []*FieldDiff
visited := make(map[string]struct{})
for k, oldV := range old {
visited[k] = struct{}{}
newV := new[k]
if diff := fieldDiff(oldV, newV, k, contextual); diff != nil {
diffs = append(diffs, diff)
}
}
for k,... | go | func fieldDiffs(old, new map[string]string, contextual bool) []*FieldDiff {
var diffs []*FieldDiff
visited := make(map[string]struct{})
for k, oldV := range old {
visited[k] = struct{}{}
newV := new[k]
if diff := fieldDiff(oldV, newV, k, contextual); diff != nil {
diffs = append(diffs, diff)
}
}
for k,... | [
"func",
"fieldDiffs",
"(",
"old",
",",
"new",
"map",
"[",
"string",
"]",
"string",
",",
"contextual",
"bool",
")",
"[",
"]",
"*",
"FieldDiff",
"{",
"var",
"diffs",
"[",
"]",
"*",
"FieldDiff",
"\n",
"visited",
":=",
"make",
"(",
"map",
"[",
"string",
... | // fieldDiffs takes a map of field names to their values and returns a set of
// field diffs. If contextual diff is enabled, even non-changed fields will be
// returned. | [
"fieldDiffs",
"takes",
"a",
"map",
"of",
"field",
"names",
"to",
"their",
"values",
"and",
"returns",
"a",
"set",
"of",
"field",
"diffs",
".",
"If",
"contextual",
"diff",
"is",
"enabled",
"even",
"non",
"-",
"changed",
"fields",
"will",
"be",
"returned",
... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L1210-L1231 |
132,598 | hashicorp/nomad | nomad/structs/diff.go | stringSetDiff | func stringSetDiff(old, new []string, name string, contextual bool) *ObjectDiff {
oldMap := make(map[string]struct{}, len(old))
newMap := make(map[string]struct{}, len(new))
for _, o := range old {
oldMap[o] = struct{}{}
}
for _, n := range new {
newMap[n] = struct{}{}
}
if reflect.DeepEqual(oldMap, newMap) ... | go | func stringSetDiff(old, new []string, name string, contextual bool) *ObjectDiff {
oldMap := make(map[string]struct{}, len(old))
newMap := make(map[string]struct{}, len(new))
for _, o := range old {
oldMap[o] = struct{}{}
}
for _, n := range new {
newMap[n] = struct{}{}
}
if reflect.DeepEqual(oldMap, newMap) ... | [
"func",
"stringSetDiff",
"(",
"old",
",",
"new",
"[",
"]",
"string",
",",
"name",
"string",
",",
"contextual",
"bool",
")",
"*",
"ObjectDiff",
"{",
"oldMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
",",
"len",
"(",
"old",
... | // stringSetDiff diffs two sets of strings with the given name. | [
"stringSetDiff",
"diffs",
"two",
"sets",
"of",
"strings",
"with",
"the",
"given",
"name",
"."
] | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L1234-L1284 |
132,599 | hashicorp/nomad | nomad/structs/diff.go | primitiveObjectDiff | func primitiveObjectDiff(old, new interface{}, filter []string, name string, contextual bool) *ObjectDiff {
oldPrimitiveFlat := flatmap.Flatten(old, filter, true)
newPrimitiveFlat := flatmap.Flatten(new, filter, true)
delete(oldPrimitiveFlat, "")
delete(newPrimitiveFlat, "")
diff := &ObjectDiff{Name: name}
diff.... | go | func primitiveObjectDiff(old, new interface{}, filter []string, name string, contextual bool) *ObjectDiff {
oldPrimitiveFlat := flatmap.Flatten(old, filter, true)
newPrimitiveFlat := flatmap.Flatten(new, filter, true)
delete(oldPrimitiveFlat, "")
delete(newPrimitiveFlat, "")
diff := &ObjectDiff{Name: name}
diff.... | [
"func",
"primitiveObjectDiff",
"(",
"old",
",",
"new",
"interface",
"{",
"}",
",",
"filter",
"[",
"]",
"string",
",",
"name",
"string",
",",
"contextual",
"bool",
")",
"*",
"ObjectDiff",
"{",
"oldPrimitiveFlat",
":=",
"flatmap",
".",
"Flatten",
"(",
"old",... | // primitiveObjectDiff returns a diff of the passed objects' primitive fields.
// The filter field can be used to exclude fields from the diff. The name is the
// name of the objects. If contextual is set, non-changed fields will also be
// stored in the object diff. | [
"primitiveObjectDiff",
"returns",
"a",
"diff",
"of",
"the",
"passed",
"objects",
"primitive",
"fields",
".",
"The",
"filter",
"field",
"can",
"be",
"used",
"to",
"exclude",
"fields",
"from",
"the",
"diff",
".",
"The",
"name",
"is",
"the",
"name",
"of",
"th... | 01c267b92b476a61fbdef49ba3c6b62a84509043 | https://github.com/hashicorp/nomad/blob/01c267b92b476a61fbdef49ba3c6b62a84509043/nomad/structs/diff.go#L1290-L1323 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.