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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
130,400 | containerd/containerd | runtime/v2/runhcs/service.go | getProcess | func (s *service) getProcess(id, execID string) (*process, error) {
s.mu.Lock()
defer s.mu.Unlock()
return s.getProcessLocked(id, execID)
} | go | func (s *service) getProcess(id, execID string) (*process, error) {
s.mu.Lock()
defer s.mu.Unlock()
return s.getProcessLocked(id, execID)
} | [
"func",
"(",
"s",
"*",
"service",
")",
"getProcess",
"(",
"id",
",",
"execID",
"string",
")",
"(",
"*",
"process",
",",
"error",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
... | // getProcess attempts to get a process by id.
// The caller MUST NOT have locked s.mu previous to calling this function. | [
"getProcess",
"attempts",
"to",
"get",
"a",
"process",
"by",
"id",
".",
"The",
"caller",
"MUST",
"NOT",
"have",
"locked",
"s",
".",
"mu",
"previous",
"to",
"calling",
"this",
"function",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/runhcs/service.go#L178-L183 |
130,401 | containerd/containerd | runtime/v2/runhcs/service.go | getProcessLocked | func (s *service) getProcessLocked(id, execID string) (*process, error) {
if execID != "" {
id = execID
}
var p *process
var ok bool
if p, ok = s.processes[id]; !ok {
return nil, errdefs.ToGRPCf(errdefs.ErrNotFound, "process %s", id)
}
return p, nil
} | go | func (s *service) getProcessLocked(id, execID string) (*process, error) {
if execID != "" {
id = execID
}
var p *process
var ok bool
if p, ok = s.processes[id]; !ok {
return nil, errdefs.ToGRPCf(errdefs.ErrNotFound, "process %s", id)
}
return p, nil
} | [
"func",
"(",
"s",
"*",
"service",
")",
"getProcessLocked",
"(",
"id",
",",
"execID",
"string",
")",
"(",
"*",
"process",
",",
"error",
")",
"{",
"if",
"execID",
"!=",
"\"",
"\"",
"{",
"id",
"=",
"execID",
"\n",
"}",
"\n\n",
"var",
"p",
"*",
"proc... | // getProcessLocked attempts to get a process by id.
// The caller MUST protect s.mu previous to calling this function. | [
"getProcessLocked",
"attempts",
"to",
"get",
"a",
"process",
"by",
"id",
".",
"The",
"caller",
"MUST",
"protect",
"s",
".",
"mu",
"previous",
"to",
"calling",
"this",
"function",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/runhcs/service.go#L187-L198 |
130,402 | containerd/containerd | runtime/v2/runhcs/service.go | Stats | func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (*taskAPI.StatsResponse, error) {
log.G(ctx).Debugf("Stats: %s", r.ID)
return nil, errdefs.ErrNotImplemented
} | go | func (s *service) Stats(ctx context.Context, r *taskAPI.StatsRequest) (*taskAPI.StatsResponse, error) {
log.G(ctx).Debugf("Stats: %s", r.ID)
return nil, errdefs.ErrNotImplemented
} | [
"func",
"(",
"s",
"*",
"service",
")",
"Stats",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"taskAPI",
".",
"StatsRequest",
")",
"(",
"*",
"taskAPI",
".",
"StatsResponse",
",",
"error",
")",
"{",
"log",
".",
"G",
"(",
"ctx",
")",
".",
"... | // Stats returns statistics about the running container | [
"Stats",
"returns",
"statistics",
"about",
"the",
"running",
"container"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/runhcs/service.go#L1042-L1046 |
130,403 | containerd/containerd | runtime/v2/runhcs/service.go | Connect | func (s *service) Connect(ctx context.Context, r *taskAPI.ConnectRequest) (*taskAPI.ConnectResponse, error) {
log.G(ctx).Debugf("Connect: %s", r.ID)
var taskpid uint32
p, _ := s.getProcess(r.ID, "")
if p != nil {
taskpid = p.stat().pid
}
return &taskAPI.ConnectResponse{
ShimPid: uint32(os.Getpid()),
TaskP... | go | func (s *service) Connect(ctx context.Context, r *taskAPI.ConnectRequest) (*taskAPI.ConnectResponse, error) {
log.G(ctx).Debugf("Connect: %s", r.ID)
var taskpid uint32
p, _ := s.getProcess(r.ID, "")
if p != nil {
taskpid = p.stat().pid
}
return &taskAPI.ConnectResponse{
ShimPid: uint32(os.Getpid()),
TaskP... | [
"func",
"(",
"s",
"*",
"service",
")",
"Connect",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"taskAPI",
".",
"ConnectRequest",
")",
"(",
"*",
"taskAPI",
".",
"ConnectResponse",
",",
"error",
")",
"{",
"log",
".",
"G",
"(",
"ctx",
")",
".... | // Connect returns the runhcs shim information | [
"Connect",
"returns",
"the",
"runhcs",
"shim",
"information"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/runhcs/service.go#L1049-L1063 |
130,404 | containerd/containerd | runtime/v2/runhcs/service.go | Shutdown | func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (*ptypes.Empty, error) {
log.G(ctx).Debugf("Shutdown: %s", r.ID)
if s.debugListener != nil {
s.debugListener.Close()
}
s.publisher.Close()
s.shutdown()
return empty, nil
} | go | func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (*ptypes.Empty, error) {
log.G(ctx).Debugf("Shutdown: %s", r.ID)
if s.debugListener != nil {
s.debugListener.Close()
}
s.publisher.Close()
s.shutdown()
return empty, nil
} | [
"func",
"(",
"s",
"*",
"service",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"taskAPI",
".",
"ShutdownRequest",
")",
"(",
"*",
"ptypes",
".",
"Empty",
",",
"error",
")",
"{",
"log",
".",
"G",
"(",
"ctx",
")",
".",
"Deb... | // Shutdown stops this instance of the runhcs shim | [
"Shutdown",
"stops",
"this",
"instance",
"of",
"the",
"runhcs",
"shim"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/runhcs/service.go#L1066-L1076 |
130,405 | containerd/containerd | runtime/v2/shim/reaper_unix.go | Reap | func Reap() error {
now := time.Now()
exits, err := sys.Reap(false)
Default.Lock()
for c := range Default.subscribers {
for _, e := range exits {
c <- runc.Exit{
Timestamp: now,
Pid: e.Pid,
Status: e.Status,
}
}
}
Default.Unlock()
return err
} | go | func Reap() error {
now := time.Now()
exits, err := sys.Reap(false)
Default.Lock()
for c := range Default.subscribers {
for _, e := range exits {
c <- runc.Exit{
Timestamp: now,
Pid: e.Pid,
Status: e.Status,
}
}
}
Default.Unlock()
return err
} | [
"func",
"Reap",
"(",
")",
"error",
"{",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"exits",
",",
"err",
":=",
"sys",
".",
"Reap",
"(",
"false",
")",
"\n",
"Default",
".",
"Lock",
"(",
")",
"\n",
"for",
"c",
":=",
"range",
"Default",
".",
... | // Reap should be called when the process receives an SIGCHLD. Reap will reap
// all exited processes and close their wait channels | [
"Reap",
"should",
"be",
"called",
"when",
"the",
"process",
"receives",
"an",
"SIGCHLD",
".",
"Reap",
"will",
"reap",
"all",
"exited",
"processes",
"and",
"close",
"their",
"wait",
"channels"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/shim/reaper_unix.go#L38-L53 |
130,406 | containerd/containerd | runtime/v2/shim/reaper_unix.go | Start | func (m *Monitor) Start(c *exec.Cmd) (chan runc.Exit, error) {
ec := m.Subscribe()
if err := c.Start(); err != nil {
m.Unsubscribe(ec)
return nil, err
}
return ec, nil
} | go | func (m *Monitor) Start(c *exec.Cmd) (chan runc.Exit, error) {
ec := m.Subscribe()
if err := c.Start(); err != nil {
m.Unsubscribe(ec)
return nil, err
}
return ec, nil
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"Start",
"(",
"c",
"*",
"exec",
".",
"Cmd",
")",
"(",
"chan",
"runc",
".",
"Exit",
",",
"error",
")",
"{",
"ec",
":=",
"m",
".",
"Subscribe",
"(",
")",
"\n",
"if",
"err",
":=",
"c",
".",
"Start",
"(",
... | // Start starts the command a registers the process with the reaper | [
"Start",
"starts",
"the",
"command",
"a",
"registers",
"the",
"process",
"with",
"the",
"reaper"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/shim/reaper_unix.go#L68-L75 |
130,407 | containerd/containerd | runtime/v2/shim/reaper_unix.go | Wait | func (m *Monitor) Wait(c *exec.Cmd, ec chan runc.Exit) (int, error) {
for e := range ec {
if e.Pid == c.Process.Pid {
// make sure we flush all IO
c.Wait()
m.Unsubscribe(ec)
return e.Status, nil
}
}
// return no such process if the ec channel is closed and no more exit
// events will be sent
return... | go | func (m *Monitor) Wait(c *exec.Cmd, ec chan runc.Exit) (int, error) {
for e := range ec {
if e.Pid == c.Process.Pid {
// make sure we flush all IO
c.Wait()
m.Unsubscribe(ec)
return e.Status, nil
}
}
// return no such process if the ec channel is closed and no more exit
// events will be sent
return... | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"Wait",
"(",
"c",
"*",
"exec",
".",
"Cmd",
",",
"ec",
"chan",
"runc",
".",
"Exit",
")",
"(",
"int",
",",
"error",
")",
"{",
"for",
"e",
":=",
"range",
"ec",
"{",
"if",
"e",
".",
"Pid",
"==",
"c",
".",
... | // Wait blocks until a process is signal as dead.
// User should rely on the value of the exit status to determine if the
// command was successful or not. | [
"Wait",
"blocks",
"until",
"a",
"process",
"is",
"signal",
"as",
"dead",
".",
"User",
"should",
"rely",
"on",
"the",
"value",
"of",
"the",
"exit",
"status",
"to",
"determine",
"if",
"the",
"command",
"was",
"successful",
"or",
"not",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/shim/reaper_unix.go#L80-L92 |
130,408 | containerd/containerd | runtime/v2/shim/reaper_unix.go | Subscribe | func (m *Monitor) Subscribe() chan runc.Exit {
c := make(chan runc.Exit, bufferSize)
m.Lock()
m.subscribers[c] = struct{}{}
m.Unlock()
return c
} | go | func (m *Monitor) Subscribe() chan runc.Exit {
c := make(chan runc.Exit, bufferSize)
m.Lock()
m.subscribers[c] = struct{}{}
m.Unlock()
return c
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"Subscribe",
"(",
")",
"chan",
"runc",
".",
"Exit",
"{",
"c",
":=",
"make",
"(",
"chan",
"runc",
".",
"Exit",
",",
"bufferSize",
")",
"\n",
"m",
".",
"Lock",
"(",
")",
"\n",
"m",
".",
"subscribers",
"[",
"... | // Subscribe to process exit changes | [
"Subscribe",
"to",
"process",
"exit",
"changes"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/shim/reaper_unix.go#L95-L101 |
130,409 | containerd/containerd | runtime/v2/shim/reaper_unix.go | Unsubscribe | func (m *Monitor) Unsubscribe(c chan runc.Exit) {
m.Lock()
delete(m.subscribers, c)
close(c)
m.Unlock()
} | go | func (m *Monitor) Unsubscribe(c chan runc.Exit) {
m.Lock()
delete(m.subscribers, c)
close(c)
m.Unlock()
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"Unsubscribe",
"(",
"c",
"chan",
"runc",
".",
"Exit",
")",
"{",
"m",
".",
"Lock",
"(",
")",
"\n",
"delete",
"(",
"m",
".",
"subscribers",
",",
"c",
")",
"\n",
"close",
"(",
"c",
")",
"\n",
"m",
".",
"Unl... | // Unsubscribe to process exit changes | [
"Unsubscribe",
"to",
"process",
"exit",
"changes"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/shim/reaper_unix.go#L104-L109 |
130,410 | containerd/containerd | runtime/v1/shim/client/client.go | writeAddress | func writeAddress(path, address string) error {
path, err := filepath.Abs(path)
if err != nil {
return err
}
tempPath := filepath.Join(filepath.Dir(path), fmt.Sprintf(".%s", filepath.Base(path)))
f, err := os.OpenFile(tempPath, os.O_RDWR|os.O_CREATE|os.O_EXCL|os.O_SYNC, 0666)
if err != nil {
return err
}
_,... | go | func writeAddress(path, address string) error {
path, err := filepath.Abs(path)
if err != nil {
return err
}
tempPath := filepath.Join(filepath.Dir(path), fmt.Sprintf(".%s", filepath.Base(path)))
f, err := os.OpenFile(tempPath, os.O_RDWR|os.O_CREATE|os.O_EXCL|os.O_SYNC, 0666)
if err != nil {
return err
}
_,... | [
"func",
"writeAddress",
"(",
"path",
",",
"address",
"string",
")",
"error",
"{",
"path",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"tempPath",
":=",
"filepath",... | // writeAddress writes a address file atomically | [
"writeAddress",
"writes",
"a",
"address",
"file",
"atomically"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/shim/client/client.go#L176-L192 |
130,411 | containerd/containerd | runtime/v1/shim/client/client.go | WithConnect | func WithConnect(address string, onClose func()) Opt {
return func(ctx context.Context, config shim.Config) (shimapi.ShimService, io.Closer, error) {
conn, err := connect(address, annonDialer)
if err != nil {
return nil, nil, err
}
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onClose))
return shimapi... | go | func WithConnect(address string, onClose func()) Opt {
return func(ctx context.Context, config shim.Config) (shimapi.ShimService, io.Closer, error) {
conn, err := connect(address, annonDialer)
if err != nil {
return nil, nil, err
}
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onClose))
return shimapi... | [
"func",
"WithConnect",
"(",
"address",
"string",
",",
"onClose",
"func",
"(",
")",
")",
"Opt",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"config",
"shim",
".",
"Config",
")",
"(",
"shimapi",
".",
"ShimService",
",",
"io",
".",
... | // WithConnect connects to an existing shim | [
"WithConnect",
"connects",
"to",
"an",
"existing",
"shim"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/shim/client/client.go#L216-L225 |
130,412 | containerd/containerd | runtime/v1/shim/client/client.go | WithLocal | func WithLocal(publisher events.Publisher) func(context.Context, shim.Config) (shimapi.ShimService, io.Closer, error) {
return func(ctx context.Context, config shim.Config) (shimapi.ShimService, io.Closer, error) {
service, err := shim.NewService(config, publisher)
if err != nil {
return nil, nil, err
}
ret... | go | func WithLocal(publisher events.Publisher) func(context.Context, shim.Config) (shimapi.ShimService, io.Closer, error) {
return func(ctx context.Context, config shim.Config) (shimapi.ShimService, io.Closer, error) {
service, err := shim.NewService(config, publisher)
if err != nil {
return nil, nil, err
}
ret... | [
"func",
"WithLocal",
"(",
"publisher",
"events",
".",
"Publisher",
")",
"func",
"(",
"context",
".",
"Context",
",",
"shim",
".",
"Config",
")",
"(",
"shimapi",
".",
"ShimService",
",",
"io",
".",
"Closer",
",",
"error",
")",
"{",
"return",
"func",
"("... | // WithLocal uses an in process shim | [
"WithLocal",
"uses",
"an",
"in",
"process",
"shim"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/shim/client/client.go#L228-L236 |
130,413 | containerd/containerd | runtime/v1/shim/client/client.go | New | func New(ctx context.Context, config shim.Config, opt Opt) (*Client, error) {
s, c, err := opt(ctx, config)
if err != nil {
return nil, err
}
return &Client{
ShimService: s,
c: c,
exitCh: make(chan struct{}),
}, nil
} | go | func New(ctx context.Context, config shim.Config, opt Opt) (*Client, error) {
s, c, err := opt(ctx, config)
if err != nil {
return nil, err
}
return &Client{
ShimService: s,
c: c,
exitCh: make(chan struct{}),
}, nil
} | [
"func",
"New",
"(",
"ctx",
"context",
".",
"Context",
",",
"config",
"shim",
".",
"Config",
",",
"opt",
"Opt",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"s",
",",
"c",
",",
"err",
":=",
"opt",
"(",
"ctx",
",",
"config",
")",
"\n",
"if",
... | // New returns a new shim client | [
"New",
"returns",
"a",
"new",
"shim",
"client"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/shim/client/client.go#L239-L249 |
130,414 | containerd/containerd | runtime/v1/shim/client/client.go | StopShim | func (c *Client) StopShim(ctx context.Context) error {
return c.signalShim(ctx, unix.SIGTERM)
} | go | func (c *Client) StopShim(ctx context.Context) error {
return c.signalShim(ctx, unix.SIGTERM)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"StopShim",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"return",
"c",
".",
"signalShim",
"(",
"ctx",
",",
"unix",
".",
"SIGTERM",
")",
"\n",
"}"
] | // StopShim signals the shim to exit and wait for the process to disappear | [
"StopShim",
"signals",
"the",
"shim",
"to",
"exit",
"and",
"wait",
"for",
"the",
"process",
"to",
"disappear"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/shim/client/client.go#L273-L275 |
130,415 | containerd/containerd | runtime/v1/shim/client/client.go | KillShim | func (c *Client) KillShim(ctx context.Context) error {
return c.signalShim(ctx, unix.SIGKILL)
} | go | func (c *Client) KillShim(ctx context.Context) error {
return c.signalShim(ctx, unix.SIGKILL)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"KillShim",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"return",
"c",
".",
"signalShim",
"(",
"ctx",
",",
"unix",
".",
"SIGKILL",
")",
"\n",
"}"
] | // KillShim kills the shim forcefully and wait for the process to disappear | [
"KillShim",
"kills",
"the",
"shim",
"forcefully",
"and",
"wait",
"for",
"the",
"process",
"to",
"disappear"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/shim/client/client.go#L278-L280 |
130,416 | containerd/containerd | runtime/v2/shim/util.go | Command | func Command(ctx context.Context, runtime, containerdAddress, path string, cmdArgs ...string) (*exec.Cmd, error) {
ns, err := namespaces.NamespaceRequired(ctx)
if err != nil {
return nil, err
}
self, err := os.Executable()
if err != nil {
return nil, err
}
args := []string{
"-namespace", ns,
"-address", ... | go | func Command(ctx context.Context, runtime, containerdAddress, path string, cmdArgs ...string) (*exec.Cmd, error) {
ns, err := namespaces.NamespaceRequired(ctx)
if err != nil {
return nil, err
}
self, err := os.Executable()
if err != nil {
return nil, err
}
args := []string{
"-namespace", ns,
"-address", ... | [
"func",
"Command",
"(",
"ctx",
"context",
".",
"Context",
",",
"runtime",
",",
"containerdAddress",
",",
"path",
"string",
",",
"cmdArgs",
"...",
"string",
")",
"(",
"*",
"exec",
".",
"Cmd",
",",
"error",
")",
"{",
"ns",
",",
"err",
":=",
"namespaces",... | // Command returns the shim command with the provided args and configuration | [
"Command",
"returns",
"the",
"shim",
"command",
"with",
"the",
"provided",
"args",
"and",
"configuration"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/shim/util.go#L38-L98 |
130,417 | containerd/containerd | runtime/v2/shim/util.go | BinaryName | func BinaryName(runtime string) string {
// runtime name should format like $prefix.name.version
parts := strings.Split(runtime, ".")
if len(parts) < 2 {
return ""
}
return fmt.Sprintf(shimBinaryFormat, parts[len(parts)-2], parts[len(parts)-1])
} | go | func BinaryName(runtime string) string {
// runtime name should format like $prefix.name.version
parts := strings.Split(runtime, ".")
if len(parts) < 2 {
return ""
}
return fmt.Sprintf(shimBinaryFormat, parts[len(parts)-2], parts[len(parts)-1])
} | [
"func",
"BinaryName",
"(",
"runtime",
"string",
")",
"string",
"{",
"// runtime name should format like $prefix.name.version",
"parts",
":=",
"strings",
".",
"Split",
"(",
"runtime",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
"<",
"2",
"{",
... | // BinaryName returns the shim binary name from the runtime name,
// empty string returns means runtime name is invalid | [
"BinaryName",
"returns",
"the",
"shim",
"binary",
"name",
"from",
"the",
"runtime",
"name",
"empty",
"string",
"returns",
"means",
"runtime",
"name",
"is",
"invalid"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/shim/util.go#L102-L110 |
130,418 | containerd/containerd | runtime/v2/shim/util.go | ReadAddress | func ReadAddress(path string) (string, error) {
path, err := filepath.Abs(path)
if err != nil {
return "", err
}
data, err := ioutil.ReadFile(path)
if err != nil {
return "", err
}
if len(data) == 0 {
return "", ErrNoAddress
}
return string(data), nil
} | go | func ReadAddress(path string) (string, error) {
path, err := filepath.Abs(path)
if err != nil {
return "", err
}
data, err := ioutil.ReadFile(path)
if err != nil {
return "", err
}
if len(data) == 0 {
return "", ErrNoAddress
}
return string(data), nil
} | [
"func",
"ReadAddress",
"(",
"path",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"path",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
... | // ReadAddress returns the shim's abstract socket address from the path | [
"ReadAddress",
"returns",
"the",
"shim",
"s",
"abstract",
"socket",
"address",
"from",
"the",
"path"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/shim/util.go#L159-L172 |
130,419 | containerd/containerd | reference/reference.go | Parse | func Parse(s string) (Spec, error) {
u, err := url.Parse("dummy://" + s)
if err != nil {
return Spec{}, err
}
if u.Scheme != "dummy" {
return Spec{}, ErrInvalid
}
if u.Host == "" {
return Spec{}, ErrHostnameRequired
}
var object string
if idx := splitRe.FindStringIndex(u.Path); idx != nil {
// This... | go | func Parse(s string) (Spec, error) {
u, err := url.Parse("dummy://" + s)
if err != nil {
return Spec{}, err
}
if u.Scheme != "dummy" {
return Spec{}, ErrInvalid
}
if u.Host == "" {
return Spec{}, ErrHostnameRequired
}
var object string
if idx := splitRe.FindStringIndex(u.Path); idx != nil {
// This... | [
"func",
"Parse",
"(",
"s",
"string",
")",
"(",
"Spec",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"\"",
"\"",
"+",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Spec",
"{",
"}",
",",
"err",
"\n",
"}... | // Parse parses the string into a structured ref. | [
"Parse",
"parses",
"the",
"string",
"into",
"a",
"structured",
"ref",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/reference/reference.go#L87-L117 |
130,420 | containerd/containerd | reference/reference.go | Hostname | func (r Spec) Hostname() string {
i := strings.Index(r.Locator, "/")
if i < 0 {
i = len(r.Locator) + 1
}
return r.Locator[:i]
} | go | func (r Spec) Hostname() string {
i := strings.Index(r.Locator, "/")
if i < 0 {
i = len(r.Locator) + 1
}
return r.Locator[:i]
} | [
"func",
"(",
"r",
"Spec",
")",
"Hostname",
"(",
")",
"string",
"{",
"i",
":=",
"strings",
".",
"Index",
"(",
"r",
".",
"Locator",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"i",
"<",
"0",
"{",
"i",
"=",
"len",
"(",
"r",
".",
"Locator",
")",
"+",
"... | // Hostname returns the hostname portion of the locator.
//
// Remotes are not required to directly access the resources at this host. This
// method is provided for convenience. | [
"Hostname",
"returns",
"the",
"hostname",
"portion",
"of",
"the",
"locator",
".",
"Remotes",
"are",
"not",
"required",
"to",
"directly",
"access",
"the",
"resources",
"at",
"this",
"host",
".",
"This",
"method",
"is",
"provided",
"for",
"convenience",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/reference/reference.go#L123-L130 |
130,421 | containerd/containerd | reference/reference.go | Digest | func (r Spec) Digest() digest.Digest {
_, dgst := SplitObject(r.Object)
return dgst
} | go | func (r Spec) Digest() digest.Digest {
_, dgst := SplitObject(r.Object)
return dgst
} | [
"func",
"(",
"r",
"Spec",
")",
"Digest",
"(",
")",
"digest",
".",
"Digest",
"{",
"_",
",",
"dgst",
":=",
"SplitObject",
"(",
"r",
".",
"Object",
")",
"\n",
"return",
"dgst",
"\n",
"}"
] | // Digest returns the digest portion of the reference spec. This may be a
// partial or invalid digest, which may be used to lookup a complete digest. | [
"Digest",
"returns",
"the",
"digest",
"portion",
"of",
"the",
"reference",
"spec",
".",
"This",
"may",
"be",
"a",
"partial",
"or",
"invalid",
"digest",
"which",
"may",
"be",
"used",
"to",
"lookup",
"a",
"complete",
"digest",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/reference/reference.go#L134-L137 |
130,422 | containerd/containerd | reference/reference.go | String | func (r Spec) String() string {
if r.Object == "" {
return r.Locator
}
if r.Object[:1] == "@" {
return fmt.Sprintf("%v%v", r.Locator, r.Object)
}
return fmt.Sprintf("%v:%v", r.Locator, r.Object)
} | go | func (r Spec) String() string {
if r.Object == "" {
return r.Locator
}
if r.Object[:1] == "@" {
return fmt.Sprintf("%v%v", r.Locator, r.Object)
}
return fmt.Sprintf("%v:%v", r.Locator, r.Object)
} | [
"func",
"(",
"r",
"Spec",
")",
"String",
"(",
")",
"string",
"{",
"if",
"r",
".",
"Object",
"==",
"\"",
"\"",
"{",
"return",
"r",
".",
"Locator",
"\n",
"}",
"\n",
"if",
"r",
".",
"Object",
"[",
":",
"1",
"]",
"==",
"\"",
"\"",
"{",
"return",
... | // String returns the normalized string for the ref. | [
"String",
"returns",
"the",
"normalized",
"string",
"for",
"the",
"ref",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/reference/reference.go#L140-L149 |
130,423 | containerd/containerd | reference/reference.go | SplitObject | func SplitObject(obj string) (tag string, dgst digest.Digest) {
parts := strings.SplitAfterN(obj, "@", 2)
if len(parts) < 2 {
return parts[0], ""
}
return parts[0], digest.Digest(parts[1])
} | go | func SplitObject(obj string) (tag string, dgst digest.Digest) {
parts := strings.SplitAfterN(obj, "@", 2)
if len(parts) < 2 {
return parts[0], ""
}
return parts[0], digest.Digest(parts[1])
} | [
"func",
"SplitObject",
"(",
"obj",
"string",
")",
"(",
"tag",
"string",
",",
"dgst",
"digest",
".",
"Digest",
")",
"{",
"parts",
":=",
"strings",
".",
"SplitAfterN",
"(",
"obj",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"parts",
")",
... | // SplitObject provides two parts of the object spec, delimited by an `@`
// symbol.
//
// Either may be empty and it is the callers job to validate them
// appropriately. | [
"SplitObject",
"provides",
"two",
"parts",
"of",
"the",
"object",
"spec",
"delimited",
"by",
"an"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/reference/reference.go#L156-L162 |
130,424 | containerd/containerd | runtime/v1/shim/service.go | NewService | func NewService(config Config, publisher events.Publisher) (*Service, error) {
if config.Namespace == "" {
return nil, fmt.Errorf("shim namespace cannot be empty")
}
ctx := namespaces.WithNamespace(context.Background(), config.Namespace)
ctx = log.WithLogger(ctx, logrus.WithFields(logrus.Fields{
"namespace": co... | go | func NewService(config Config, publisher events.Publisher) (*Service, error) {
if config.Namespace == "" {
return nil, fmt.Errorf("shim namespace cannot be empty")
}
ctx := namespaces.WithNamespace(context.Background(), config.Namespace)
ctx = log.WithLogger(ctx, logrus.WithFields(logrus.Fields{
"namespace": co... | [
"func",
"NewService",
"(",
"config",
"Config",
",",
"publisher",
"events",
".",
"Publisher",
")",
"(",
"*",
"Service",
",",
"error",
")",
"{",
"if",
"config",
".",
"Namespace",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"... | // NewService returns a new shim service that can be used via GRPC | [
"NewService",
"returns",
"a",
"new",
"shim",
"service",
"that",
"can",
"be",
"used",
"via",
"GRPC"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/shim/service.go#L74-L97 |
130,425 | containerd/containerd | runtime/v1/shim/service.go | DeleteProcess | func (s *Service) DeleteProcess(ctx context.Context, r *shimapi.DeleteProcessRequest) (*shimapi.DeleteResponse, error) {
if r.ID == s.id {
return nil, status.Errorf(codes.InvalidArgument, "cannot delete init process with DeleteProcess")
}
p, err := s.getExecProcess(r.ID)
if err != nil {
return nil, err
}
if e... | go | func (s *Service) DeleteProcess(ctx context.Context, r *shimapi.DeleteProcessRequest) (*shimapi.DeleteResponse, error) {
if r.ID == s.id {
return nil, status.Errorf(codes.InvalidArgument, "cannot delete init process with DeleteProcess")
}
p, err := s.getExecProcess(r.ID)
if err != nil {
return nil, err
}
if e... | [
"func",
"(",
"s",
"*",
"Service",
")",
"DeleteProcess",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"shimapi",
".",
"DeleteProcessRequest",
")",
"(",
"*",
"shimapi",
".",
"DeleteResponse",
",",
"error",
")",
"{",
"if",
"r",
".",
"ID",
"==",
... | // DeleteProcess deletes an exec'd process | [
"DeleteProcess",
"deletes",
"an",
"exec",
"d",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/shim/service.go#L225-L244 |
130,426 | containerd/containerd | runtime/v1/shim/service.go | ListPids | func (s *Service) ListPids(ctx context.Context, r *shimapi.ListPidsRequest) (*shimapi.ListPidsResponse, error) {
pids, err := s.getContainerPids(ctx, r.ID)
if err != nil {
return nil, errdefs.ToGRPC(err)
}
var processes []*task.ProcessInfo
for _, pid := range pids {
pInfo := task.ProcessInfo{
Pid: pid,
}
... | go | func (s *Service) ListPids(ctx context.Context, r *shimapi.ListPidsRequest) (*shimapi.ListPidsResponse, error) {
pids, err := s.getContainerPids(ctx, r.ID)
if err != nil {
return nil, errdefs.ToGRPC(err)
}
var processes []*task.ProcessInfo
for _, pid := range pids {
pInfo := task.ProcessInfo{
Pid: pid,
}
... | [
"func",
"(",
"s",
"*",
"Service",
")",
"ListPids",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"shimapi",
".",
"ListPidsRequest",
")",
"(",
"*",
"shimapi",
".",
"ListPidsResponse",
",",
"error",
")",
"{",
"pids",
",",
"err",
":=",
"s",
".",... | // ListPids returns all pids inside the container | [
"ListPids",
"returns",
"all",
"pids",
"inside",
"the",
"container"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/shim/service.go#L385-L413 |
130,427 | containerd/containerd | runtime/v1/shim/service.go | ShimInfo | func (s *Service) ShimInfo(ctx context.Context, r *ptypes.Empty) (*shimapi.ShimInfoResponse, error) {
return &shimapi.ShimInfoResponse{
ShimPid: uint32(os.Getpid()),
}, nil
} | go | func (s *Service) ShimInfo(ctx context.Context, r *ptypes.Empty) (*shimapi.ShimInfoResponse, error) {
return &shimapi.ShimInfoResponse{
ShimPid: uint32(os.Getpid()),
}, nil
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"ShimInfo",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"ptypes",
".",
"Empty",
")",
"(",
"*",
"shimapi",
".",
"ShimInfoResponse",
",",
"error",
")",
"{",
"return",
"&",
"shimapi",
".",
"ShimInfoResponse... | // ShimInfo returns shim information such as the shim's pid | [
"ShimInfo",
"returns",
"shim",
"information",
"such",
"as",
"the",
"shim",
"s",
"pid"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/shim/service.go#L459-L463 |
130,428 | containerd/containerd | runtime/v1/shim/service.go | getInitProcess | func (s *Service) getInitProcess() (rproc.Process, error) {
s.mu.Lock()
defer s.mu.Unlock()
p := s.processes[s.id]
if p == nil {
return nil, errdefs.ToGRPCf(errdefs.ErrFailedPrecondition, "container must be created")
}
return p, nil
} | go | func (s *Service) getInitProcess() (rproc.Process, error) {
s.mu.Lock()
defer s.mu.Unlock()
p := s.processes[s.id]
if p == nil {
return nil, errdefs.ToGRPCf(errdefs.ErrFailedPrecondition, "container must be created")
}
return p, nil
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"getInitProcess",
"(",
")",
"(",
"rproc",
".",
"Process",
",",
"error",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"p",
":=",
"s",
".... | // getInitProcess returns initial process | [
"getInitProcess",
"returns",
"initial",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/shim/service.go#L584-L593 |
130,429 | containerd/containerd | runtime/v1/shim/service.go | getExecProcess | func (s *Service) getExecProcess(id string) (rproc.Process, error) {
s.mu.Lock()
defer s.mu.Unlock()
p := s.processes[id]
if p == nil {
return nil, errdefs.ToGRPCf(errdefs.ErrNotFound, "process %s does not exist", id)
}
return p, nil
} | go | func (s *Service) getExecProcess(id string) (rproc.Process, error) {
s.mu.Lock()
defer s.mu.Unlock()
p := s.processes[id]
if p == nil {
return nil, errdefs.ToGRPCf(errdefs.ErrNotFound, "process %s does not exist", id)
}
return p, nil
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"getExecProcess",
"(",
"id",
"string",
")",
"(",
"rproc",
".",
"Process",
",",
"error",
")",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"p",... | // getExecProcess returns exec process | [
"getExecProcess",
"returns",
"exec",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/shim/service.go#L596-L605 |
130,430 | containerd/containerd | filters/parser.go | ParseAll | func ParseAll(ss ...string) (Filter, error) {
if len(ss) == 0 {
return Always, nil
}
var fs []Filter
for _, s := range ss {
f, err := Parse(s)
if err != nil {
return nil, errors.Wrap(errdefs.ErrInvalidArgument, err.Error())
}
fs = append(fs, f)
}
return Any(fs), nil
} | go | func ParseAll(ss ...string) (Filter, error) {
if len(ss) == 0 {
return Always, nil
}
var fs []Filter
for _, s := range ss {
f, err := Parse(s)
if err != nil {
return nil, errors.Wrap(errdefs.ErrInvalidArgument, err.Error())
}
fs = append(fs, f)
}
return Any(fs), nil
} | [
"func",
"ParseAll",
"(",
"ss",
"...",
"string",
")",
"(",
"Filter",
",",
"error",
")",
"{",
"if",
"len",
"(",
"ss",
")",
"==",
"0",
"{",
"return",
"Always",
",",
"nil",
"\n",
"}",
"\n\n",
"var",
"fs",
"[",
"]",
"Filter",
"\n",
"for",
"_",
",",
... | // ParseAll parses each filter in ss and returns a filter that will return true
// if any filter matches the expression.
//
// If no filters are provided, the filter will match anything. | [
"ParseAll",
"parses",
"each",
"filter",
"in",
"ss",
"and",
"returns",
"a",
"filter",
"that",
"will",
"return",
"true",
"if",
"any",
"filter",
"matches",
"the",
"expression",
".",
"If",
"no",
"filters",
"are",
"provided",
"the",
"filter",
"will",
"match",
"... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/filters/parser.go#L65-L81 |
130,431 | containerd/containerd | sys/epoll.go | EpollCtl | func EpollCtl(epfd int, op int, fd int, event *unix.EpollEvent) error {
return unix.EpollCtl(epfd, op, fd, event)
} | go | func EpollCtl(epfd int, op int, fd int, event *unix.EpollEvent) error {
return unix.EpollCtl(epfd, op, fd, event)
} | [
"func",
"EpollCtl",
"(",
"epfd",
"int",
",",
"op",
"int",
",",
"fd",
"int",
",",
"event",
"*",
"unix",
".",
"EpollEvent",
")",
"error",
"{",
"return",
"unix",
".",
"EpollCtl",
"(",
"epfd",
",",
"op",
",",
"fd",
",",
"event",
")",
"\n",
"}"
] | // EpollCtl directly calls unix.EpollCtl | [
"EpollCtl",
"directly",
"calls",
"unix",
".",
"EpollCtl"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/sys/epoll.go#L29-L31 |
130,432 | containerd/containerd | sys/epoll.go | EpollWait | func EpollWait(epfd int, events []unix.EpollEvent, msec int) (int, error) {
return unix.EpollWait(epfd, events, msec)
} | go | func EpollWait(epfd int, events []unix.EpollEvent, msec int) (int, error) {
return unix.EpollWait(epfd, events, msec)
} | [
"func",
"EpollWait",
"(",
"epfd",
"int",
",",
"events",
"[",
"]",
"unix",
".",
"EpollEvent",
",",
"msec",
"int",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"unix",
".",
"EpollWait",
"(",
"epfd",
",",
"events",
",",
"msec",
")",
"\n",
"}"
] | // EpollWait directly calls unix.EpollWait | [
"EpollWait",
"directly",
"calls",
"unix",
".",
"EpollWait"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/sys/epoll.go#L34-L36 |
130,433 | containerd/containerd | runtime/v1/linux/proc/init.go | NewRunc | func NewRunc(root, path, namespace, runtime, criu string, systemd bool) *runc.Runc {
if root == "" {
root = RuncRoot
}
return &runc.Runc{
Command: runtime,
Log: filepath.Join(path, "log.json"),
LogFormat: runc.JSON,
PdeathSignal: syscall.SIGKILL,
Root: filepath.Join(root, na... | go | func NewRunc(root, path, namespace, runtime, criu string, systemd bool) *runc.Runc {
if root == "" {
root = RuncRoot
}
return &runc.Runc{
Command: runtime,
Log: filepath.Join(path, "log.json"),
LogFormat: runc.JSON,
PdeathSignal: syscall.SIGKILL,
Root: filepath.Join(root, na... | [
"func",
"NewRunc",
"(",
"root",
",",
"path",
",",
"namespace",
",",
"runtime",
",",
"criu",
"string",
",",
"systemd",
"bool",
")",
"*",
"runc",
".",
"Runc",
"{",
"if",
"root",
"==",
"\"",
"\"",
"{",
"root",
"=",
"RuncRoot",
"\n",
"}",
"\n",
"return... | // NewRunc returns a new runc instance for a process | [
"NewRunc",
"returns",
"a",
"new",
"runc",
"instance",
"for",
"a",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L80-L93 |
130,434 | containerd/containerd | runtime/v1/linux/proc/init.go | New | func New(id string, runtime *runc.Runc, stdio proc.Stdio) *Init {
p := &Init{
id: id,
runtime: runtime,
stdio: stdio,
status: 0,
waitBlock: make(chan struct{}),
}
p.initState = &createdState{p: p}
return p
} | go | func New(id string, runtime *runc.Runc, stdio proc.Stdio) *Init {
p := &Init{
id: id,
runtime: runtime,
stdio: stdio,
status: 0,
waitBlock: make(chan struct{}),
}
p.initState = &createdState{p: p}
return p
} | [
"func",
"New",
"(",
"id",
"string",
",",
"runtime",
"*",
"runc",
".",
"Runc",
",",
"stdio",
"proc",
".",
"Stdio",
")",
"*",
"Init",
"{",
"p",
":=",
"&",
"Init",
"{",
"id",
":",
"id",
",",
"runtime",
":",
"runtime",
",",
"stdio",
":",
"stdio",
"... | // New returns a new process | [
"New",
"returns",
"a",
"new",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L96-L106 |
130,435 | containerd/containerd | runtime/v1/linux/proc/init.go | Create | func (p *Init) Create(ctx context.Context, r *CreateConfig) error {
var (
err error
socket *runc.Socket
pio *processIO
pidFile = newPidFile(p.Bundle)
)
if r.Terminal {
if socket, err = runc.NewTempConsoleSocket(); err != nil {
return errors.Wrap(err, "failed to create OCI runtime console socket... | go | func (p *Init) Create(ctx context.Context, r *CreateConfig) error {
var (
err error
socket *runc.Socket
pio *processIO
pidFile = newPidFile(p.Bundle)
)
if r.Terminal {
if socket, err = runc.NewTempConsoleSocket(); err != nil {
return errors.Wrap(err, "failed to create OCI runtime console socket... | [
"func",
"(",
"p",
"*",
"Init",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"CreateConfig",
")",
"error",
"{",
"var",
"(",
"err",
"error",
"\n",
"socket",
"*",
"runc",
".",
"Socket",
"\n",
"pio",
"*",
"processIO",
"\n",
"pid... | // Create the process with the provided config | [
"Create",
"the",
"process",
"with",
"the",
"provided",
"config"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L109-L172 |
130,436 | containerd/containerd | runtime/v1/linux/proc/init.go | ExitStatus | func (p *Init) ExitStatus() int {
p.mu.Lock()
defer p.mu.Unlock()
return p.status
} | go | func (p *Init) ExitStatus() int {
p.mu.Lock()
defer p.mu.Unlock()
return p.status
} | [
"func",
"(",
"p",
"*",
"Init",
")",
"ExitStatus",
"(",
")",
"int",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"p",
".",
"status",
"\n",
"}"
] | // ExitStatus of the process | [
"ExitStatus",
"of",
"the",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L220-L225 |
130,437 | containerd/containerd | runtime/v1/linux/proc/init.go | ExitedAt | func (p *Init) ExitedAt() time.Time {
p.mu.Lock()
defer p.mu.Unlock()
return p.exited
} | go | func (p *Init) ExitedAt() time.Time {
p.mu.Lock()
defer p.mu.Unlock()
return p.exited
} | [
"func",
"(",
"p",
"*",
"Init",
")",
"ExitedAt",
"(",
")",
"time",
".",
"Time",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"p",
".",
"exited",
"\n",
"}"
] | // ExitedAt at time when the process exited | [
"ExitedAt",
"at",
"time",
"when",
"the",
"process",
"exited"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L228-L233 |
130,438 | containerd/containerd | runtime/v1/linux/proc/init.go | Status | func (p *Init) Status(ctx context.Context) (string, error) {
p.mu.Lock()
defer p.mu.Unlock()
c, err := p.runtime.State(ctx, p.id)
if err != nil {
if strings.Contains(err.Error(), "does not exist") {
return "stopped", nil
}
return "", p.runtimeError(err, "OCI runtime state failed")
}
return c.Status, nil... | go | func (p *Init) Status(ctx context.Context) (string, error) {
p.mu.Lock()
defer p.mu.Unlock()
c, err := p.runtime.State(ctx, p.id)
if err != nil {
if strings.Contains(err.Error(), "does not exist") {
return "stopped", nil
}
return "", p.runtimeError(err, "OCI runtime state failed")
}
return c.Status, nil... | [
"func",
"(",
"p",
"*",
"Init",
")",
"Status",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"c",
",",
... | // Status of the process | [
"Status",
"of",
"the",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L236-L248 |
130,439 | containerd/containerd | runtime/v1/linux/proc/init.go | Start | func (p *Init) Start(ctx context.Context) error {
p.mu.Lock()
defer p.mu.Unlock()
return p.initState.Start(ctx)
} | go | func (p *Init) Start(ctx context.Context) error {
p.mu.Lock()
defer p.mu.Unlock()
return p.initState.Start(ctx)
} | [
"func",
"(",
"p",
"*",
"Init",
")",
"Start",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"p",
".",
"initState",
".",
... | // Start the init process | [
"Start",
"the",
"init",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L251-L256 |
130,440 | containerd/containerd | runtime/v1/linux/proc/init.go | SetExited | func (p *Init) SetExited(status int) {
p.mu.Lock()
defer p.mu.Unlock()
p.initState.SetExited(status)
} | go | func (p *Init) SetExited(status int) {
p.mu.Lock()
defer p.mu.Unlock()
p.initState.SetExited(status)
} | [
"func",
"(",
"p",
"*",
"Init",
")",
"SetExited",
"(",
"status",
"int",
")",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"p",
".",
"initState",
".",
"SetExited",
"(",
"status",
")",... | // SetExited of the init process with the next status | [
"SetExited",
"of",
"the",
"init",
"process",
"with",
"the",
"next",
"status"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L264-L269 |
130,441 | containerd/containerd | runtime/v1/linux/proc/init.go | Resize | func (p *Init) Resize(ws console.WinSize) error {
p.mu.Lock()
defer p.mu.Unlock()
if p.console == nil {
return nil
}
return p.console.Resize(ws)
} | go | func (p *Init) Resize(ws console.WinSize) error {
p.mu.Lock()
defer p.mu.Unlock()
if p.console == nil {
return nil
}
return p.console.Resize(ws)
} | [
"func",
"(",
"p",
"*",
"Init",
")",
"Resize",
"(",
"ws",
"console",
".",
"WinSize",
")",
"error",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"p",
".",
"console",
"==",
"ni... | // Resize the init processes console | [
"Resize",
"the",
"init",
"processes",
"console"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L317-L325 |
130,442 | containerd/containerd | runtime/v1/linux/proc/init.go | Kill | func (p *Init) Kill(ctx context.Context, signal uint32, all bool) error {
p.mu.Lock()
defer p.mu.Unlock()
return p.initState.Kill(ctx, signal, all)
} | go | func (p *Init) Kill(ctx context.Context, signal uint32, all bool) error {
p.mu.Lock()
defer p.mu.Unlock()
return p.initState.Kill(ctx, signal, all)
} | [
"func",
"(",
"p",
"*",
"Init",
")",
"Kill",
"(",
"ctx",
"context",
".",
"Context",
",",
"signal",
"uint32",
",",
"all",
"bool",
")",
"error",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
... | // Kill the init process | [
"Kill",
"the",
"init",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L351-L356 |
130,443 | containerd/containerd | runtime/v1/linux/proc/init.go | KillAll | func (p *Init) KillAll(ctx context.Context) error {
p.mu.Lock()
defer p.mu.Unlock()
err := p.runtime.Kill(ctx, p.id, int(syscall.SIGKILL), &runc.KillOpts{
All: true,
})
return p.runtimeError(err, "OCI runtime killall failed")
} | go | func (p *Init) KillAll(ctx context.Context) error {
p.mu.Lock()
defer p.mu.Unlock()
err := p.runtime.Kill(ctx, p.id, int(syscall.SIGKILL), &runc.KillOpts{
All: true,
})
return p.runtimeError(err, "OCI runtime killall failed")
} | [
"func",
"(",
"p",
"*",
"Init",
")",
"KillAll",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"err",
":=",
"p",
".",
"runtime",
... | // KillAll processes belonging to the init process | [
"KillAll",
"processes",
"belonging",
"to",
"the",
"init",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L366-L374 |
130,444 | containerd/containerd | runtime/v1/linux/proc/init.go | Exec | func (p *Init) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
p.mu.Lock()
defer p.mu.Unlock()
return p.initState.Exec(ctx, path, r)
} | go | func (p *Init) Exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
p.mu.Lock()
defer p.mu.Unlock()
return p.initState.Exec(ctx, path, r)
} | [
"func",
"(",
"p",
"*",
"Init",
")",
"Exec",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"r",
"*",
"ExecConfig",
")",
"(",
"proc",
".",
"Process",
",",
"error",
")",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer... | // Exec returns a new child process | [
"Exec",
"returns",
"a",
"new",
"child",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L387-L392 |
130,445 | containerd/containerd | runtime/v1/linux/proc/init.go | exec | func (p *Init) exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
// process exec request
var spec specs.Process
if err := json.Unmarshal(r.Spec.Value, &spec); err != nil {
return nil, err
}
spec.Terminal = r.Terminal
e := &execProcess{
id: r.ID,
path: path,
parent: p,
... | go | func (p *Init) exec(ctx context.Context, path string, r *ExecConfig) (proc.Process, error) {
// process exec request
var spec specs.Process
if err := json.Unmarshal(r.Spec.Value, &spec); err != nil {
return nil, err
}
spec.Terminal = r.Terminal
e := &execProcess{
id: r.ID,
path: path,
parent: p,
... | [
"func",
"(",
"p",
"*",
"Init",
")",
"exec",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"r",
"*",
"ExecConfig",
")",
"(",
"proc",
".",
"Process",
",",
"error",
")",
"{",
"// process exec request",
"var",
"spec",
"specs",
".",
"... | // exec returns a new exec'd process | [
"exec",
"returns",
"a",
"new",
"exec",
"d",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L395-L419 |
130,446 | containerd/containerd | runtime/v1/linux/proc/init.go | Checkpoint | func (p *Init) Checkpoint(ctx context.Context, r *CheckpointConfig) error {
p.mu.Lock()
defer p.mu.Unlock()
return p.initState.Checkpoint(ctx, r)
} | go | func (p *Init) Checkpoint(ctx context.Context, r *CheckpointConfig) error {
p.mu.Lock()
defer p.mu.Unlock()
return p.initState.Checkpoint(ctx, r)
} | [
"func",
"(",
"p",
"*",
"Init",
")",
"Checkpoint",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"CheckpointConfig",
")",
"error",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
... | // Checkpoint the init process | [
"Checkpoint",
"the",
"init",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L422-L427 |
130,447 | containerd/containerd | runtime/v1/linux/proc/init.go | Update | func (p *Init) Update(ctx context.Context, r *google_protobuf.Any) error {
p.mu.Lock()
defer p.mu.Unlock()
return p.initState.Update(ctx, r)
} | go | func (p *Init) Update(ctx context.Context, r *google_protobuf.Any) error {
p.mu.Lock()
defer p.mu.Unlock()
return p.initState.Update(ctx, r)
} | [
"func",
"(",
"p",
"*",
"Init",
")",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"google_protobuf",
".",
"Any",
")",
"error",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",... | // Update the processes resource configuration | [
"Update",
"the",
"processes",
"resource",
"configuration"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/init.go#L459-L464 |
130,448 | containerd/containerd | mount/temp.go | WithTempMount | func WithTempMount(ctx context.Context, mounts []Mount, f func(root string) error) (err error) {
root, uerr := ioutil.TempDir(tempMountLocation, "containerd-mount")
if uerr != nil {
return errors.Wrapf(uerr, "failed to create temp dir")
}
// We use Remove here instead of RemoveAll.
// The RemoveAll will delete t... | go | func WithTempMount(ctx context.Context, mounts []Mount, f func(root string) error) (err error) {
root, uerr := ioutil.TempDir(tempMountLocation, "containerd-mount")
if uerr != nil {
return errors.Wrapf(uerr, "failed to create temp dir")
}
// We use Remove here instead of RemoveAll.
// The RemoveAll will delete t... | [
"func",
"WithTempMount",
"(",
"ctx",
"context",
".",
"Context",
",",
"mounts",
"[",
"]",
"Mount",
",",
"f",
"func",
"(",
"root",
"string",
")",
"error",
")",
"(",
"err",
"error",
")",
"{",
"root",
",",
"uerr",
":=",
"ioutil",
".",
"TempDir",
"(",
"... | // WithTempMount mounts the provided mounts to a temp dir, and pass the temp dir to f.
// The mounts are valid during the call to the f.
// Finally we will unmount and remove the temp dir regardless of the result of f. | [
"WithTempMount",
"mounts",
"the",
"provided",
"mounts",
"to",
"a",
"temp",
"dir",
"and",
"pass",
"the",
"temp",
"dir",
"to",
"f",
".",
"The",
"mounts",
"are",
"valid",
"during",
"the",
"call",
"to",
"the",
"f",
".",
"Finally",
"we",
"will",
"unmount",
... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/mount/temp.go#L33-L66 |
130,449 | containerd/containerd | log/context.go | ParseLevel | func ParseLevel(lvl string) (logrus.Level, error) {
if lvl == "trace" {
return TraceLevel, nil
}
return logrus.ParseLevel(lvl)
} | go | func ParseLevel(lvl string) (logrus.Level, error) {
if lvl == "trace" {
return TraceLevel, nil
}
return logrus.ParseLevel(lvl)
} | [
"func",
"ParseLevel",
"(",
"lvl",
"string",
")",
"(",
"logrus",
".",
"Level",
",",
"error",
")",
"{",
"if",
"lvl",
"==",
"\"",
"\"",
"{",
"return",
"TraceLevel",
",",
"nil",
"\n",
"}",
"\n",
"return",
"logrus",
".",
"ParseLevel",
"(",
"lvl",
")",
"... | // ParseLevel takes a string level and returns the Logrus log level constant.
// It supports trace level. | [
"ParseLevel",
"takes",
"a",
"string",
"level",
"and",
"returns",
"the",
"Logrus",
"log",
"level",
"constant",
".",
"It",
"supports",
"trace",
"level",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/log/context.go#L51-L56 |
130,450 | containerd/containerd | log/context.go | GetLogger | func GetLogger(ctx context.Context) *logrus.Entry {
logger := ctx.Value(loggerKey{})
if logger == nil {
return L
}
return logger.(*logrus.Entry)
} | go | func GetLogger(ctx context.Context) *logrus.Entry {
logger := ctx.Value(loggerKey{})
if logger == nil {
return L
}
return logger.(*logrus.Entry)
} | [
"func",
"GetLogger",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"logrus",
".",
"Entry",
"{",
"logger",
":=",
"ctx",
".",
"Value",
"(",
"loggerKey",
"{",
"}",
")",
"\n\n",
"if",
"logger",
"==",
"nil",
"{",
"return",
"L",
"\n",
"}",
"\n\n",
"re... | // GetLogger retrieves the current logger from the context. If no logger is
// available, the default logger is returned. | [
"GetLogger",
"retrieves",
"the",
"current",
"logger",
"from",
"the",
"context",
".",
"If",
"no",
"logger",
"is",
"available",
"the",
"default",
"logger",
"is",
"returned",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/log/context.go#L66-L74 |
130,451 | containerd/containerd | log/context.go | Trace | func Trace(e *logrus.Entry, args ...interface{}) {
level := logrus.Level(atomic.LoadUint32((*uint32)(&e.Logger.Level)))
if level >= TraceLevel {
e.Debug(args...)
}
} | go | func Trace(e *logrus.Entry, args ...interface{}) {
level := logrus.Level(atomic.LoadUint32((*uint32)(&e.Logger.Level)))
if level >= TraceLevel {
e.Debug(args...)
}
} | [
"func",
"Trace",
"(",
"e",
"*",
"logrus",
".",
"Entry",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"level",
":=",
"logrus",
".",
"Level",
"(",
"atomic",
".",
"LoadUint32",
"(",
"(",
"*",
"uint32",
")",
"(",
"&",
"e",
".",
"Logger",
".",... | // Trace logs a message at level Trace with the log entry passed-in. | [
"Trace",
"logs",
"a",
"message",
"at",
"level",
"Trace",
"with",
"the",
"log",
"entry",
"passed",
"-",
"in",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/log/context.go#L77-L82 |
130,452 | containerd/containerd | log/context.go | Tracef | func Tracef(e *logrus.Entry, format string, args ...interface{}) {
level := logrus.Level(atomic.LoadUint32((*uint32)(&e.Logger.Level)))
if level >= TraceLevel {
e.Debugf(format, args...)
}
} | go | func Tracef(e *logrus.Entry, format string, args ...interface{}) {
level := logrus.Level(atomic.LoadUint32((*uint32)(&e.Logger.Level)))
if level >= TraceLevel {
e.Debugf(format, args...)
}
} | [
"func",
"Tracef",
"(",
"e",
"*",
"logrus",
".",
"Entry",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"level",
":=",
"logrus",
".",
"Level",
"(",
"atomic",
".",
"LoadUint32",
"(",
"(",
"*",
"uint32",
")",
"(",
"&",
... | // Tracef logs a message at level Trace with the log entry passed-in. | [
"Tracef",
"logs",
"a",
"message",
"at",
"level",
"Trace",
"with",
"the",
"log",
"entry",
"passed",
"-",
"in",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/log/context.go#L85-L90 |
130,453 | containerd/containerd | sys/reaper.go | Reap | func Reap(wait bool) (exits []Exit, err error) {
var (
ws unix.WaitStatus
rus unix.Rusage
)
flag := unix.WNOHANG
if wait {
flag = 0
}
for {
pid, err := unix.Wait4(-1, &ws, flag, &rus)
if err != nil {
if err == unix.ECHILD {
return exits, nil
}
return exits, err
}
if pid <= 0 {
retur... | go | func Reap(wait bool) (exits []Exit, err error) {
var (
ws unix.WaitStatus
rus unix.Rusage
)
flag := unix.WNOHANG
if wait {
flag = 0
}
for {
pid, err := unix.Wait4(-1, &ws, flag, &rus)
if err != nil {
if err == unix.ECHILD {
return exits, nil
}
return exits, err
}
if pid <= 0 {
retur... | [
"func",
"Reap",
"(",
"wait",
"bool",
")",
"(",
"exits",
"[",
"]",
"Exit",
",",
"err",
"error",
")",
"{",
"var",
"(",
"ws",
"unix",
".",
"WaitStatus",
"\n",
"rus",
"unix",
".",
"Rusage",
"\n",
")",
"\n",
"flag",
":=",
"unix",
".",
"WNOHANG",
"\n",... | // Reap reaps all child processes for the calling process and returns their
// exit information | [
"Reap",
"reaps",
"all",
"child",
"processes",
"for",
"the",
"calling",
"process",
"and",
"returns",
"their",
"exit",
"information"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/sys/reaper.go#L33-L58 |
130,454 | containerd/containerd | leases/lease.go | SynchronousDelete | func SynchronousDelete(ctx context.Context, o *DeleteOptions) error {
o.Synchronous = true
return nil
} | go | func SynchronousDelete(ctx context.Context, o *DeleteOptions) error {
o.Synchronous = true
return nil
} | [
"func",
"SynchronousDelete",
"(",
"ctx",
"context",
".",
"Context",
",",
"o",
"*",
"DeleteOptions",
")",
"error",
"{",
"o",
".",
"Synchronous",
"=",
"true",
"\n",
"return",
"nil",
"\n",
"}"
] | // SynchronousDelete is used to indicate that a lease deletion and removal of
// any unreferenced resources should occur synchronously before returning the
// result. | [
"SynchronousDelete",
"is",
"used",
"to",
"indicate",
"that",
"a",
"lease",
"deletion",
"and",
"removal",
"of",
"any",
"unreferenced",
"resources",
"should",
"occur",
"synchronously",
"before",
"returning",
"the",
"result",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/leases/lease.go#L53-L56 |
130,455 | containerd/containerd | leases/lease.go | WithLabels | func WithLabels(labels map[string]string) Opt {
return func(l *Lease) error {
l.Labels = labels
return nil
}
} | go | func WithLabels(labels map[string]string) Opt {
return func(l *Lease) error {
l.Labels = labels
return nil
}
} | [
"func",
"WithLabels",
"(",
"labels",
"map",
"[",
"string",
"]",
"string",
")",
"Opt",
"{",
"return",
"func",
"(",
"l",
"*",
"Lease",
")",
"error",
"{",
"l",
".",
"Labels",
"=",
"labels",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"}"
] | // WithLabels sets labels on a lease | [
"WithLabels",
"sets",
"labels",
"on",
"a",
"lease"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/leases/lease.go#L59-L64 |
130,456 | containerd/containerd | leases/lease.go | WithExpiration | func WithExpiration(d time.Duration) Opt {
return func(l *Lease) error {
if l.Labels == nil {
l.Labels = map[string]string{}
}
l.Labels["containerd.io/gc.expire"] = time.Now().Add(d).Format(time.RFC3339)
return nil
}
} | go | func WithExpiration(d time.Duration) Opt {
return func(l *Lease) error {
if l.Labels == nil {
l.Labels = map[string]string{}
}
l.Labels["containerd.io/gc.expire"] = time.Now().Add(d).Format(time.RFC3339)
return nil
}
} | [
"func",
"WithExpiration",
"(",
"d",
"time",
".",
"Duration",
")",
"Opt",
"{",
"return",
"func",
"(",
"l",
"*",
"Lease",
")",
"error",
"{",
"if",
"l",
".",
"Labels",
"==",
"nil",
"{",
"l",
".",
"Labels",
"=",
"map",
"[",
"string",
"]",
"string",
"... | // WithExpiration sets an expiration on the lease | [
"WithExpiration",
"sets",
"an",
"expiration",
"on",
"the",
"lease"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/leases/lease.go#L67-L76 |
130,457 | containerd/containerd | task_opts_unix.go | WithNoNewKeyring | func WithNoNewKeyring(ctx context.Context, c *Client, ti *TaskInfo) error {
if CheckRuntime(ti.Runtime(), "io.containerd.runc") {
if ti.Options == nil {
ti.Options = &options.Options{}
}
opts, ok := ti.Options.(*options.Options)
if !ok {
return errors.New("invalid v2 shim create options format")
}
op... | go | func WithNoNewKeyring(ctx context.Context, c *Client, ti *TaskInfo) error {
if CheckRuntime(ti.Runtime(), "io.containerd.runc") {
if ti.Options == nil {
ti.Options = &options.Options{}
}
opts, ok := ti.Options.(*options.Options)
if !ok {
return errors.New("invalid v2 shim create options format")
}
op... | [
"func",
"WithNoNewKeyring",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"Client",
",",
"ti",
"*",
"TaskInfo",
")",
"error",
"{",
"if",
"CheckRuntime",
"(",
"ti",
".",
"Runtime",
"(",
")",
",",
"\"",
"\"",
")",
"{",
"if",
"ti",
".",
"Optio... | // WithNoNewKeyring causes tasks not to be created with a new keyring for secret storage.
// There is an upper limit on the number of keyrings in a linux system | [
"WithNoNewKeyring",
"causes",
"tasks",
"not",
"to",
"be",
"created",
"with",
"a",
"new",
"keyring",
"for",
"secret",
"storage",
".",
"There",
"is",
"an",
"upper",
"limit",
"on",
"the",
"number",
"of",
"keyrings",
"in",
"a",
"linux",
"system"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/task_opts_unix.go#L31-L52 |
130,458 | containerd/containerd | task_opts_unix.go | WithNoPivotRoot | func WithNoPivotRoot(_ context.Context, _ *Client, ti *TaskInfo) error {
if CheckRuntime(ti.Runtime(), "io.containerd.runc") {
if ti.Options == nil {
ti.Options = &options.Options{}
}
opts, ok := ti.Options.(*options.Options)
if !ok {
return errors.New("invalid v2 shim create options format")
}
opts.... | go | func WithNoPivotRoot(_ context.Context, _ *Client, ti *TaskInfo) error {
if CheckRuntime(ti.Runtime(), "io.containerd.runc") {
if ti.Options == nil {
ti.Options = &options.Options{}
}
opts, ok := ti.Options.(*options.Options)
if !ok {
return errors.New("invalid v2 shim create options format")
}
opts.... | [
"func",
"WithNoPivotRoot",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"*",
"Client",
",",
"ti",
"*",
"TaskInfo",
")",
"error",
"{",
"if",
"CheckRuntime",
"(",
"ti",
".",
"Runtime",
"(",
")",
",",
"\"",
"\"",
")",
"{",
"if",
"ti",
".",
"Options"... | // WithNoPivotRoot instructs the runtime not to you pivot_root | [
"WithNoPivotRoot",
"instructs",
"the",
"runtime",
"not",
"to",
"you",
"pivot_root"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/task_opts_unix.go#L55-L79 |
130,459 | containerd/containerd | runtime/v2/logging/logging.go | Run | func Run(fn LoggerFunc) {
ctx, cancel := context.WithCancel(context.Background())
config := &Config{
ID: os.Getenv("CONTAINER_ID"),
Namespace: os.Getenv("CONTAINER_NAMESPACE"),
Stdout: os.NewFile(3, "CONTAINER_STDOUT"),
Stderr: os.NewFile(4, "CONTAINER_STDERR"),
}
var (
s = make(chan os.S... | go | func Run(fn LoggerFunc) {
ctx, cancel := context.WithCancel(context.Background())
config := &Config{
ID: os.Getenv("CONTAINER_ID"),
Namespace: os.Getenv("CONTAINER_NAMESPACE"),
Stdout: os.NewFile(3, "CONTAINER_STDOUT"),
Stderr: os.NewFile(4, "CONTAINER_STDERR"),
}
var (
s = make(chan os.S... | [
"func",
"Run",
"(",
"fn",
"LoggerFunc",
")",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"context",
".",
"Background",
"(",
")",
")",
"\n",
"config",
":=",
"&",
"Config",
"{",
"ID",
":",
"os",
".",
"Getenv",
"(",
"\"",
"\"",... | // Run the logging driver | [
"Run",
"the",
"logging",
"driver"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/logging/logging.go#L43-L77 |
130,460 | containerd/containerd | cio/io_windows.go | NewFIFOSetInDir | func NewFIFOSetInDir(_, id string, terminal bool) (*FIFOSet, error) {
stderrPipe := ""
if !terminal {
stderrPipe = fmt.Sprintf(`%s\ctr-%s-stderr`, pipeRoot, id)
}
return NewFIFOSet(Config{
Terminal: terminal,
Stdin: fmt.Sprintf(`%s\ctr-%s-stdin`, pipeRoot, id),
Stdout: fmt.Sprintf(`%s\ctr-%s-stdout`, p... | go | func NewFIFOSetInDir(_, id string, terminal bool) (*FIFOSet, error) {
stderrPipe := ""
if !terminal {
stderrPipe = fmt.Sprintf(`%s\ctr-%s-stderr`, pipeRoot, id)
}
return NewFIFOSet(Config{
Terminal: terminal,
Stdin: fmt.Sprintf(`%s\ctr-%s-stdin`, pipeRoot, id),
Stdout: fmt.Sprintf(`%s\ctr-%s-stdout`, p... | [
"func",
"NewFIFOSetInDir",
"(",
"_",
",",
"id",
"string",
",",
"terminal",
"bool",
")",
"(",
"*",
"FIFOSet",
",",
"error",
")",
"{",
"stderrPipe",
":=",
"\"",
"\"",
"\n",
"if",
"!",
"terminal",
"{",
"stderrPipe",
"=",
"fmt",
".",
"Sprintf",
"(",
"`%s... | // NewFIFOSetInDir returns a new set of fifos for the task | [
"NewFIFOSetInDir",
"returns",
"a",
"new",
"set",
"of",
"fifos",
"for",
"the",
"task"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/cio/io_windows.go#L33-L44 |
130,461 | containerd/containerd | cio/io_windows.go | NewDirectIOFromFIFOSet | func NewDirectIOFromFIFOSet(ctx context.Context, stdin io.WriteCloser, stdout, stderr io.ReadCloser, fifos *FIFOSet) *DirectIO {
_, cancel := context.WithCancel(ctx)
pipes := pipes{
Stdin: stdin,
Stdout: stdout,
Stderr: stderr,
}
return &DirectIO{
pipes: pipes,
cio: cio{
config: fifos.Config,
clos... | go | func NewDirectIOFromFIFOSet(ctx context.Context, stdin io.WriteCloser, stdout, stderr io.ReadCloser, fifos *FIFOSet) *DirectIO {
_, cancel := context.WithCancel(ctx)
pipes := pipes{
Stdin: stdin,
Stdout: stdout,
Stderr: stderr,
}
return &DirectIO{
pipes: pipes,
cio: cio{
config: fifos.Config,
clos... | [
"func",
"NewDirectIOFromFIFOSet",
"(",
"ctx",
"context",
".",
"Context",
",",
"stdin",
"io",
".",
"WriteCloser",
",",
"stdout",
",",
"stderr",
"io",
".",
"ReadCloser",
",",
"fifos",
"*",
"FIFOSet",
")",
"*",
"DirectIO",
"{",
"_",
",",
"cancel",
":=",
"co... | // NewDirectIOFromFIFOSet returns an IO implementation that exposes the IO streams as io.ReadCloser
// and io.WriteCloser. | [
"NewDirectIOFromFIFOSet",
"returns",
"an",
"IO",
"implementation",
"that",
"exposes",
"the",
"IO",
"streams",
"as",
"io",
".",
"ReadCloser",
"and",
"io",
".",
"WriteCloser",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/cio/io_windows.go#L155-L170 |
130,462 | containerd/containerd | runtime/v1/linux/task.go | Delete | func (t *Task) Delete(ctx context.Context) (*runtime.Exit, error) {
rsp, err := t.shim.Delete(ctx, empty)
if err != nil {
return nil, errdefs.FromGRPC(err)
}
t.tasks.Delete(ctx, t.id)
if err := t.shim.KillShim(ctx); err != nil {
log.G(ctx).WithError(err).Error("failed to kill shim")
}
if err := t.bundle.Dele... | go | func (t *Task) Delete(ctx context.Context) (*runtime.Exit, error) {
rsp, err := t.shim.Delete(ctx, empty)
if err != nil {
return nil, errdefs.FromGRPC(err)
}
t.tasks.Delete(ctx, t.id)
if err := t.shim.KillShim(ctx); err != nil {
log.G(ctx).WithError(err).Error("failed to kill shim")
}
if err := t.bundle.Dele... | [
"func",
"(",
"t",
"*",
"Task",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"runtime",
".",
"Exit",
",",
"error",
")",
"{",
"rsp",
",",
"err",
":=",
"t",
".",
"shim",
".",
"Delete",
"(",
"ctx",
",",
"empty",
")",
"\n",
... | // Delete the task and return the exit status | [
"Delete",
"the",
"task",
"and",
"return",
"the",
"exit",
"status"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L88-L111 |
130,463 | containerd/containerd | runtime/v1/linux/task.go | Start | func (t *Task) Start(ctx context.Context) error {
t.mu.Lock()
hasCgroup := t.cg != nil
t.mu.Unlock()
r, err := t.shim.Start(ctx, &shim.StartRequest{
ID: t.id,
})
if err != nil {
return errdefs.FromGRPC(err)
}
t.pid = int(r.Pid)
if !hasCgroup {
cg, err := cgroups.Load(cgroups.V1, cgroups.PidPath(t.pid))
... | go | func (t *Task) Start(ctx context.Context) error {
t.mu.Lock()
hasCgroup := t.cg != nil
t.mu.Unlock()
r, err := t.shim.Start(ctx, &shim.StartRequest{
ID: t.id,
})
if err != nil {
return errdefs.FromGRPC(err)
}
t.pid = int(r.Pid)
if !hasCgroup {
cg, err := cgroups.Load(cgroups.V1, cgroups.PidPath(t.pid))
... | [
"func",
"(",
"t",
"*",
"Task",
")",
"Start",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"t",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"hasCgroup",
":=",
"t",
".",
"cg",
"!=",
"nil",
"\n",
"t",
".",
"mu",
".",
"Unlock",
"(",
")",... | // Start the task | [
"Start",
"the",
"task"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L114-L139 |
130,464 | containerd/containerd | runtime/v1/linux/task.go | Pause | func (t *Task) Pause(ctx context.Context) error {
if _, err := t.shim.Pause(ctx, empty); err != nil {
return errdefs.FromGRPC(err)
}
t.events.Publish(ctx, runtime.TaskPausedEventTopic, &eventstypes.TaskPaused{
ContainerID: t.id,
})
return nil
} | go | func (t *Task) Pause(ctx context.Context) error {
if _, err := t.shim.Pause(ctx, empty); err != nil {
return errdefs.FromGRPC(err)
}
t.events.Publish(ctx, runtime.TaskPausedEventTopic, &eventstypes.TaskPaused{
ContainerID: t.id,
})
return nil
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"Pause",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"t",
".",
"shim",
".",
"Pause",
"(",
"ctx",
",",
"empty",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errdefs"... | // Pause the task and all processes | [
"Pause",
"the",
"task",
"and",
"all",
"processes"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L178-L186 |
130,465 | containerd/containerd | runtime/v1/linux/task.go | Resume | func (t *Task) Resume(ctx context.Context) error {
if _, err := t.shim.Resume(ctx, empty); err != nil {
return errdefs.FromGRPC(err)
}
t.events.Publish(ctx, runtime.TaskResumedEventTopic, &eventstypes.TaskResumed{
ContainerID: t.id,
})
return nil
} | go | func (t *Task) Resume(ctx context.Context) error {
if _, err := t.shim.Resume(ctx, empty); err != nil {
return errdefs.FromGRPC(err)
}
t.events.Publish(ctx, runtime.TaskResumedEventTopic, &eventstypes.TaskResumed{
ContainerID: t.id,
})
return nil
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"Resume",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"t",
".",
"shim",
".",
"Resume",
"(",
"ctx",
",",
"empty",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errdef... | // Resume the task and all processes | [
"Resume",
"the",
"task",
"and",
"all",
"processes"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L189-L197 |
130,466 | containerd/containerd | runtime/v1/linux/task.go | Kill | func (t *Task) Kill(ctx context.Context, signal uint32, all bool) error {
if _, err := t.shim.Kill(ctx, &shim.KillRequest{
ID: t.id,
Signal: signal,
All: all,
}); err != nil {
return errdefs.FromGRPC(err)
}
return nil
} | go | func (t *Task) Kill(ctx context.Context, signal uint32, all bool) error {
if _, err := t.shim.Kill(ctx, &shim.KillRequest{
ID: t.id,
Signal: signal,
All: all,
}); err != nil {
return errdefs.FromGRPC(err)
}
return nil
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"Kill",
"(",
"ctx",
"context",
".",
"Context",
",",
"signal",
"uint32",
",",
"all",
"bool",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"t",
".",
"shim",
".",
"Kill",
"(",
"ctx",
",",
"&",
"shim",
".",
... | // Kill the task using the provided signal
//
// Optionally send the signal to all processes that are a child of the task | [
"Kill",
"the",
"task",
"using",
"the",
"provided",
"signal",
"Optionally",
"send",
"the",
"signal",
"to",
"all",
"processes",
"that",
"are",
"a",
"child",
"of",
"the",
"task"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L202-L211 |
130,467 | containerd/containerd | runtime/v1/linux/task.go | Pids | func (t *Task) Pids(ctx context.Context) ([]runtime.ProcessInfo, error) {
resp, err := t.shim.ListPids(ctx, &shim.ListPidsRequest{
ID: t.id,
})
if err != nil {
return nil, errdefs.FromGRPC(err)
}
var processList []runtime.ProcessInfo
for _, p := range resp.Processes {
processList = append(processList, runti... | go | func (t *Task) Pids(ctx context.Context) ([]runtime.ProcessInfo, error) {
resp, err := t.shim.ListPids(ctx, &shim.ListPidsRequest{
ID: t.id,
})
if err != nil {
return nil, errdefs.FromGRPC(err)
}
var processList []runtime.ProcessInfo
for _, p := range resp.Processes {
processList = append(processList, runti... | [
"func",
"(",
"t",
"*",
"Task",
")",
"Pids",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"runtime",
".",
"ProcessInfo",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"t",
".",
"shim",
".",
"ListPids",
"(",
"ctx",
",",
"&",
"sh... | // Pids returns all system level process ids running inside the task | [
"Pids",
"returns",
"all",
"system",
"level",
"process",
"ids",
"running",
"inside",
"the",
"task"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L236-L251 |
130,468 | containerd/containerd | runtime/v1/linux/task.go | CloseIO | func (t *Task) CloseIO(ctx context.Context) error {
_, err := t.shim.CloseIO(ctx, &shim.CloseIORequest{
ID: t.id,
Stdin: true,
})
if err != nil {
err = errdefs.FromGRPC(err)
}
return err
} | go | func (t *Task) CloseIO(ctx context.Context) error {
_, err := t.shim.CloseIO(ctx, &shim.CloseIORequest{
ID: t.id,
Stdin: true,
})
if err != nil {
err = errdefs.FromGRPC(err)
}
return err
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"CloseIO",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"_",
",",
"err",
":=",
"t",
".",
"shim",
".",
"CloseIO",
"(",
"ctx",
",",
"&",
"shim",
".",
"CloseIORequest",
"{",
"ID",
":",
"t",
".",
"id... | // CloseIO closes the provided IO on the task | [
"CloseIO",
"closes",
"the",
"provided",
"IO",
"on",
"the",
"task"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L267-L276 |
130,469 | containerd/containerd | runtime/v1/linux/task.go | Checkpoint | func (t *Task) Checkpoint(ctx context.Context, path string, options *types.Any) error {
r := &shim.CheckpointTaskRequest{
Path: path,
Options: options,
}
if _, err := t.shim.Checkpoint(ctx, r); err != nil {
return errdefs.FromGRPC(err)
}
t.events.Publish(ctx, runtime.TaskCheckpointedEventTopic, &eventstyp... | go | func (t *Task) Checkpoint(ctx context.Context, path string, options *types.Any) error {
r := &shim.CheckpointTaskRequest{
Path: path,
Options: options,
}
if _, err := t.shim.Checkpoint(ctx, r); err != nil {
return errdefs.FromGRPC(err)
}
t.events.Publish(ctx, runtime.TaskCheckpointedEventTopic, &eventstyp... | [
"func",
"(",
"t",
"*",
"Task",
")",
"Checkpoint",
"(",
"ctx",
"context",
".",
"Context",
",",
"path",
"string",
",",
"options",
"*",
"types",
".",
"Any",
")",
"error",
"{",
"r",
":=",
"&",
"shim",
".",
"CheckpointTaskRequest",
"{",
"Path",
":",
"path... | // Checkpoint creates a system level dump of the task and process information that can be later restored | [
"Checkpoint",
"creates",
"a",
"system",
"level",
"dump",
"of",
"the",
"task",
"and",
"process",
"information",
"that",
"can",
"be",
"later",
"restored"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L279-L291 |
130,470 | containerd/containerd | runtime/v1/linux/task.go | Update | func (t *Task) Update(ctx context.Context, resources *types.Any) error {
if _, err := t.shim.Update(ctx, &shim.UpdateTaskRequest{
Resources: resources,
}); err != nil {
return errdefs.FromGRPC(err)
}
return nil
} | go | func (t *Task) Update(ctx context.Context, resources *types.Any) error {
if _, err := t.shim.Update(ctx, &shim.UpdateTaskRequest{
Resources: resources,
}); err != nil {
return errdefs.FromGRPC(err)
}
return nil
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"resources",
"*",
"types",
".",
"Any",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"t",
".",
"shim",
".",
"Update",
"(",
"ctx",
",",
"&",
"shim",
".",... | // Update changes runtime information of a running task | [
"Update",
"changes",
"runtime",
"information",
"of",
"a",
"running",
"task"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L294-L301 |
130,471 | containerd/containerd | runtime/v1/linux/task.go | Process | func (t *Task) Process(ctx context.Context, id string) (runtime.Process, error) {
p := &Process{
id: id,
t: t,
}
if _, err := p.State(ctx); err != nil {
return nil, err
}
return p, nil
} | go | func (t *Task) Process(ctx context.Context, id string) (runtime.Process, error) {
p := &Process{
id: id,
t: t,
}
if _, err := p.State(ctx); err != nil {
return nil, err
}
return p, nil
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"Process",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"(",
"runtime",
".",
"Process",
",",
"error",
")",
"{",
"p",
":=",
"&",
"Process",
"{",
"id",
":",
"id",
",",
"t",
":",
"t",
",",
... | // Process returns a specific process inside the task by the process id | [
"Process",
"returns",
"a",
"specific",
"process",
"inside",
"the",
"task",
"by",
"the",
"process",
"id"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L304-L313 |
130,472 | containerd/containerd | runtime/v1/linux/task.go | Stats | func (t *Task) Stats(ctx context.Context) (*types.Any, error) {
t.mu.Lock()
defer t.mu.Unlock()
if t.cg == nil {
return nil, errors.Wrap(errdefs.ErrNotFound, "cgroup does not exist")
}
stats, err := t.cg.Stat(cgroups.IgnoreNotExist)
if err != nil {
return nil, err
}
return typeurl.MarshalAny(stats)
} | go | func (t *Task) Stats(ctx context.Context) (*types.Any, error) {
t.mu.Lock()
defer t.mu.Unlock()
if t.cg == nil {
return nil, errors.Wrap(errdefs.ErrNotFound, "cgroup does not exist")
}
stats, err := t.cg.Stat(cgroups.IgnoreNotExist)
if err != nil {
return nil, err
}
return typeurl.MarshalAny(stats)
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"Stats",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"types",
".",
"Any",
",",
"error",
")",
"{",
"t",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"mu",
".",
"Unlock",
"(",
")",
"... | // Stats returns runtime specific system level metric information for the task | [
"Stats",
"returns",
"runtime",
"specific",
"system",
"level",
"metric",
"information",
"for",
"the",
"task"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L316-L327 |
130,473 | containerd/containerd | runtime/v1/linux/task.go | Cgroup | func (t *Task) Cgroup() (cgroups.Cgroup, error) {
t.mu.Lock()
defer t.mu.Unlock()
if t.cg == nil {
return nil, errors.Wrap(errdefs.ErrNotFound, "cgroup does not exist")
}
return t.cg, nil
} | go | func (t *Task) Cgroup() (cgroups.Cgroup, error) {
t.mu.Lock()
defer t.mu.Unlock()
if t.cg == nil {
return nil, errors.Wrap(errdefs.ErrNotFound, "cgroup does not exist")
}
return t.cg, nil
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"Cgroup",
"(",
")",
"(",
"cgroups",
".",
"Cgroup",
",",
"error",
")",
"{",
"t",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"t",
".",
"cg",
"==",
... | // Cgroup returns the underlying cgroup for a linux task | [
"Cgroup",
"returns",
"the",
"underlying",
"cgroup",
"for",
"a",
"linux",
"task"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L330-L337 |
130,474 | containerd/containerd | runtime/v1/linux/task.go | Wait | func (t *Task) Wait(ctx context.Context) (*runtime.Exit, error) {
r, err := t.shim.Wait(ctx, &shim.WaitRequest{
ID: t.id,
})
if err != nil {
return nil, err
}
return &runtime.Exit{
Timestamp: r.ExitedAt,
Status: r.ExitStatus,
}, nil
} | go | func (t *Task) Wait(ctx context.Context) (*runtime.Exit, error) {
r, err := t.shim.Wait(ctx, &shim.WaitRequest{
ID: t.id,
})
if err != nil {
return nil, err
}
return &runtime.Exit{
Timestamp: r.ExitedAt,
Status: r.ExitStatus,
}, nil
} | [
"func",
"(",
"t",
"*",
"Task",
")",
"Wait",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"runtime",
".",
"Exit",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"t",
".",
"shim",
".",
"Wait",
"(",
"ctx",
",",
"&",
"shim",
".",
"WaitRe... | // Wait for the task to exit returning the status and timestamp | [
"Wait",
"for",
"the",
"task",
"to",
"exit",
"returning",
"the",
"status",
"and",
"timestamp"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/task.go#L340-L351 |
130,475 | containerd/containerd | runtime/v1/linux/proc/io.go | isFifo | func isFifo(path string) (bool, error) {
stat, err := os.Stat(path)
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
if stat.Mode()&os.ModeNamedPipe == os.ModeNamedPipe {
return true, nil
}
return false, nil
} | go | func isFifo(path string) (bool, error) {
stat, err := os.Stat(path)
if err != nil {
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
if stat.Mode()&os.ModeNamedPipe == os.ModeNamedPipe {
return true, nil
}
return false, nil
} | [
"func",
"isFifo",
"(",
"path",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"stat",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"return"... | // isFifo checks if a file is a fifo
// if the file does not exist then it returns false | [
"isFifo",
"checks",
"if",
"a",
"file",
"is",
"a",
"fifo",
"if",
"the",
"file",
"does",
"not",
"exist",
"then",
"it",
"returns",
"false"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/proc/io.go#L240-L252 |
130,476 | containerd/containerd | services/server/config/config.go | Validate | func (bc *BoltConfig) Validate() error {
switch bc.ContentSharingPolicy {
case SharingPolicyShared, SharingPolicyIsolated:
return nil
default:
return errors.Wrapf(errdefs.ErrInvalidArgument, "unknown policy: %s", bc.ContentSharingPolicy)
}
} | go | func (bc *BoltConfig) Validate() error {
switch bc.ContentSharingPolicy {
case SharingPolicyShared, SharingPolicyIsolated:
return nil
default:
return errors.Wrapf(errdefs.ErrInvalidArgument, "unknown policy: %s", bc.ContentSharingPolicy)
}
} | [
"func",
"(",
"bc",
"*",
"BoltConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"switch",
"bc",
".",
"ContentSharingPolicy",
"{",
"case",
"SharingPolicyShared",
",",
"SharingPolicyIsolated",
":",
"return",
"nil",
"\n",
"default",
":",
"return",
"errors",
".",
... | // Validate validates if BoltConfig is valid | [
"Validate",
"validates",
"if",
"BoltConfig",
"is",
"valid"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/services/server/config/config.go#L123-L130 |
130,477 | containerd/containerd | services/server/config/config.go | Decode | func (c *Config) Decode(id string, v interface{}) (interface{}, error) {
data, ok := c.Plugins[id]
if !ok {
return v, nil
}
if err := c.md.PrimitiveDecode(data, v); err != nil {
return nil, err
}
return v, nil
} | go | func (c *Config) Decode(id string, v interface{}) (interface{}, error) {
data, ok := c.Plugins[id]
if !ok {
return v, nil
}
if err := c.md.PrimitiveDecode(data, v); err != nil {
return nil, err
}
return v, nil
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"Decode",
"(",
"id",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"data",
",",
"ok",
":=",
"c",
".",
"Plugins",
"[",
"id",
"]",
"\n",
"if",
"!",
"ok"... | // Decode unmarshals a plugin specific configuration by plugin id | [
"Decode",
"unmarshals",
"a",
"plugin",
"specific",
"configuration",
"by",
"plugin",
"id"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/services/server/config/config.go#L133-L142 |
130,478 | containerd/containerd | services/server/config/config.go | LoadConfig | func LoadConfig(path string, v *Config) error {
if v == nil {
return errors.Wrapf(errdefs.ErrInvalidArgument, "argument v must not be nil")
}
md, err := toml.DecodeFile(path, v)
if err != nil {
return err
}
v.md = md
return nil
} | go | func LoadConfig(path string, v *Config) error {
if v == nil {
return errors.Wrapf(errdefs.ErrInvalidArgument, "argument v must not be nil")
}
md, err := toml.DecodeFile(path, v)
if err != nil {
return err
}
v.md = md
return nil
} | [
"func",
"LoadConfig",
"(",
"path",
"string",
",",
"v",
"*",
"Config",
")",
"error",
"{",
"if",
"v",
"==",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"errdefs",
".",
"ErrInvalidArgument",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"md",
",",
"er... | // LoadConfig loads the containerd server config from the provided path | [
"LoadConfig",
"loads",
"the",
"containerd",
"server",
"config",
"from",
"the",
"provided",
"path"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/services/server/config/config.go#L145-L155 |
130,479 | containerd/containerd | pkg/progress/bar.go | Format | func (h Bar) Format(state fmt.State, r rune) {
switch r {
case 'r':
default:
panic(fmt.Sprintf("%v: unexpected format character", float64(h)))
}
if h > 1.0 {
h = 1.0
}
if h < 0.0 {
h = 0.0
}
if state.Flag('-') {
h = 1.0 - h
}
width, ok := state.Width()
if !ok {
// default width of 40
width =... | go | func (h Bar) Format(state fmt.State, r rune) {
switch r {
case 'r':
default:
panic(fmt.Sprintf("%v: unexpected format character", float64(h)))
}
if h > 1.0 {
h = 1.0
}
if h < 0.0 {
h = 0.0
}
if state.Flag('-') {
h = 1.0 - h
}
width, ok := state.Width()
if !ok {
// default width of 40
width =... | [
"func",
"(",
"h",
"Bar",
")",
"Format",
"(",
"state",
"fmt",
".",
"State",
",",
"r",
"rune",
")",
"{",
"switch",
"r",
"{",
"case",
"'r'",
":",
"default",
":",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"float64",
"(",
"h",
")",
... | // Format the progress bar as output | [
"Format",
"the",
"progress",
"bar",
"as",
"output"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/pkg/progress/bar.go#L36-L82 |
130,480 | containerd/containerd | platforms/platforms.go | MustParse | func MustParse(specifier string) specs.Platform {
p, err := Parse(specifier)
if err != nil {
panic("platform: Parse(" + strconv.Quote(specifier) + "): " + err.Error())
}
return p
} | go | func MustParse(specifier string) specs.Platform {
p, err := Parse(specifier)
if err != nil {
panic("platform: Parse(" + strconv.Quote(specifier) + "): " + err.Error())
}
return p
} | [
"func",
"MustParse",
"(",
"specifier",
"string",
")",
"specs",
".",
"Platform",
"{",
"p",
",",
"err",
":=",
"Parse",
"(",
"specifier",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"strconv",
".",
"Quote",
"(",
"specifier",... | // MustParse is like Parses but panics if the specifier cannot be parsed.
// Simplifies initialization of global variables. | [
"MustParse",
"is",
"like",
"Parses",
"but",
"panics",
"if",
"the",
"specifier",
"cannot",
"be",
"parsed",
".",
"Simplifies",
"initialization",
"of",
"global",
"variables",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/platforms/platforms.go#L236-L242 |
130,481 | containerd/containerd | platforms/platforms.go | Format | func Format(platform specs.Platform) string {
if platform.OS == "" {
return "unknown"
}
return joinNotEmpty(platform.OS, platform.Architecture, platform.Variant)
} | go | func Format(platform specs.Platform) string {
if platform.OS == "" {
return "unknown"
}
return joinNotEmpty(platform.OS, platform.Architecture, platform.Variant)
} | [
"func",
"Format",
"(",
"platform",
"specs",
".",
"Platform",
")",
"string",
"{",
"if",
"platform",
".",
"OS",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"joinNotEmpty",
"(",
"platform",
".",
"OS",
",",
"platform",
".",
... | // Format returns a string specifier from the provided platform specification. | [
"Format",
"returns",
"a",
"string",
"specifier",
"from",
"the",
"provided",
"platform",
"specification",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/platforms/platforms.go#L245-L251 |
130,482 | containerd/containerd | platforms/platforms.go | Normalize | func Normalize(platform specs.Platform) specs.Platform {
platform.OS = normalizeOS(platform.OS)
platform.Architecture, platform.Variant = normalizeArch(platform.Architecture, platform.Variant)
// these fields are deprecated, remove them
platform.OSFeatures = nil
platform.OSVersion = ""
return platform
} | go | func Normalize(platform specs.Platform) specs.Platform {
platform.OS = normalizeOS(platform.OS)
platform.Architecture, platform.Variant = normalizeArch(platform.Architecture, platform.Variant)
// these fields are deprecated, remove them
platform.OSFeatures = nil
platform.OSVersion = ""
return platform
} | [
"func",
"Normalize",
"(",
"platform",
"specs",
".",
"Platform",
")",
"specs",
".",
"Platform",
"{",
"platform",
".",
"OS",
"=",
"normalizeOS",
"(",
"platform",
".",
"OS",
")",
"\n",
"platform",
".",
"Architecture",
",",
"platform",
".",
"Variant",
"=",
"... | // Normalize validates and translate the platform to the canonical value.
//
// For example, if "Aarch64" is encountered, we change it to "arm64" or if
// "x86_64" is encountered, it becomes "amd64". | [
"Normalize",
"validates",
"and",
"translate",
"the",
"platform",
"to",
"the",
"canonical",
"value",
".",
"For",
"example",
"if",
"Aarch64",
"is",
"encountered",
"we",
"change",
"it",
"to",
"arm64",
"or",
"if",
"x86_64",
"is",
"encountered",
"it",
"becomes",
... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/platforms/platforms.go#L270-L279 |
130,483 | containerd/containerd | runtime/proc/proc.go | IsNull | func (s Stdio) IsNull() bool {
return s.Stdin == "" && s.Stdout == "" && s.Stderr == ""
} | go | func (s Stdio) IsNull() bool {
return s.Stdin == "" && s.Stdout == "" && s.Stderr == ""
} | [
"func",
"(",
"s",
"Stdio",
")",
"IsNull",
"(",
")",
"bool",
"{",
"return",
"s",
".",
"Stdin",
"==",
"\"",
"\"",
"&&",
"s",
".",
"Stdout",
"==",
"\"",
"\"",
"&&",
"s",
".",
"Stderr",
"==",
"\"",
"\"",
"\n",
"}"
] | // IsNull returns true if the stdio is not defined | [
"IsNull",
"returns",
"true",
"if",
"the",
"stdio",
"is",
"not",
"defined"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/proc/proc.go#L37-L39 |
130,484 | containerd/containerd | cmd/containerd/command/service_windows.go | serviceFlags | func serviceFlags() []cli.Flag {
return []cli.Flag{
cli.StringFlag{
Name: "service-name",
Usage: "Set the Windows service name",
Value: "containerd",
},
cli.BoolFlag{
Name: "register-service",
Usage: "Register the service and exit",
},
cli.BoolFlag{
Name: "unregister-service",
Usage: ... | go | func serviceFlags() []cli.Flag {
return []cli.Flag{
cli.StringFlag{
Name: "service-name",
Usage: "Set the Windows service name",
Value: "containerd",
},
cli.BoolFlag{
Name: "register-service",
Usage: "Register the service and exit",
},
cli.BoolFlag{
Name: "unregister-service",
Usage: ... | [
"func",
"serviceFlags",
"(",
")",
"[",
"]",
"cli",
".",
"Flag",
"{",
"return",
"[",
"]",
"cli",
".",
"Flag",
"{",
"cli",
".",
"StringFlag",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"\"",
",",
"Value",
":",
"\"",
"\"",
",",
"}",
... | // serviceFlags returns an array of flags for configuring containerd to run
// as a Windows service under control of SCM. | [
"serviceFlags",
"returns",
"an",
"array",
"of",
"flags",
"for",
"configuring",
"containerd",
"to",
"run",
"as",
"a",
"Windows",
"service",
"under",
"control",
"of",
"SCM",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/cmd/containerd/command/service_windows.go#L68-L89 |
130,485 | containerd/containerd | cmd/containerd/command/service_windows.go | applyPlatformFlags | func applyPlatformFlags(context *cli.Context) {
if s := context.GlobalString("service-name"); s != "" {
serviceNameFlag = s
}
for _, v := range []struct {
name string
d *bool
}{
{
name: "register-service",
d: ®isterServiceFlag,
},
{
name: "unregister-service",
d: &unregisterServ... | go | func applyPlatformFlags(context *cli.Context) {
if s := context.GlobalString("service-name"); s != "" {
serviceNameFlag = s
}
for _, v := range []struct {
name string
d *bool
}{
{
name: "register-service",
d: ®isterServiceFlag,
},
{
name: "unregister-service",
d: &unregisterServ... | [
"func",
"applyPlatformFlags",
"(",
"context",
"*",
"cli",
".",
"Context",
")",
"{",
"if",
"s",
":=",
"context",
".",
"GlobalString",
"(",
"\"",
"\"",
")",
";",
"s",
"!=",
"\"",
"\"",
"{",
"serviceNameFlag",
"=",
"s",
"\n",
"}",
"\n",
"for",
"_",
",... | // applyPlatformFlags applies platform-specific flags. | [
"applyPlatformFlags",
"applies",
"platform",
"-",
"specific",
"flags",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/cmd/containerd/command/service_windows.go#L92-L116 |
130,486 | containerd/containerd | cmd/containerd/command/service_windows.go | launchService | func launchService(s *server.Server, done chan struct{}) error {
if !runServiceFlag {
return nil
}
h := &handler{
fromsvc: make(chan error),
s: s,
done: done,
}
interactive, err := svc.IsAnInteractiveSession()
if err != nil {
return err
}
service = h
go func() {
if interactive {
err... | go | func launchService(s *server.Server, done chan struct{}) error {
if !runServiceFlag {
return nil
}
h := &handler{
fromsvc: make(chan error),
s: s,
done: done,
}
interactive, err := svc.IsAnInteractiveSession()
if err != nil {
return err
}
service = h
go func() {
if interactive {
err... | [
"func",
"launchService",
"(",
"s",
"*",
"server",
".",
"Server",
",",
"done",
"chan",
"struct",
"{",
"}",
")",
"error",
"{",
"if",
"!",
"runServiceFlag",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"h",
":=",
"&",
"handler",
"{",
"fromsvc",
":",
"make",... | // launchService is the entry point for running the daemon under SCM. | [
"launchService",
"is",
"the",
"entry",
"point",
"for",
"running",
"the",
"daemon",
"under",
"SCM",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/cmd/containerd/command/service_windows.go#L349-L382 |
130,487 | containerd/containerd | runtime/v1/linux/bundle.go | loadBundle | func loadBundle(id, path, workdir string) *bundle {
return &bundle{
id: id,
path: path,
workDir: workdir,
}
} | go | func loadBundle(id, path, workdir string) *bundle {
return &bundle{
id: id,
path: path,
workDir: workdir,
}
} | [
"func",
"loadBundle",
"(",
"id",
",",
"path",
",",
"workdir",
"string",
")",
"*",
"bundle",
"{",
"return",
"&",
"bundle",
"{",
"id",
":",
"id",
",",
"path",
":",
"path",
",",
"workDir",
":",
"workdir",
",",
"}",
"\n",
"}"
] | // loadBundle loads an existing bundle from disk | [
"loadBundle",
"loads",
"an",
"existing",
"bundle",
"from",
"disk"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/bundle.go#L37-L43 |
130,488 | containerd/containerd | runtime/v1/linux/bundle.go | newBundle | func newBundle(id, path, workDir string, spec []byte) (b *bundle, err error) {
if err := os.MkdirAll(path, 0711); err != nil {
return nil, err
}
path = filepath.Join(path, id)
if err := os.Mkdir(path, 0711); err != nil {
return nil, err
}
defer func() {
if err != nil {
os.RemoveAll(path)
}
}()
workDi... | go | func newBundle(id, path, workDir string, spec []byte) (b *bundle, err error) {
if err := os.MkdirAll(path, 0711); err != nil {
return nil, err
}
path = filepath.Join(path, id)
if err := os.Mkdir(path, 0711); err != nil {
return nil, err
}
defer func() {
if err != nil {
os.RemoveAll(path)
}
}()
workDi... | [
"func",
"newBundle",
"(",
"id",
",",
"path",
",",
"workDir",
"string",
",",
"spec",
"[",
"]",
"byte",
")",
"(",
"b",
"*",
"bundle",
",",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"path",
",",
"0711",
")",
";",
"er... | // newBundle creates a new bundle on disk at the provided path for the given id | [
"newBundle",
"creates",
"a",
"new",
"bundle",
"on",
"disk",
"at",
"the",
"provided",
"path",
"for",
"the",
"given",
"id"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/bundle.go#L46-L77 |
130,489 | containerd/containerd | runtime/v1/linux/bundle.go | ShimRemote | func ShimRemote(c *Config, daemonAddress, cgroup string, exitHandler func()) ShimOpt {
return func(b *bundle, ns string, ropts *runctypes.RuncOptions) (shim.Config, client.Opt) {
config := b.shimConfig(ns, c, ropts)
return config,
client.WithStart(c.Shim, b.shimAddress(ns), daemonAddress, cgroup, c.ShimDebug, e... | go | func ShimRemote(c *Config, daemonAddress, cgroup string, exitHandler func()) ShimOpt {
return func(b *bundle, ns string, ropts *runctypes.RuncOptions) (shim.Config, client.Opt) {
config := b.shimConfig(ns, c, ropts)
return config,
client.WithStart(c.Shim, b.shimAddress(ns), daemonAddress, cgroup, c.ShimDebug, e... | [
"func",
"ShimRemote",
"(",
"c",
"*",
"Config",
",",
"daemonAddress",
",",
"cgroup",
"string",
",",
"exitHandler",
"func",
"(",
")",
")",
"ShimOpt",
"{",
"return",
"func",
"(",
"b",
"*",
"bundle",
",",
"ns",
"string",
",",
"ropts",
"*",
"runctypes",
"."... | // ShimRemote is a ShimOpt for connecting and starting a remote shim | [
"ShimRemote",
"is",
"a",
"ShimOpt",
"for",
"connecting",
"and",
"starting",
"a",
"remote",
"shim"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/bundle.go#L89-L95 |
130,490 | containerd/containerd | runtime/v1/linux/bundle.go | ShimLocal | func ShimLocal(c *Config, exchange *exchange.Exchange) ShimOpt {
return func(b *bundle, ns string, ropts *runctypes.RuncOptions) (shim.Config, client.Opt) {
return b.shimConfig(ns, c, ropts), client.WithLocal(exchange)
}
} | go | func ShimLocal(c *Config, exchange *exchange.Exchange) ShimOpt {
return func(b *bundle, ns string, ropts *runctypes.RuncOptions) (shim.Config, client.Opt) {
return b.shimConfig(ns, c, ropts), client.WithLocal(exchange)
}
} | [
"func",
"ShimLocal",
"(",
"c",
"*",
"Config",
",",
"exchange",
"*",
"exchange",
".",
"Exchange",
")",
"ShimOpt",
"{",
"return",
"func",
"(",
"b",
"*",
"bundle",
",",
"ns",
"string",
",",
"ropts",
"*",
"runctypes",
".",
"RuncOptions",
")",
"(",
"shim",
... | // ShimLocal is a ShimOpt for using an in process shim implementation | [
"ShimLocal",
"is",
"a",
"ShimOpt",
"for",
"using",
"an",
"in",
"process",
"shim",
"implementation"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/bundle.go#L98-L102 |
130,491 | containerd/containerd | runtime/v1/linux/bundle.go | ShimConnect | func ShimConnect(c *Config, onClose func()) ShimOpt {
return func(b *bundle, ns string, ropts *runctypes.RuncOptions) (shim.Config, client.Opt) {
return b.shimConfig(ns, c, ropts), client.WithConnect(b.decideShimAddress(ns), onClose)
}
} | go | func ShimConnect(c *Config, onClose func()) ShimOpt {
return func(b *bundle, ns string, ropts *runctypes.RuncOptions) (shim.Config, client.Opt) {
return b.shimConfig(ns, c, ropts), client.WithConnect(b.decideShimAddress(ns), onClose)
}
} | [
"func",
"ShimConnect",
"(",
"c",
"*",
"Config",
",",
"onClose",
"func",
"(",
")",
")",
"ShimOpt",
"{",
"return",
"func",
"(",
"b",
"*",
"bundle",
",",
"ns",
"string",
",",
"ropts",
"*",
"runctypes",
".",
"RuncOptions",
")",
"(",
"shim",
".",
"Config"... | // ShimConnect is a ShimOpt for connecting to an existing remote shim | [
"ShimConnect",
"is",
"a",
"ShimOpt",
"for",
"connecting",
"to",
"an",
"existing",
"remote",
"shim"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/bundle.go#L105-L109 |
130,492 | containerd/containerd | runtime/v1/linux/bundle.go | NewShimClient | func (b *bundle) NewShimClient(ctx context.Context, namespace string, getClientOpts ShimOpt, runcOpts *runctypes.RuncOptions) (*client.Client, error) {
cfg, opt := getClientOpts(b, namespace, runcOpts)
return client.New(ctx, cfg, opt)
} | go | func (b *bundle) NewShimClient(ctx context.Context, namespace string, getClientOpts ShimOpt, runcOpts *runctypes.RuncOptions) (*client.Client, error) {
cfg, opt := getClientOpts(b, namespace, runcOpts)
return client.New(ctx, cfg, opt)
} | [
"func",
"(",
"b",
"*",
"bundle",
")",
"NewShimClient",
"(",
"ctx",
"context",
".",
"Context",
",",
"namespace",
"string",
",",
"getClientOpts",
"ShimOpt",
",",
"runcOpts",
"*",
"runctypes",
".",
"RuncOptions",
")",
"(",
"*",
"client",
".",
"Client",
",",
... | // NewShimClient connects to the shim managing the bundle and tasks creating it if needed | [
"NewShimClient",
"connects",
"to",
"the",
"shim",
"managing",
"the",
"bundle",
"and",
"tasks",
"creating",
"it",
"if",
"needed"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/bundle.go#L112-L115 |
130,493 | containerd/containerd | runtime/v1/linux/bundle.go | Delete | func (b *bundle) Delete() error {
err := atomicDelete(b.path)
if err == nil {
return atomicDelete(b.workDir)
}
// error removing the bundle path; still attempt removing work dir
err2 := atomicDelete(b.workDir)
if err2 == nil {
return err
}
return errors.Wrapf(err, "Failed to remove both bundle and workdir l... | go | func (b *bundle) Delete() error {
err := atomicDelete(b.path)
if err == nil {
return atomicDelete(b.workDir)
}
// error removing the bundle path; still attempt removing work dir
err2 := atomicDelete(b.workDir)
if err2 == nil {
return err
}
return errors.Wrapf(err, "Failed to remove both bundle and workdir l... | [
"func",
"(",
"b",
"*",
"bundle",
")",
"Delete",
"(",
")",
"error",
"{",
"err",
":=",
"atomicDelete",
"(",
"b",
".",
"path",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"atomicDelete",
"(",
"b",
".",
"workDir",
")",
"\n",
"}",
"\n",
"// er... | // Delete deletes the bundle from disk | [
"Delete",
"deletes",
"the",
"bundle",
"from",
"disk"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v1/linux/bundle.go#L118-L129 |
130,494 | gocolly/colly | response.go | Save | func (r *Response) Save(fileName string) error {
return ioutil.WriteFile(fileName, r.Body, 0644)
} | go | func (r *Response) Save(fileName string) error {
return ioutil.WriteFile(fileName, r.Body, 0644)
} | [
"func",
"(",
"r",
"*",
"Response",
")",
"Save",
"(",
"fileName",
"string",
")",
"error",
"{",
"return",
"ioutil",
".",
"WriteFile",
"(",
"fileName",
",",
"r",
".",
"Body",
",",
"0644",
")",
"\n",
"}"
] | // Save writes response body to disk | [
"Save",
"writes",
"response",
"body",
"to",
"disk"
] | b3d99101c625896f85d94cee72ddfa49f0379d25 | https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/response.go#L44-L46 |
130,495 | gocolly/colly | response.go | FileName | func (r *Response) FileName() string {
_, params, err := mime.ParseMediaType(r.Headers.Get("Content-Disposition"))
if fName, ok := params["filename"]; ok && err == nil {
return SanitizeFileName(fName)
}
if r.Request.URL.RawQuery != "" {
return SanitizeFileName(fmt.Sprintf("%s_%s", r.Request.URL.Path, r.Request.... | go | func (r *Response) FileName() string {
_, params, err := mime.ParseMediaType(r.Headers.Get("Content-Disposition"))
if fName, ok := params["filename"]; ok && err == nil {
return SanitizeFileName(fName)
}
if r.Request.URL.RawQuery != "" {
return SanitizeFileName(fmt.Sprintf("%s_%s", r.Request.URL.Path, r.Request.... | [
"func",
"(",
"r",
"*",
"Response",
")",
"FileName",
"(",
")",
"string",
"{",
"_",
",",
"params",
",",
"err",
":=",
"mime",
".",
"ParseMediaType",
"(",
"r",
".",
"Headers",
".",
"Get",
"(",
"\"",
"\"",
")",
")",
"\n",
"if",
"fName",
",",
"ok",
"... | // FileName returns the sanitized file name parsed from "Content-Disposition"
// header or from URL | [
"FileName",
"returns",
"the",
"sanitized",
"file",
"name",
"parsed",
"from",
"Content",
"-",
"Disposition",
"header",
"or",
"from",
"URL"
] | b3d99101c625896f85d94cee72ddfa49f0379d25 | https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/response.go#L50-L59 |
130,496 | gocolly/colly | extensions/url_length_filter.go | URLLengthFilter | func URLLengthFilter(c *colly.Collector, URLLengthLimit int) {
c.OnRequest(func(r *colly.Request) {
if len(r.URL.String()) > URLLengthLimit {
r.Abort()
}
})
} | go | func URLLengthFilter(c *colly.Collector, URLLengthLimit int) {
c.OnRequest(func(r *colly.Request) {
if len(r.URL.String()) > URLLengthLimit {
r.Abort()
}
})
} | [
"func",
"URLLengthFilter",
"(",
"c",
"*",
"colly",
".",
"Collector",
",",
"URLLengthLimit",
"int",
")",
"{",
"c",
".",
"OnRequest",
"(",
"func",
"(",
"r",
"*",
"colly",
".",
"Request",
")",
"{",
"if",
"len",
"(",
"r",
".",
"URL",
".",
"String",
"("... | // URLLengthFilter filters out requests with URLs longer than URLLengthLimit | [
"URLLengthFilter",
"filters",
"out",
"requests",
"with",
"URLs",
"longer",
"than",
"URLLengthLimit"
] | b3d99101c625896f85d94cee72ddfa49f0379d25 | https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/extensions/url_length_filter.go#L8-L14 |
130,497 | gocolly/colly | queue/queue.go | New | func New(threads int, s Storage) (*Queue, error) {
if s == nil {
s = &InMemoryQueueStorage{MaxSize: 100000}
}
if err := s.Init(); err != nil {
return nil, err
}
return &Queue{
Threads: threads,
storage: s,
lock: &sync.Mutex{},
threadChans: make([]chan bool, 0, threads),
}, nil
} | go | func New(threads int, s Storage) (*Queue, error) {
if s == nil {
s = &InMemoryQueueStorage{MaxSize: 100000}
}
if err := s.Init(); err != nil {
return nil, err
}
return &Queue{
Threads: threads,
storage: s,
lock: &sync.Mutex{},
threadChans: make([]chan bool, 0, threads),
}, nil
} | [
"func",
"New",
"(",
"threads",
"int",
",",
"s",
"Storage",
")",
"(",
"*",
"Queue",
",",
"error",
")",
"{",
"if",
"s",
"==",
"nil",
"{",
"s",
"=",
"&",
"InMemoryQueueStorage",
"{",
"MaxSize",
":",
"100000",
"}",
"\n",
"}",
"\n",
"if",
"err",
":=",... | // New creates a new queue with a Storage specified in argument
// A standard InMemoryQueueStorage is used if Storage argument is nil. | [
"New",
"creates",
"a",
"new",
"queue",
"with",
"a",
"Storage",
"specified",
"in",
"argument",
"A",
"standard",
"InMemoryQueueStorage",
"is",
"used",
"if",
"Storage",
"argument",
"is",
"nil",
"."
] | b3d99101c625896f85d94cee72ddfa49f0379d25 | https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/queue/queue.go#L56-L69 |
130,498 | gocolly/colly | queue/queue.go | AddURL | func (q *Queue) AddURL(URL string) error {
u, err := url.Parse(URL)
if err != nil {
return err
}
r := &colly.Request{
URL: u,
Method: "GET",
}
d, err := r.Marshal()
if err != nil {
return err
}
return q.storage.AddRequest(d)
} | go | func (q *Queue) AddURL(URL string) error {
u, err := url.Parse(URL)
if err != nil {
return err
}
r := &colly.Request{
URL: u,
Method: "GET",
}
d, err := r.Marshal()
if err != nil {
return err
}
return q.storage.AddRequest(d)
} | [
"func",
"(",
"q",
"*",
"Queue",
")",
"AddURL",
"(",
"URL",
"string",
")",
"error",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"URL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"r",
":=",
"&",
"colly... | // AddURL adds a new URL to the queue | [
"AddURL",
"adds",
"a",
"new",
"URL",
"to",
"the",
"queue"
] | b3d99101c625896f85d94cee72ddfa49f0379d25 | https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/queue/queue.go#L78-L92 |
130,499 | gocolly/colly | queue/queue.go | AddRequest | func (q *Queue) AddRequest(r *colly.Request) error {
d, err := r.Marshal()
if err != nil {
return err
}
if err := q.storage.AddRequest(d); err != nil {
return err
}
q.lock.Lock()
for _, c := range q.threadChans {
c <- !stop
}
q.threadChans = make([]chan bool, 0, q.Threads)
q.lock.Unlock()
return nil
} | go | func (q *Queue) AddRequest(r *colly.Request) error {
d, err := r.Marshal()
if err != nil {
return err
}
if err := q.storage.AddRequest(d); err != nil {
return err
}
q.lock.Lock()
for _, c := range q.threadChans {
c <- !stop
}
q.threadChans = make([]chan bool, 0, q.Threads)
q.lock.Unlock()
return nil
} | [
"func",
"(",
"q",
"*",
"Queue",
")",
"AddRequest",
"(",
"r",
"*",
"colly",
".",
"Request",
")",
"error",
"{",
"d",
",",
"err",
":=",
"r",
".",
"Marshal",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"... | // AddRequest adds a new Request to the queue | [
"AddRequest",
"adds",
"a",
"new",
"Request",
"to",
"the",
"queue"
] | b3d99101c625896f85d94cee72ddfa49f0379d25 | https://github.com/gocolly/colly/blob/b3d99101c625896f85d94cee72ddfa49f0379d25/queue/queue.go#L95-L110 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.