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,100 | containerd/containerd | snapshots/storage/bolt.go | UpdateInfo | func UpdateInfo(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) {
updated := snapshots.Info{
Name: info.Name,
}
err := withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error {
sbkt := bkt.Bucket([]byte(info.Name))
if sbkt == nil {
return errors.Wrap(e... | go | func UpdateInfo(ctx context.Context, info snapshots.Info, fieldpaths ...string) (snapshots.Info, error) {
updated := snapshots.Info{
Name: info.Name,
}
err := withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error {
sbkt := bkt.Bucket([]byte(info.Name))
if sbkt == nil {
return errors.Wrap(e... | [
"func",
"UpdateInfo",
"(",
"ctx",
"context",
".",
"Context",
",",
"info",
"snapshots",
".",
"Info",
",",
"fieldpaths",
"...",
"string",
")",
"(",
"snapshots",
".",
"Info",
",",
"error",
")",
"{",
"updated",
":=",
"snapshots",
".",
"Info",
"{",
"Name",
... | // UpdateInfo updates an existing snapshot info's data | [
"UpdateInfo",
"updates",
"an",
"existing",
"snapshot",
"info",
"s",
"data"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/storage/bolt.go#L95-L142 |
130,101 | containerd/containerd | snapshots/storage/bolt.go | WalkInfo | func WalkInfo(ctx context.Context, fn func(context.Context, snapshots.Info) error) error {
return withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error {
return bkt.ForEach(func(k, v []byte) error {
// skip non buckets
if v != nil {
return nil
}
var (
sbkt = bkt.Bucket(k)
si... | go | func WalkInfo(ctx context.Context, fn func(context.Context, snapshots.Info) error) error {
return withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error {
return bkt.ForEach(func(k, v []byte) error {
// skip non buckets
if v != nil {
return nil
}
var (
sbkt = bkt.Bucket(k)
si... | [
"func",
"WalkInfo",
"(",
"ctx",
"context",
".",
"Context",
",",
"fn",
"func",
"(",
"context",
".",
"Context",
",",
"snapshots",
".",
"Info",
")",
"error",
")",
"error",
"{",
"return",
"withBucket",
"(",
"ctx",
",",
"func",
"(",
"ctx",
"context",
".",
... | // WalkInfo iterates through all metadata Info for the stored snapshots and
// calls the provided function for each. Requires a context with a storage
// transaction. | [
"WalkInfo",
"iterates",
"through",
"all",
"metadata",
"Info",
"for",
"the",
"stored",
"snapshots",
"and",
"calls",
"the",
"provided",
"function",
"for",
"each",
".",
"Requires",
"a",
"context",
"with",
"a",
"storage",
"transaction",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/storage/bolt.go#L147-L167 |
130,102 | containerd/containerd | snapshots/storage/bolt.go | GetSnapshot | func GetSnapshot(ctx context.Context, key string) (s Snapshot, err error) {
err = withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error {
sbkt := bkt.Bucket([]byte(key))
if sbkt == nil {
return errors.Wrap(errdefs.ErrNotFound, "snapshot does not exist")
}
s.ID = fmt.Sprintf("%d", readID(s... | go | func GetSnapshot(ctx context.Context, key string) (s Snapshot, err error) {
err = withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error {
sbkt := bkt.Bucket([]byte(key))
if sbkt == nil {
return errors.Wrap(errdefs.ErrNotFound, "snapshot does not exist")
}
s.ID = fmt.Sprintf("%d", readID(s... | [
"func",
"GetSnapshot",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
")",
"(",
"s",
"Snapshot",
",",
"err",
"error",
")",
"{",
"err",
"=",
"withBucket",
"(",
"ctx",
",",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"bkt",
",",
... | // GetSnapshot returns the metadata for the active or view snapshot transaction
// referenced by the given key. Requires a context with a storage transaction. | [
"GetSnapshot",
"returns",
"the",
"metadata",
"for",
"the",
"active",
"or",
"view",
"snapshot",
"transaction",
"referenced",
"by",
"the",
"given",
"key",
".",
"Requires",
"a",
"context",
"with",
"a",
"storage",
"transaction",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/storage/bolt.go#L171-L203 |
130,103 | containerd/containerd | snapshots/storage/bolt.go | CreateSnapshot | func CreateSnapshot(ctx context.Context, kind snapshots.Kind, key, parent string, opts ...snapshots.Opt) (s Snapshot, err error) {
switch kind {
case snapshots.KindActive, snapshots.KindView:
default:
return Snapshot{}, errors.Wrapf(errdefs.ErrInvalidArgument, "snapshot type %v invalid; only snapshots of type Acti... | go | func CreateSnapshot(ctx context.Context, kind snapshots.Kind, key, parent string, opts ...snapshots.Opt) (s Snapshot, err error) {
switch kind {
case snapshots.KindActive, snapshots.KindView:
default:
return Snapshot{}, errors.Wrapf(errdefs.ErrInvalidArgument, "snapshot type %v invalid; only snapshots of type Acti... | [
"func",
"CreateSnapshot",
"(",
"ctx",
"context",
".",
"Context",
",",
"kind",
"snapshots",
".",
"Kind",
",",
"key",
",",
"parent",
"string",
",",
"opts",
"...",
"snapshots",
".",
"Opt",
")",
"(",
"s",
"Snapshot",
",",
"err",
"error",
")",
"{",
"switch"... | // CreateSnapshot inserts a record for an active or view snapshot with the provided parent. | [
"CreateSnapshot",
"inserts",
"a",
"record",
"for",
"an",
"active",
"or",
"view",
"snapshot",
"with",
"the",
"provided",
"parent",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/storage/bolt.go#L206-L282 |
130,104 | containerd/containerd | snapshots/storage/bolt.go | Remove | func Remove(ctx context.Context, key string) (string, snapshots.Kind, error) {
var (
id uint64
si snapshots.Info
)
if err := withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error {
sbkt := bkt.Bucket([]byte(key))
if sbkt == nil {
return errors.Wrapf(errdefs.ErrNotFound, "snapshot %v", k... | go | func Remove(ctx context.Context, key string) (string, snapshots.Kind, error) {
var (
id uint64
si snapshots.Info
)
if err := withBucket(ctx, func(ctx context.Context, bkt, pbkt *bolt.Bucket) error {
sbkt := bkt.Bucket([]byte(key))
if sbkt == nil {
return errors.Wrapf(errdefs.ErrNotFound, "snapshot %v", k... | [
"func",
"Remove",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
"string",
")",
"(",
"string",
",",
"snapshots",
".",
"Kind",
",",
"error",
")",
"{",
"var",
"(",
"id",
"uint64",
"\n",
"si",
"snapshots",
".",
"Info",
"\n",
")",
"\n\n",
"if",
"er... | // Remove removes a snapshot from the metastore. The string identifier for the
// snapshot is returned as well as the kind. The provided context must contain a
// writable transaction. | [
"Remove",
"removes",
"a",
"snapshot",
"from",
"the",
"metastore",
".",
"The",
"string",
"identifier",
"for",
"the",
"snapshot",
"is",
"returned",
"as",
"well",
"as",
"the",
"kind",
".",
"The",
"provided",
"context",
"must",
"contain",
"a",
"writable",
"trans... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/storage/bolt.go#L287-L331 |
130,105 | containerd/containerd | snapshots/storage/bolt.go | CommitActive | func CommitActive(ctx context.Context, key, name string, usage snapshots.Usage, opts ...snapshots.Opt) (string, error) {
var (
id uint64
base snapshots.Info
)
for _, opt := range opts {
if err := opt(&base); err != nil {
return "", err
}
}
if err := withBucket(ctx, func(ctx context.Context, bkt, pbkt... | go | func CommitActive(ctx context.Context, key, name string, usage snapshots.Usage, opts ...snapshots.Opt) (string, error) {
var (
id uint64
base snapshots.Info
)
for _, opt := range opts {
if err := opt(&base); err != nil {
return "", err
}
}
if err := withBucket(ctx, func(ctx context.Context, bkt, pbkt... | [
"func",
"CommitActive",
"(",
"ctx",
"context",
".",
"Context",
",",
"key",
",",
"name",
"string",
",",
"usage",
"snapshots",
".",
"Usage",
",",
"opts",
"...",
"snapshots",
".",
"Opt",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"(",
"id",
"uin... | // CommitActive renames the active snapshot transaction referenced by `key`
// as a committed snapshot referenced by `Name`. The resulting snapshot will be
// committed and readonly. The `key` reference will no longer be available for
// lookup or removal. The returned string identifier for the committed snapshot
// i... | [
"CommitActive",
"renames",
"the",
"active",
"snapshot",
"transaction",
"referenced",
"by",
"key",
"as",
"a",
"committed",
"snapshot",
"referenced",
"by",
"Name",
".",
"The",
"resulting",
"snapshot",
"will",
"be",
"committed",
"and",
"readonly",
".",
"The",
"key"... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/storage/bolt.go#L339-L406 |
130,106 | containerd/containerd | snapshots/storage/bolt.go | IDMap | func IDMap(ctx context.Context) (map[string]string, error) {
m := map[string]string{}
if err := withBucket(ctx, func(ctx context.Context, bkt, _ *bolt.Bucket) error {
return bkt.ForEach(func(k, v []byte) error {
// skip non buckets
if v != nil {
return nil
}
id := readID(bkt.Bucket(k))
m[fmt.Spri... | go | func IDMap(ctx context.Context) (map[string]string, error) {
m := map[string]string{}
if err := withBucket(ctx, func(ctx context.Context, bkt, _ *bolt.Bucket) error {
return bkt.ForEach(func(k, v []byte) error {
// skip non buckets
if v != nil {
return nil
}
id := readID(bkt.Bucket(k))
m[fmt.Spri... | [
"func",
"IDMap",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"m",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"if",
"err",
":=",
"withBucket",
"(",
"ctx",
",",
"func... | // IDMap returns all the IDs mapped to their key | [
"IDMap",
"returns",
"all",
"the",
"IDs",
"mapped",
"to",
"their",
"key"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/storage/bolt.go#L409-L426 |
130,107 | containerd/containerd | namespaces/validate.go | Validate | func Validate(s string) error {
if len(s) > maxLength {
return errors.Wrapf(errdefs.ErrInvalidArgument, "namespace %q greater than maximum length (%d characters)", s, maxLength)
}
if !namespaceRe.MatchString(s) {
return errors.Wrapf(errdefs.ErrInvalidArgument, "namespace %q must match %v", s, namespaceRe)
}
r... | go | func Validate(s string) error {
if len(s) > maxLength {
return errors.Wrapf(errdefs.ErrInvalidArgument, "namespace %q greater than maximum length (%d characters)", s, maxLength)
}
if !namespaceRe.MatchString(s) {
return errors.Wrapf(errdefs.ErrInvalidArgument, "namespace %q must match %v", s, namespaceRe)
}
r... | [
"func",
"Validate",
"(",
"s",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"s",
")",
">",
"maxLength",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"errdefs",
".",
"ErrInvalidArgument",
",",
"\"",
"\"",
",",
"s",
",",
"maxLength",
")",
"\n",
"}",
... | // Validate returns nil if the string s is a valid namespace.
//
// To allow such namespace identifiers to be used across various contexts
// safely, the character set has been restricted to that defined for domains in
// RFC 1035, section 2.3.1. This will make namespace identifiers safe for use
// across networks, fil... | [
"Validate",
"returns",
"nil",
"if",
"the",
"string",
"s",
"is",
"a",
"valid",
"namespace",
".",
"To",
"allow",
"such",
"namespace",
"identifiers",
"to",
"be",
"used",
"across",
"various",
"contexts",
"safely",
"the",
"character",
"set",
"has",
"been",
"restr... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/namespaces/validate.go#L66-L75 |
130,108 | containerd/containerd | mount/mount_linux.go | Mount | func (m *Mount) Mount(target string) error {
var (
chdir string
options = m.Options
)
// avoid hitting one page limit of mount argument buffer
//
// NOTE: 512 is a buffer during pagesize check.
if m.Type == "overlay" && optionsSize(options) >= pagesize-512 {
chdir, options = compactLowerdirOption(options... | go | func (m *Mount) Mount(target string) error {
var (
chdir string
options = m.Options
)
// avoid hitting one page limit of mount argument buffer
//
// NOTE: 512 is a buffer during pagesize check.
if m.Type == "overlay" && optionsSize(options) >= pagesize-512 {
chdir, options = compactLowerdirOption(options... | [
"func",
"(",
"m",
"*",
"Mount",
")",
"Mount",
"(",
"target",
"string",
")",
"error",
"{",
"var",
"(",
"chdir",
"string",
"\n",
"options",
"=",
"m",
".",
"Options",
"\n",
")",
"\n\n",
"// avoid hitting one page limit of mount argument buffer",
"//",
"// NOTE: 5... | // Mount to the provided target path | [
"Mount",
"to",
"the",
"provided",
"target",
"path"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/mount/mount_linux.go#L38-L85 |
130,109 | containerd/containerd | mount/mount_linux.go | Unmount | func Unmount(target string, flags int) error {
if err := unmount(target, flags); err != nil && err != unix.EINVAL {
return err
}
return nil
} | go | func Unmount(target string, flags int) error {
if err := unmount(target, flags); err != nil && err != unix.EINVAL {
return err
}
return nil
} | [
"func",
"Unmount",
"(",
"target",
"string",
",",
"flags",
"int",
")",
"error",
"{",
"if",
"err",
":=",
"unmount",
"(",
"target",
",",
"flags",
")",
";",
"err",
"!=",
"nil",
"&&",
"err",
"!=",
"unix",
".",
"EINVAL",
"{",
"return",
"err",
"\n",
"}",
... | // Unmount the provided mount path with the flags | [
"Unmount",
"the",
"provided",
"mount",
"path",
"with",
"the",
"flags"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/mount/mount_linux.go#L88-L93 |
130,110 | containerd/containerd | mount/mount_linux.go | compactLowerdirOption | func compactLowerdirOption(opts []string) (string, []string) {
idx, dirs := findOverlayLowerdirs(opts)
if idx == -1 || len(dirs) == 1 {
// no need to compact if there is only one lowerdir
return "", opts
}
// find out common dir
commondir := longestCommonPrefix(dirs)
if commondir == "" {
return "", opts
}... | go | func compactLowerdirOption(opts []string) (string, []string) {
idx, dirs := findOverlayLowerdirs(opts)
if idx == -1 || len(dirs) == 1 {
// no need to compact if there is only one lowerdir
return "", opts
}
// find out common dir
commondir := longestCommonPrefix(dirs)
if commondir == "" {
return "", opts
}... | [
"func",
"compactLowerdirOption",
"(",
"opts",
"[",
"]",
"string",
")",
"(",
"string",
",",
"[",
"]",
"string",
")",
"{",
"idx",
",",
"dirs",
":=",
"findOverlayLowerdirs",
"(",
"opts",
")",
"\n",
"if",
"idx",
"==",
"-",
"1",
"||",
"len",
"(",
"dirs",
... | // compactLowerdirOption updates overlay lowdir option and returns the common
// dir among all the lowdirs. | [
"compactLowerdirOption",
"updates",
"overlay",
"lowdir",
"option",
"and",
"returns",
"the",
"common",
"dir",
"among",
"all",
"the",
"lowdirs",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/mount/mount_linux.go#L186-L217 |
130,111 | containerd/containerd | mount/mount_linux.go | findOverlayLowerdirs | func findOverlayLowerdirs(opts []string) (int, []string) {
var (
idx = -1
prefix = "lowerdir="
)
for i, opt := range opts {
if strings.HasPrefix(opt, prefix) {
idx = i
break
}
}
if idx == -1 {
return -1, nil
}
return idx, strings.Split(opts[idx][len(prefix):], ":")
} | go | func findOverlayLowerdirs(opts []string) (int, []string) {
var (
idx = -1
prefix = "lowerdir="
)
for i, opt := range opts {
if strings.HasPrefix(opt, prefix) {
idx = i
break
}
}
if idx == -1 {
return -1, nil
}
return idx, strings.Split(opts[idx][len(prefix):], ":")
} | [
"func",
"findOverlayLowerdirs",
"(",
"opts",
"[",
"]",
"string",
")",
"(",
"int",
",",
"[",
"]",
"string",
")",
"{",
"var",
"(",
"idx",
"=",
"-",
"1",
"\n",
"prefix",
"=",
"\"",
"\"",
"\n",
")",
"\n\n",
"for",
"i",
",",
"opt",
":=",
"range",
"o... | // findOverlayLowerdirs returns the index of lowerdir in mount's options and
// all the lowerdir target. | [
"findOverlayLowerdirs",
"returns",
"the",
"index",
"of",
"lowerdir",
"in",
"mount",
"s",
"options",
"and",
"all",
"the",
"lowerdir",
"target",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/mount/mount_linux.go#L221-L238 |
130,112 | containerd/containerd | mount/mount_linux.go | longestCommonPrefix | func longestCommonPrefix(strs []string) string {
if len(strs) == 0 {
return ""
} else if len(strs) == 1 {
return strs[0]
}
// find out the min/max value by alphabetical order
min, max := strs[0], strs[0]
for _, str := range strs[1:] {
if min > str {
min = str
}
if max < str {
max = str
}
}
/... | go | func longestCommonPrefix(strs []string) string {
if len(strs) == 0 {
return ""
} else if len(strs) == 1 {
return strs[0]
}
// find out the min/max value by alphabetical order
min, max := strs[0], strs[0]
for _, str := range strs[1:] {
if min > str {
min = str
}
if max < str {
max = str
}
}
/... | [
"func",
"longestCommonPrefix",
"(",
"strs",
"[",
"]",
"string",
")",
"string",
"{",
"if",
"len",
"(",
"strs",
")",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"else",
"if",
"len",
"(",
"strs",
")",
"==",
"1",
"{",
"return",
"strs",
"[",
"0",... | // longestCommonPrefix finds the longest common prefix in the string slice. | [
"longestCommonPrefix",
"finds",
"the",
"longest",
"common",
"prefix",
"in",
"the",
"string",
"slice",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/mount/mount_linux.go#L241-L266 |
130,113 | containerd/containerd | mount/mount_linux.go | copyOptions | func copyOptions(opts []string) []string {
if len(opts) == 0 {
return nil
}
acopy := make([]string, len(opts))
copy(acopy, opts)
return acopy
} | go | func copyOptions(opts []string) []string {
if len(opts) == 0 {
return nil
}
acopy := make([]string, len(opts))
copy(acopy, opts)
return acopy
} | [
"func",
"copyOptions",
"(",
"opts",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"if",
"len",
"(",
"opts",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"acopy",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"opts",
")... | // copyOptions copies the options. | [
"copyOptions",
"copies",
"the",
"options",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/mount/mount_linux.go#L269-L277 |
130,114 | containerd/containerd | mount/mount_linux.go | optionsSize | func optionsSize(opts []string) int {
size := 0
for _, opt := range opts {
size += len(opt)
}
return size
} | go | func optionsSize(opts []string) int {
size := 0
for _, opt := range opts {
size += len(opt)
}
return size
} | [
"func",
"optionsSize",
"(",
"opts",
"[",
"]",
"string",
")",
"int",
"{",
"size",
":=",
"0",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"size",
"+=",
"len",
"(",
"opt",
")",
"\n",
"}",
"\n",
"return",
"size",
"\n",
"}"
] | // optionsSize returns the byte size of options of mount. | [
"optionsSize",
"returns",
"the",
"byte",
"size",
"of",
"options",
"of",
"mount",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/mount/mount_linux.go#L280-L286 |
130,115 | containerd/containerd | pkg/seed/seed.go | WithTimeAndRand | func WithTimeAndRand() {
var (
b [4]byte
u int64
)
tryReadRandom(b[:])
// Set higher 32 bits, bottom 32 will be set with nanos
u |= (int64(b[0]) << 56) | (int64(b[1]) << 48) | (int64(b[2]) << 40) | (int64(b[3]) << 32)
rand.Seed(u ^ time.Now().UnixNano())
} | go | func WithTimeAndRand() {
var (
b [4]byte
u int64
)
tryReadRandom(b[:])
// Set higher 32 bits, bottom 32 will be set with nanos
u |= (int64(b[0]) << 56) | (int64(b[1]) << 48) | (int64(b[2]) << 40) | (int64(b[3]) << 32)
rand.Seed(u ^ time.Now().UnixNano())
} | [
"func",
"WithTimeAndRand",
"(",
")",
"{",
"var",
"(",
"b",
"[",
"4",
"]",
"byte",
"\n",
"u",
"int64",
"\n",
")",
"\n\n",
"tryReadRandom",
"(",
"b",
"[",
":",
"]",
")",
"\n\n",
"// Set higher 32 bits, bottom 32 will be set with nanos",
"u",
"|=",
"(",
"int6... | // WithTimeAndRand seeds the global math rand generator with nanoseconds
// XOR'ed with a crypto component if available for uniqueness. | [
"WithTimeAndRand",
"seeds",
"the",
"global",
"math",
"rand",
"generator",
"with",
"nanoseconds",
"XOR",
"ed",
"with",
"a",
"crypto",
"component",
"if",
"available",
"for",
"uniqueness",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/pkg/seed/seed.go#L26-L38 |
130,116 | containerd/containerd | oci/spec.go | GenerateSpec | func GenerateSpec(ctx context.Context, client Client, c *containers.Container, opts ...SpecOpts) (*Spec, error) {
return GenerateSpecWithPlatform(ctx, client, platforms.DefaultString(), c, opts...)
} | go | func GenerateSpec(ctx context.Context, client Client, c *containers.Container, opts ...SpecOpts) (*Spec, error) {
return GenerateSpecWithPlatform(ctx, client, platforms.DefaultString(), c, opts...)
} | [
"func",
"GenerateSpec",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"Client",
",",
"c",
"*",
"containers",
".",
"Container",
",",
"opts",
"...",
"SpecOpts",
")",
"(",
"*",
"Spec",
",",
"error",
")",
"{",
"return",
"GenerateSpecWithPlatform",
"(",... | // GenerateSpec will generate a default spec from the provided image
// for use as a containerd container | [
"GenerateSpec",
"will",
"generate",
"a",
"default",
"spec",
"from",
"the",
"provided",
"image",
"for",
"use",
"as",
"a",
"containerd",
"container"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec.go#L48-L50 |
130,117 | containerd/containerd | oci/spec.go | GenerateSpecWithPlatform | func GenerateSpecWithPlatform(ctx context.Context, client Client, platform string, c *containers.Container, opts ...SpecOpts) (*Spec, error) {
var s Spec
if err := generateDefaultSpecWithPlatform(ctx, platform, c.ID, &s); err != nil {
return nil, err
}
return &s, ApplyOpts(ctx, client, c, &s, opts...)
} | go | func GenerateSpecWithPlatform(ctx context.Context, client Client, platform string, c *containers.Container, opts ...SpecOpts) (*Spec, error) {
var s Spec
if err := generateDefaultSpecWithPlatform(ctx, platform, c.ID, &s); err != nil {
return nil, err
}
return &s, ApplyOpts(ctx, client, c, &s, opts...)
} | [
"func",
"GenerateSpecWithPlatform",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"Client",
",",
"platform",
"string",
",",
"c",
"*",
"containers",
".",
"Container",
",",
"opts",
"...",
"SpecOpts",
")",
"(",
"*",
"Spec",
",",
"error",
")",
"{",
"... | // GenerateSpecWithPlatform will generate a default spec from the provided image
// for use as a containerd container in the platform requested. | [
"GenerateSpecWithPlatform",
"will",
"generate",
"a",
"default",
"spec",
"from",
"the",
"provided",
"image",
"for",
"use",
"as",
"a",
"containerd",
"container",
"in",
"the",
"platform",
"requested",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec.go#L54-L61 |
130,118 | containerd/containerd | oci/spec.go | ApplyOpts | func ApplyOpts(ctx context.Context, client Client, c *containers.Container, s *Spec, opts ...SpecOpts) error {
for _, o := range opts {
if err := o(ctx, client, c, s); err != nil {
return err
}
}
return nil
} | go | func ApplyOpts(ctx context.Context, client Client, c *containers.Container, s *Spec, opts ...SpecOpts) error {
for _, o := range opts {
if err := o(ctx, client, c, s); err != nil {
return err
}
}
return nil
} | [
"func",
"ApplyOpts",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"Client",
",",
"c",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
",",
"opts",
"...",
"SpecOpts",
")",
"error",
"{",
"for",
"_",
",",
"o",
":=",
"range",
"opts",... | // ApplyOpts applys the options to the given spec, injecting data from the
// context, client and container instance. | [
"ApplyOpts",
"applys",
"the",
"options",
"to",
"the",
"given",
"spec",
"injecting",
"data",
"from",
"the",
"context",
"client",
"and",
"container",
"instance",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec.go#L83-L91 |
130,119 | containerd/containerd | snapshots/devmapper/losetup/losetup.go | FindAssociatedLoopDevices | func FindAssociatedLoopDevices(imagePath string) ([]string, error) {
output, err := losetup("--list", "--output", "NAME", "--associated", imagePath)
if err != nil {
return nil, errors.Wrapf(err, "failed to get loop devices: '%s'", output)
}
if output == "" {
return []string{}, nil
}
items := strings.Split(o... | go | func FindAssociatedLoopDevices(imagePath string) ([]string, error) {
output, err := losetup("--list", "--output", "NAME", "--associated", imagePath)
if err != nil {
return nil, errors.Wrapf(err, "failed to get loop devices: '%s'", output)
}
if output == "" {
return []string{}, nil
}
items := strings.Split(o... | [
"func",
"FindAssociatedLoopDevices",
"(",
"imagePath",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"output",
",",
"err",
":=",
"losetup",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"imagePath",
")",
... | // FindAssociatedLoopDevices returns a list of loop devices attached to a given image | [
"FindAssociatedLoopDevices",
"returns",
"a",
"list",
"of",
"loop",
"devices",
"attached",
"to",
"a",
"given",
"image"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/devmapper/losetup/losetup.go#L29-L46 |
130,120 | containerd/containerd | snapshots/devmapper/losetup/losetup.go | DetachLoopDevice | func DetachLoopDevice(loopDevice ...string) error {
args := append([]string{"--detach"}, loopDevice...)
_, err := losetup(args...)
return err
} | go | func DetachLoopDevice(loopDevice ...string) error {
args := append([]string{"--detach"}, loopDevice...)
_, err := losetup(args...)
return err
} | [
"func",
"DetachLoopDevice",
"(",
"loopDevice",
"...",
"string",
")",
"error",
"{",
"args",
":=",
"append",
"(",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
",",
"loopDevice",
"...",
")",
"\n",
"_",
",",
"err",
":=",
"losetup",
"(",
"args",
"...",
")",
... | // DetachLoopDevice detaches loop devices | [
"DetachLoopDevice",
"detaches",
"loop",
"devices"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/devmapper/losetup/losetup.go#L54-L58 |
130,121 | containerd/containerd | snapshots/devmapper/losetup/losetup.go | RemoveLoopDevicesAssociatedWithImage | func RemoveLoopDevicesAssociatedWithImage(imagePath string) error {
loopDevices, err := FindAssociatedLoopDevices(imagePath)
if err != nil {
return err
}
for _, loopDevice := range loopDevices {
if err = DetachLoopDevice(loopDevice); err != nil {
return err
}
}
return nil
} | go | func RemoveLoopDevicesAssociatedWithImage(imagePath string) error {
loopDevices, err := FindAssociatedLoopDevices(imagePath)
if err != nil {
return err
}
for _, loopDevice := range loopDevices {
if err = DetachLoopDevice(loopDevice); err != nil {
return err
}
}
return nil
} | [
"func",
"RemoveLoopDevicesAssociatedWithImage",
"(",
"imagePath",
"string",
")",
"error",
"{",
"loopDevices",
",",
"err",
":=",
"FindAssociatedLoopDevices",
"(",
"imagePath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"for",
... | // RemoveLoopDevicesAssociatedWithImage detaches all loop devices attached to a given sparse image | [
"RemoveLoopDevicesAssociatedWithImage",
"detaches",
"all",
"loop",
"devices",
"attached",
"to",
"a",
"given",
"sparse",
"image"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/devmapper/losetup/losetup.go#L61-L74 |
130,122 | containerd/containerd | snapshots/devmapper/losetup/losetup.go | losetup | func losetup(args ...string) (string, error) {
data, err := exec.Command("losetup", args...).CombinedOutput()
output := string(data)
if err != nil {
return "", errors.Wrapf(err, "losetup %s\nerror: %s\n", strings.Join(args, " "), output)
}
return strings.TrimSuffix(output, "\n"), err
} | go | func losetup(args ...string) (string, error) {
data, err := exec.Command("losetup", args...).CombinedOutput()
output := string(data)
if err != nil {
return "", errors.Wrapf(err, "losetup %s\nerror: %s\n", strings.Join(args, " "), output)
}
return strings.TrimSuffix(output, "\n"), err
} | [
"func",
"losetup",
"(",
"args",
"...",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"args",
"...",
")",
".",
"CombinedOutput",
"(",
")",
"\n",
"output",
":=",
"string"... | // losetup is a wrapper around losetup command line tool | [
"losetup",
"is",
"a",
"wrapper",
"around",
"losetup",
"command",
"line",
"tool"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/devmapper/losetup/losetup.go#L77-L85 |
130,123 | containerd/containerd | oci/spec_opts.go | setRoot | func setRoot(s *Spec) {
if s.Root == nil {
s.Root = &specs.Root{}
}
} | go | func setRoot(s *Spec) {
if s.Root == nil {
s.Root = &specs.Root{}
}
} | [
"func",
"setRoot",
"(",
"s",
"*",
"Spec",
")",
"{",
"if",
"s",
".",
"Root",
"==",
"nil",
"{",
"s",
".",
"Root",
"=",
"&",
"specs",
".",
"Root",
"{",
"}",
"\n",
"}",
"\n",
"}"
] | // setRoot sets Root to empty if unset | [
"setRoot",
"sets",
"Root",
"to",
"empty",
"if",
"unset"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L66-L70 |
130,124 | containerd/containerd | oci/spec_opts.go | setLinux | func setLinux(s *Spec) {
if s.Linux == nil {
s.Linux = &specs.Linux{}
}
} | go | func setLinux(s *Spec) {
if s.Linux == nil {
s.Linux = &specs.Linux{}
}
} | [
"func",
"setLinux",
"(",
"s",
"*",
"Spec",
")",
"{",
"if",
"s",
".",
"Linux",
"==",
"nil",
"{",
"s",
".",
"Linux",
"=",
"&",
"specs",
".",
"Linux",
"{",
"}",
"\n",
"}",
"\n",
"}"
] | // setLinux sets Linux to empty if unset | [
"setLinux",
"sets",
"Linux",
"to",
"empty",
"if",
"unset"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L73-L77 |
130,125 | containerd/containerd | oci/spec_opts.go | setCapabilities | func setCapabilities(s *Spec) {
setProcess(s)
if s.Process.Capabilities == nil {
s.Process.Capabilities = &specs.LinuxCapabilities{}
}
} | go | func setCapabilities(s *Spec) {
setProcess(s)
if s.Process.Capabilities == nil {
s.Process.Capabilities = &specs.LinuxCapabilities{}
}
} | [
"func",
"setCapabilities",
"(",
"s",
"*",
"Spec",
")",
"{",
"setProcess",
"(",
"s",
")",
"\n",
"if",
"s",
".",
"Process",
".",
"Capabilities",
"==",
"nil",
"{",
"s",
".",
"Process",
".",
"Capabilities",
"=",
"&",
"specs",
".",
"LinuxCapabilities",
"{",... | // setCapabilities sets Linux Capabilities to empty if unset | [
"setCapabilities",
"sets",
"Linux",
"Capabilities",
"to",
"empty",
"if",
"unset"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L80-L85 |
130,126 | containerd/containerd | oci/spec_opts.go | WithDefaultSpec | func WithDefaultSpec() SpecOpts {
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
return generateDefaultSpecWithPlatform(ctx, platforms.DefaultString(), c.ID, s)
}
} | go | func WithDefaultSpec() SpecOpts {
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
return generateDefaultSpecWithPlatform(ctx, platforms.DefaultString(), c.ID, s)
}
} | [
"func",
"WithDefaultSpec",
"(",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"c",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"return",
"generateDefaultSpecWithPl... | // WithDefaultSpec returns a SpecOpts that will populate the spec with default
// values.
//
// Use as the first option to clear the spec, then apply options afterwards. | [
"WithDefaultSpec",
"returns",
"a",
"SpecOpts",
"that",
"will",
"populate",
"the",
"spec",
"with",
"default",
"values",
".",
"Use",
"as",
"the",
"first",
"option",
"to",
"clear",
"the",
"spec",
"then",
"apply",
"options",
"afterwards",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L91-L95 |
130,127 | containerd/containerd | oci/spec_opts.go | WithDefaultSpecForPlatform | func WithDefaultSpecForPlatform(platform string) SpecOpts {
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
return generateDefaultSpecWithPlatform(ctx, platform, c.ID, s)
}
} | go | func WithDefaultSpecForPlatform(platform string) SpecOpts {
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
return generateDefaultSpecWithPlatform(ctx, platform, c.ID, s)
}
} | [
"func",
"WithDefaultSpecForPlatform",
"(",
"platform",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"c",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"... | // WithDefaultSpecForPlatform returns a SpecOpts that will populate the spec
// with default values for a given platform.
//
// Use as the first option to clear the spec, then apply options afterwards. | [
"WithDefaultSpecForPlatform",
"returns",
"a",
"SpecOpts",
"that",
"will",
"populate",
"the",
"spec",
"with",
"default",
"values",
"for",
"a",
"given",
"platform",
".",
"Use",
"as",
"the",
"first",
"option",
"to",
"clear",
"the",
"spec",
"then",
"apply",
"optio... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L101-L105 |
130,128 | containerd/containerd | oci/spec_opts.go | WithSpecFromBytes | func WithSpecFromBytes(p []byte) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
*s = Spec{} // make sure spec is cleared.
if err := json.Unmarshal(p, s); err != nil {
return errors.Wrapf(err, "decoding spec config file failed, current supported OCI runtime-spec : v... | go | func WithSpecFromBytes(p []byte) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
*s = Spec{} // make sure spec is cleared.
if err := json.Unmarshal(p, s); err != nil {
return errors.Wrapf(err, "decoding spec config file failed, current supported OCI runtime-spec : v... | [
"func",
"WithSpecFromBytes",
"(",
"p",
"[",
"]",
"byte",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"*",
... | // WithSpecFromBytes loads the the spec from the provided byte slice. | [
"WithSpecFromBytes",
"loads",
"the",
"the",
"spec",
"from",
"the",
"provided",
"byte",
"slice",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L108-L116 |
130,129 | containerd/containerd | oci/spec_opts.go | WithSpecFromFile | func WithSpecFromFile(filename string) SpecOpts {
return func(ctx context.Context, c Client, container *containers.Container, s *Spec) error {
p, err := ioutil.ReadFile(filename)
if err != nil {
return errors.Wrap(err, "cannot load spec config file")
}
return WithSpecFromBytes(p)(ctx, c, container, s)
}
} | go | func WithSpecFromFile(filename string) SpecOpts {
return func(ctx context.Context, c Client, container *containers.Container, s *Spec) error {
p, err := ioutil.ReadFile(filename)
if err != nil {
return errors.Wrap(err, "cannot load spec config file")
}
return WithSpecFromBytes(p)(ctx, c, container, s)
}
} | [
"func",
"WithSpecFromFile",
"(",
"filename",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"Client",
",",
"container",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"p"... | // WithSpecFromFile loads the specification from the provided filename. | [
"WithSpecFromFile",
"loads",
"the",
"specification",
"from",
"the",
"provided",
"filename",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L119-L127 |
130,130 | containerd/containerd | oci/spec_opts.go | WithEnv | func WithEnv(environmentVariables []string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
if len(environmentVariables) > 0 {
setProcess(s)
s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, environmentVariables)
}
return nil
}
} | go | func WithEnv(environmentVariables []string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
if len(environmentVariables) > 0 {
setProcess(s)
s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, environmentVariables)
}
return nil
}
} | [
"func",
"WithEnv",
"(",
"environmentVariables",
"[",
"]",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{"... | // WithEnv appends environment variables | [
"WithEnv",
"appends",
"environment",
"variables"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L130-L138 |
130,131 | containerd/containerd | oci/spec_opts.go | replaceOrAppendEnvValues | func replaceOrAppendEnvValues(defaults, overrides []string) []string {
cache := make(map[string]int, len(defaults))
results := make([]string, 0, len(defaults))
for i, e := range defaults {
parts := strings.SplitN(e, "=", 2)
results = append(results, e)
cache[parts[0]] = i
}
for _, value := range overrides {... | go | func replaceOrAppendEnvValues(defaults, overrides []string) []string {
cache := make(map[string]int, len(defaults))
results := make([]string, 0, len(defaults))
for i, e := range defaults {
parts := strings.SplitN(e, "=", 2)
results = append(results, e)
cache[parts[0]] = i
}
for _, value := range overrides {... | [
"func",
"replaceOrAppendEnvValues",
"(",
"defaults",
",",
"overrides",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"cache",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int",
",",
"len",
"(",
"defaults",
")",
")",
"\n",
"results",
":=",
"make",... | // replaceOrAppendEnvValues returns the defaults with the overrides either
// replaced by env key or appended to the list | [
"replaceOrAppendEnvValues",
"returns",
"the",
"defaults",
"with",
"the",
"overrides",
"either",
"replaced",
"by",
"env",
"key",
"or",
"appended",
"to",
"the",
"list"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L142-L178 |
130,132 | containerd/containerd | oci/spec_opts.go | WithProcessArgs | func WithProcessArgs(args ...string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.Args = args
return nil
}
} | go | func WithProcessArgs(args ...string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.Args = args
return nil
}
} | [
"func",
"WithProcessArgs",
"(",
"args",
"...",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setProce... | // WithProcessArgs replaces the args on the generated spec | [
"WithProcessArgs",
"replaces",
"the",
"args",
"on",
"the",
"generated",
"spec"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L181-L187 |
130,133 | containerd/containerd | oci/spec_opts.go | WithProcessCwd | func WithProcessCwd(cwd string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.Cwd = cwd
return nil
}
} | go | func WithProcessCwd(cwd string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.Cwd = cwd
return nil
}
} | [
"func",
"WithProcessCwd",
"(",
"cwd",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setProcess",
"(",... | // WithProcessCwd replaces the current working directory on the generated spec | [
"WithProcessCwd",
"replaces",
"the",
"current",
"working",
"directory",
"on",
"the",
"generated",
"spec"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L190-L196 |
130,134 | containerd/containerd | oci/spec_opts.go | WithTTY | func WithTTY(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.Terminal = true
if s.Linux != nil {
s.Process.Env = append(s.Process.Env, "TERM=xterm")
}
return nil
} | go | func WithTTY(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.Terminal = true
if s.Linux != nil {
s.Process.Env = append(s.Process.Env, "TERM=xterm")
}
return nil
} | [
"func",
"WithTTY",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setProcess",
"(",
"s",
")",
"\n",
"s",
".",
"Process",
".",
"Terminal",
"=",
"true... | // WithTTY sets the information on the spec as well as the environment variables for
// using a TTY | [
"WithTTY",
"sets",
"the",
"information",
"on",
"the",
"spec",
"as",
"well",
"as",
"the",
"environment",
"variables",
"for",
"using",
"a",
"TTY"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L200-L208 |
130,135 | containerd/containerd | oci/spec_opts.go | WithTTYSize | func WithTTYSize(width, height int) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
if s.Process.ConsoleSize == nil {
s.Process.ConsoleSize = &specs.Box{}
}
s.Process.ConsoleSize.Width = uint(width)
s.Process.ConsoleSize.Height = uint(height)
r... | go | func WithTTYSize(width, height int) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
if s.Process.ConsoleSize == nil {
s.Process.ConsoleSize = &specs.Box{}
}
s.Process.ConsoleSize.Width = uint(width)
s.Process.ConsoleSize.Height = uint(height)
r... | [
"func",
"WithTTYSize",
"(",
"width",
",",
"height",
"int",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setP... | // WithTTYSize sets the information on the spec as well as the environment variables for
// using a TTY | [
"WithTTYSize",
"sets",
"the",
"information",
"on",
"the",
"spec",
"as",
"well",
"as",
"the",
"environment",
"variables",
"for",
"using",
"a",
"TTY"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L212-L222 |
130,136 | containerd/containerd | oci/spec_opts.go | WithHostname | func WithHostname(name string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
s.Hostname = name
return nil
}
} | go | func WithHostname(name string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
s.Hostname = name
return nil
}
} | [
"func",
"WithHostname",
"(",
"name",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"s",
".",
"Hostna... | // WithHostname sets the container's hostname | [
"WithHostname",
"sets",
"the",
"container",
"s",
"hostname"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L225-L230 |
130,137 | containerd/containerd | oci/spec_opts.go | WithMounts | func WithMounts(mounts []specs.Mount) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
s.Mounts = append(s.Mounts, mounts...)
return nil
}
} | go | func WithMounts(mounts []specs.Mount) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
s.Mounts = append(s.Mounts, mounts...)
return nil
}
} | [
"func",
"WithMounts",
"(",
"mounts",
"[",
"]",
"specs",
".",
"Mount",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",... | // WithMounts appends mounts | [
"WithMounts",
"appends",
"mounts"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L233-L238 |
130,138 | containerd/containerd | oci/spec_opts.go | WithHostNamespace | func WithHostNamespace(ns specs.LinuxNamespaceType) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
for i, n := range s.Linux.Namespaces {
if n.Type == ns {
s.Linux.Namespaces = append(s.Linux.Namespaces[:i], s.Linux.Namespaces[i+1:]...)
return n... | go | func WithHostNamespace(ns specs.LinuxNamespaceType) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
for i, n := range s.Linux.Namespaces {
if n.Type == ns {
s.Linux.Namespaces = append(s.Linux.Namespaces[:i], s.Linux.Namespaces[i+1:]...)
return n... | [
"func",
"WithHostNamespace",
"(",
"ns",
"specs",
".",
"LinuxNamespaceType",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error... | // WithHostNamespace allows a task to run inside the host's linux namespace | [
"WithHostNamespace",
"allows",
"a",
"task",
"to",
"run",
"inside",
"the",
"host",
"s",
"linux",
"namespace"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L241-L252 |
130,139 | containerd/containerd | oci/spec_opts.go | WithLinuxNamespace | func WithLinuxNamespace(ns specs.LinuxNamespace) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
for i, n := range s.Linux.Namespaces {
if n.Type == ns.Type {
before := s.Linux.Namespaces[:i]
after := s.Linux.Namespaces[i+1:]
s.Linux.Namespac... | go | func WithLinuxNamespace(ns specs.LinuxNamespace) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
for i, n := range s.Linux.Namespaces {
if n.Type == ns.Type {
before := s.Linux.Namespaces[:i]
after := s.Linux.Namespaces[i+1:]
s.Linux.Namespac... | [
"func",
"WithLinuxNamespace",
"(",
"ns",
"specs",
".",
"LinuxNamespace",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
... | // WithLinuxNamespace uses the passed in namespace for the spec. If a namespace of the same type already exists in the
// spec, the existing namespace is replaced by the one provided. | [
"WithLinuxNamespace",
"uses",
"the",
"passed",
"in",
"namespace",
"for",
"the",
"spec",
".",
"If",
"a",
"namespace",
"of",
"the",
"same",
"type",
"already",
"exists",
"in",
"the",
"spec",
"the",
"existing",
"namespace",
"is",
"replaced",
"by",
"the",
"one",
... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L256-L271 |
130,140 | containerd/containerd | oci/spec_opts.go | WithNewPrivileges | func WithNewPrivileges(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.NoNewPrivileges = false
return nil
} | go | func WithNewPrivileges(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.NoNewPrivileges = false
return nil
} | [
"func",
"WithNewPrivileges",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setProcess",
"(",
"s",
")",
"\n",
"s",
".",
"Process",
".",
"NoNewPrivileges... | // WithNewPrivileges turns off the NoNewPrivileges feature flag in the spec | [
"WithNewPrivileges",
"turns",
"off",
"the",
"NoNewPrivileges",
"feature",
"flag",
"in",
"the",
"spec"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L274-L279 |
130,141 | containerd/containerd | oci/spec_opts.go | WithImageConfigArgs | func WithImageConfigArgs(image Image, args []string) SpecOpts {
return func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
ic, err := image.Config(ctx)
if err != nil {
return err
}
var (
ociimage v1.Image
config v1.ImageConfig
)
switch ic.MediaType {
case v1.Medi... | go | func WithImageConfigArgs(image Image, args []string) SpecOpts {
return func(ctx context.Context, client Client, c *containers.Container, s *Spec) error {
ic, err := image.Config(ctx)
if err != nil {
return err
}
var (
ociimage v1.Image
config v1.ImageConfig
)
switch ic.MediaType {
case v1.Medi... | [
"func",
"WithImageConfigArgs",
"(",
"image",
"Image",
",",
"args",
"[",
"]",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"client",
"Client",
",",
"c",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
... | // WithImageConfigArgs configures the spec to from the configuration of an Image with additional args that
// replaces the CMD of the image | [
"WithImageConfigArgs",
"configures",
"the",
"spec",
"to",
"from",
"the",
"configuration",
"of",
"an",
"Image",
"with",
"additional",
"args",
"that",
"replaces",
"the",
"CMD",
"of",
"the",
"image"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L288-L353 |
130,142 | containerd/containerd | oci/spec_opts.go | WithRootFSPath | func WithRootFSPath(path string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setRoot(s)
s.Root.Path = path
// Entrypoint is not set here (it's up to caller)
return nil
}
} | go | func WithRootFSPath(path string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setRoot(s)
s.Root.Path = path
// Entrypoint is not set here (it's up to caller)
return nil
}
} | [
"func",
"WithRootFSPath",
"(",
"path",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setRoot",
"(",
... | // WithRootFSPath specifies unmanaged rootfs path. | [
"WithRootFSPath",
"specifies",
"unmanaged",
"rootfs",
"path",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L356-L363 |
130,143 | containerd/containerd | oci/spec_opts.go | WithRootFSReadonly | func WithRootFSReadonly() SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setRoot(s)
s.Root.Readonly = true
return nil
}
} | go | func WithRootFSReadonly() SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setRoot(s)
s.Root.Readonly = true
return nil
}
} | [
"func",
"WithRootFSReadonly",
"(",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setRoot",
"(",
"s",
")",
"\n... | // WithRootFSReadonly sets specs.Root.Readonly to true | [
"WithRootFSReadonly",
"sets",
"specs",
".",
"Root",
".",
"Readonly",
"to",
"true"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L366-L372 |
130,144 | containerd/containerd | oci/spec_opts.go | WithNoNewPrivileges | func WithNoNewPrivileges(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.NoNewPrivileges = true
return nil
} | go | func WithNoNewPrivileges(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.NoNewPrivileges = true
return nil
} | [
"func",
"WithNoNewPrivileges",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setProcess",
"(",
"s",
")",
"\n",
"s",
".",
"Process",
".",
"NoNewPrivileg... | // WithNoNewPrivileges sets no_new_privileges on the process for the container | [
"WithNoNewPrivileges",
"sets",
"no_new_privileges",
"on",
"the",
"process",
"for",
"the",
"container"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L375-L379 |
130,145 | containerd/containerd | oci/spec_opts.go | WithUserNamespace | func WithUserNamespace(container, host, size uint32) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
var hasUserns bool
setLinux(s)
for _, ns := range s.Linux.Namespaces {
if ns.Type == specs.UserNamespace {
hasUserns = true
break
}
}
if !hasUserns ... | go | func WithUserNamespace(container, host, size uint32) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
var hasUserns bool
setLinux(s)
for _, ns := range s.Linux.Namespaces {
if ns.Type == specs.UserNamespace {
hasUserns = true
break
}
}
if !hasUserns ... | [
"func",
"WithUserNamespace",
"(",
"container",
",",
"host",
",",
"size",
"uint32",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")... | // WithUserNamespace sets the uid and gid mappings for the task
// this can be called multiple times to add more mappings to the generated spec | [
"WithUserNamespace",
"sets",
"the",
"uid",
"and",
"gid",
"mappings",
"for",
"the",
"task",
"this",
"can",
"be",
"called",
"multiple",
"times",
"to",
"add",
"more",
"mappings",
"to",
"the",
"generated",
"spec"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L416-L440 |
130,146 | containerd/containerd | oci/spec_opts.go | WithCgroup | func WithCgroup(path string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
s.Linux.CgroupsPath = path
return nil
}
} | go | func WithCgroup(path string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
s.Linux.CgroupsPath = path
return nil
}
} | [
"func",
"WithCgroup",
"(",
"path",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setLinux",
"(",
"s... | // WithCgroup sets the container's cgroup path | [
"WithCgroup",
"sets",
"the",
"container",
"s",
"cgroup",
"path"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L443-L449 |
130,147 | containerd/containerd | oci/spec_opts.go | WithNamespacedCgroup | func WithNamespacedCgroup() SpecOpts {
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
namespace, err := namespaces.NamespaceRequired(ctx)
if err != nil {
return err
}
setLinux(s)
s.Linux.CgroupsPath = filepath.Join("/", namespace, c.ID)
return nil
}
} | go | func WithNamespacedCgroup() SpecOpts {
return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error {
namespace, err := namespaces.NamespaceRequired(ctx)
if err != nil {
return err
}
setLinux(s)
s.Linux.CgroupsPath = filepath.Join("/", namespace, c.ID)
return nil
}
} | [
"func",
"WithNamespacedCgroup",
"(",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"ctx",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"c",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"namespace",
",",
"err",
":... | // WithNamespacedCgroup uses the namespace set on the context to create a
// root directory for containers in the cgroup with the id as the subcgroup | [
"WithNamespacedCgroup",
"uses",
"the",
"namespace",
"set",
"on",
"the",
"context",
"to",
"create",
"a",
"root",
"directory",
"for",
"containers",
"in",
"the",
"cgroup",
"with",
"the",
"id",
"as",
"the",
"subcgroup"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L453-L463 |
130,148 | containerd/containerd | oci/spec_opts.go | WithUIDGID | func WithUIDGID(uid, gid uint32) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.User.UID = uid
s.Process.User.GID = gid
return nil
}
} | go | func WithUIDGID(uid, gid uint32) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.User.UID = uid
s.Process.User.GID = gid
return nil
}
} | [
"func",
"WithUIDGID",
"(",
"uid",
",",
"gid",
"uint32",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setProc... | // WithUIDGID allows the UID and GID for the Process to be set | [
"WithUIDGID",
"allows",
"the",
"UID",
"and",
"GID",
"for",
"the",
"Process",
"to",
"be",
"set"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L547-L554 |
130,149 | containerd/containerd | oci/spec_opts.go | WithCapabilities | func WithCapabilities(caps []string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setCapabilities(s)
s.Process.Capabilities.Bounding = caps
s.Process.Capabilities.Effective = caps
s.Process.Capabilities.Permitted = caps
s.Process.Capabilities.Inheritable = ca... | go | func WithCapabilities(caps []string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setCapabilities(s)
s.Process.Capabilities.Bounding = caps
s.Process.Capabilities.Effective = caps
s.Process.Capabilities.Permitted = caps
s.Process.Capabilities.Inheritable = ca... | [
"func",
"WithCapabilities",
"(",
"caps",
"[",
"]",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"se... | // WithCapabilities sets Linux capabilities on the process | [
"WithCapabilities",
"sets",
"Linux",
"capabilities",
"on",
"the",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L730-L741 |
130,150 | containerd/containerd | oci/spec_opts.go | GetAllCapabilities | func GetAllCapabilities() []string {
last := capability.CAP_LAST_CAP
// hack for RHEL6 which has no /proc/sys/kernel/cap_last_cap
if last == capability.Cap(63) {
last = capability.CAP_BLOCK_SUSPEND
}
var caps []string
for _, cap := range capability.List() {
if cap > last {
continue
}
caps = append(caps... | go | func GetAllCapabilities() []string {
last := capability.CAP_LAST_CAP
// hack for RHEL6 which has no /proc/sys/kernel/cap_last_cap
if last == capability.Cap(63) {
last = capability.CAP_BLOCK_SUSPEND
}
var caps []string
for _, cap := range capability.List() {
if cap > last {
continue
}
caps = append(caps... | [
"func",
"GetAllCapabilities",
"(",
")",
"[",
"]",
"string",
"{",
"last",
":=",
"capability",
".",
"CAP_LAST_CAP",
"\n",
"// hack for RHEL6 which has no /proc/sys/kernel/cap_last_cap",
"if",
"last",
"==",
"capability",
".",
"Cap",
"(",
"63",
")",
"{",
"last",
"=",
... | // GetAllCapabilities returns all caps up to CAP_LAST_CAP
// or CAP_BLOCK_SUSPEND on RHEL6 | [
"GetAllCapabilities",
"returns",
"all",
"caps",
"up",
"to",
"CAP_LAST_CAP",
"or",
"CAP_BLOCK_SUSPEND",
"on",
"RHEL6"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L750-L764 |
130,151 | containerd/containerd | oci/spec_opts.go | WithAmbientCapabilities | func WithAmbientCapabilities(caps []string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setCapabilities(s)
s.Process.Capabilities.Ambient = caps
return nil
}
} | go | func WithAmbientCapabilities(caps []string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setCapabilities(s)
s.Process.Capabilities.Ambient = caps
return nil
}
} | [
"func",
"WithAmbientCapabilities",
"(",
"caps",
"[",
"]",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{"... | // WithAmbientCapabilities set the Linux ambient capabilities for the process
// Ambient capabilities should only be set for non-root users or the caller should
// understand how these capabilities are used and set | [
"WithAmbientCapabilities",
"set",
"the",
"Linux",
"ambient",
"capabilities",
"for",
"the",
"process",
"Ambient",
"capabilities",
"should",
"only",
"be",
"set",
"for",
"non",
"-",
"root",
"users",
"or",
"the",
"caller",
"should",
"understand",
"how",
"these",
"ca... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L827-L834 |
130,152 | containerd/containerd | oci/spec_opts.go | WithMaskedPaths | func WithMaskedPaths(paths []string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
s.Linux.MaskedPaths = paths
return nil
}
} | go | func WithMaskedPaths(paths []string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
s.Linux.MaskedPaths = paths
return nil
}
} | [
"func",
"WithMaskedPaths",
"(",
"paths",
"[",
"]",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"se... | // WithMaskedPaths sets the masked paths option | [
"WithMaskedPaths",
"sets",
"the",
"masked",
"paths",
"option"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L896-L902 |
130,153 | containerd/containerd | oci/spec_opts.go | WithReadonlyPaths | func WithReadonlyPaths(paths []string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
s.Linux.ReadonlyPaths = paths
return nil
}
} | go | func WithReadonlyPaths(paths []string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
s.Linux.ReadonlyPaths = paths
return nil
}
} | [
"func",
"WithReadonlyPaths",
"(",
"paths",
"[",
"]",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"... | // WithReadonlyPaths sets the read only paths option | [
"WithReadonlyPaths",
"sets",
"the",
"read",
"only",
"paths",
"option"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L905-L911 |
130,154 | containerd/containerd | oci/spec_opts.go | WithWriteableSysfs | func WithWriteableSysfs(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
for i, m := range s.Mounts {
if m.Type == "sysfs" {
var options []string
for _, o := range m.Options {
if o == "ro" {
o = "rw"
}
options = append(options, o)
}
s.Mounts[i].Options = options
}... | go | func WithWriteableSysfs(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
for i, m := range s.Mounts {
if m.Type == "sysfs" {
var options []string
for _, o := range m.Options {
if o == "ro" {
o = "rw"
}
options = append(options, o)
}
s.Mounts[i].Options = options
}... | [
"func",
"WithWriteableSysfs",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"for",
"i",
",",
"m",
":=",
"range",
"s",
".",
"Mounts",
"{",
"if",
"m",... | // WithWriteableSysfs makes any sysfs mounts writeable | [
"WithWriteableSysfs",
"makes",
"any",
"sysfs",
"mounts",
"writeable"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L914-L928 |
130,155 | containerd/containerd | oci/spec_opts.go | WithSelinuxLabel | func WithSelinuxLabel(label string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.SelinuxLabel = label
return nil
}
} | go | func WithSelinuxLabel(label string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.SelinuxLabel = label
return nil
}
} | [
"func",
"WithSelinuxLabel",
"(",
"label",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setProcess",
... | // WithSelinuxLabel sets the process SELinux label | [
"WithSelinuxLabel",
"sets",
"the",
"process",
"SELinux",
"label"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L948-L954 |
130,156 | containerd/containerd | oci/spec_opts.go | WithApparmorProfile | func WithApparmorProfile(profile string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.ApparmorProfile = profile
return nil
}
} | go | func WithApparmorProfile(profile string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setProcess(s)
s.Process.ApparmorProfile = profile
return nil
}
} | [
"func",
"WithApparmorProfile",
"(",
"profile",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setProcess... | // WithApparmorProfile sets the Apparmor profile for the process | [
"WithApparmorProfile",
"sets",
"the",
"Apparmor",
"profile",
"for",
"the",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L957-L963 |
130,157 | containerd/containerd | oci/spec_opts.go | WithSeccompUnconfined | func WithSeccompUnconfined(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
s.Linux.Seccomp = nil
return nil
} | go | func WithSeccompUnconfined(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
s.Linux.Seccomp = nil
return nil
} | [
"func",
"WithSeccompUnconfined",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setLinux",
"(",
"s",
")",
"\n",
"s",
".",
"Linux",
".",
"Seccomp",
"="... | // WithSeccompUnconfined clears the seccomp profile | [
"WithSeccompUnconfined",
"clears",
"the",
"seccomp",
"profile"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L966-L970 |
130,158 | containerd/containerd | oci/spec_opts.go | WithParentCgroupDevices | func WithParentCgroupDevices(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
if s.Linux.Resources == nil {
s.Linux.Resources = &specs.LinuxResources{}
}
s.Linux.Resources.Devices = nil
return nil
} | go | func WithParentCgroupDevices(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
setLinux(s)
if s.Linux.Resources == nil {
s.Linux.Resources = &specs.LinuxResources{}
}
s.Linux.Resources.Devices = nil
return nil
} | [
"func",
"WithParentCgroupDevices",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"setLinux",
"(",
"s",
")",
"\n",
"if",
"s",
".",
"Linux",
".",
"Resou... | // WithParentCgroupDevices uses the default cgroup setup to inherit the container's parent cgroup's
// allowed and denied devices | [
"WithParentCgroupDevices",
"uses",
"the",
"default",
"cgroup",
"setup",
"to",
"inherit",
"the",
"container",
"s",
"parent",
"cgroup",
"s",
"allowed",
"and",
"denied",
"devices"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L974-L981 |
130,159 | containerd/containerd | oci/spec_opts.go | WithWindowsHyperV | func WithWindowsHyperV(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
if s.Windows == nil {
s.Windows = &specs.Windows{}
}
if s.Windows.HyperV == nil {
s.Windows.HyperV = &specs.WindowsHyperV{}
}
return nil
} | go | func WithWindowsHyperV(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
if s.Windows == nil {
s.Windows = &specs.Windows{}
}
if s.Windows.HyperV == nil {
s.Windows.HyperV = &specs.WindowsHyperV{}
}
return nil
} | [
"func",
"WithWindowsHyperV",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"if",
"s",
".",
"Windows",
"==",
"nil",
"{",
"s",
".",
"Windows",
"=",
"&... | // WithWindowsHyperV sets the Windows.HyperV section for HyperV isolation of containers. | [
"WithWindowsHyperV",
"sets",
"the",
"Windows",
".",
"HyperV",
"section",
"for",
"HyperV",
"isolation",
"of",
"containers",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L1090-L1098 |
130,160 | containerd/containerd | oci/spec_opts.go | WithMemoryLimit | func WithMemoryLimit(limit uint64) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
if s.Linux != nil {
if s.Linux.Resources == nil {
s.Linux.Resources = &specs.LinuxResources{}
}
if s.Linux.Resources.Memory == nil {
s.Linux.Resources.Memory = &specs.Linu... | go | func WithMemoryLimit(limit uint64) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
if s.Linux != nil {
if s.Linux.Resources == nil {
s.Linux.Resources = &specs.LinuxResources{}
}
if s.Linux.Resources.Memory == nil {
s.Linux.Resources.Memory = &specs.Linu... | [
"func",
"WithMemoryLimit",
"(",
"limit",
"uint64",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
")",
"error",
"{",
"if",
"s",
".... | // WithMemoryLimit sets the `Linux.LinuxResources.Memory.Limit` section to the
// `limit` specified if the `Linux` section is not `nil`. Additionally sets the
// `Windows.WindowsResources.Memory.Limit` section if the `Windows` section is
// not `nil`. | [
"WithMemoryLimit",
"sets",
"the",
"Linux",
".",
"LinuxResources",
".",
"Memory",
".",
"Limit",
"section",
"to",
"the",
"limit",
"specified",
"if",
"the",
"Linux",
"section",
"is",
"not",
"nil",
".",
"Additionally",
"sets",
"the",
"Windows",
".",
"WindowsResour... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L1104-L1127 |
130,161 | containerd/containerd | oci/spec_opts.go | WithAnnotations | func WithAnnotations(annotations map[string]string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
if s.Annotations == nil {
s.Annotations = make(map[string]string)
}
for k, v := range annotations {
s.Annotations[k] = v
}
return nil
}
} | go | func WithAnnotations(annotations map[string]string) SpecOpts {
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
if s.Annotations == nil {
s.Annotations = make(map[string]string)
}
for k, v := range annotations {
s.Annotations[k] = v
}
return nil
}
} | [
"func",
"WithAnnotations",
"(",
"annotations",
"map",
"[",
"string",
"]",
"string",
")",
"SpecOpts",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"Client",
",",
"_",
"*",
"containers",
".",
"Container",
",",
"s",
"*",
"Spec",
"... | // WithAnnotations appends or replaces the annotations on the spec with the
// provided annotations | [
"WithAnnotations",
"appends",
"or",
"replaces",
"the",
"annotations",
"on",
"the",
"spec",
"with",
"the",
"provided",
"annotations"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/oci/spec_opts.go#L1131-L1141 |
130,162 | containerd/containerd | labels/validate.go | Validate | func Validate(k, v string) error {
if (len(k) + len(v)) > maxSize {
if len(k) > 10 {
k = k[:10]
}
return errors.Wrapf(errdefs.ErrInvalidArgument, "label key and value greater than maximum size (%d bytes), key: %s", maxSize, k)
}
return nil
} | go | func Validate(k, v string) error {
if (len(k) + len(v)) > maxSize {
if len(k) > 10 {
k = k[:10]
}
return errors.Wrapf(errdefs.ErrInvalidArgument, "label key and value greater than maximum size (%d bytes), key: %s", maxSize, k)
}
return nil
} | [
"func",
"Validate",
"(",
"k",
",",
"v",
"string",
")",
"error",
"{",
"if",
"(",
"len",
"(",
"k",
")",
"+",
"len",
"(",
"v",
")",
")",
">",
"maxSize",
"{",
"if",
"len",
"(",
"k",
")",
">",
"10",
"{",
"k",
"=",
"k",
"[",
":",
"10",
"]",
"... | // Validate a label's key and value are under 4096 bytes | [
"Validate",
"a",
"label",
"s",
"key",
"and",
"value",
"are",
"under",
"4096",
"bytes"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/labels/validate.go#L29-L37 |
130,163 | containerd/containerd | windows/io.go | newPipeSet | func newPipeSet(ctx context.Context, io runtime.IO) (*pipeSet, error) {
var (
err error
c net.Conn
wg sync.WaitGroup
set = &pipeSet{src: io}
ch = make(chan error)
opened = 0
)
defer func() {
if err != nil {
go func() {
for i := 0; i < opened; i++ {
// Drain the channel t... | go | func newPipeSet(ctx context.Context, io runtime.IO) (*pipeSet, error) {
var (
err error
c net.Conn
wg sync.WaitGroup
set = &pipeSet{src: io}
ch = make(chan error)
opened = 0
)
defer func() {
if err != nil {
go func() {
for i := 0; i < opened; i++ {
// Drain the channel t... | [
"func",
"newPipeSet",
"(",
"ctx",
"context",
".",
"Context",
",",
"io",
"runtime",
".",
"IO",
")",
"(",
"*",
"pipeSet",
",",
"error",
")",
"{",
"var",
"(",
"err",
"error",
"\n",
"c",
"net",
".",
"Conn",
"\n",
"wg",
"sync",
".",
"WaitGroup",
"\n",
... | // NewIO connects to the provided pipe addresses | [
"NewIO",
"connects",
"to",
"the",
"provided",
"pipe",
"addresses"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/windows/io.go#L40-L117 |
130,164 | containerd/containerd | windows/io.go | Close | func (p *pipeSet) Close() {
for _, cn := range []net.Conn{p.stdin, p.stdout, p.stderr} {
if cn != nil {
cn.Close()
}
}
} | go | func (p *pipeSet) Close() {
for _, cn := range []net.Conn{p.stdin, p.stdout, p.stderr} {
if cn != nil {
cn.Close()
}
}
} | [
"func",
"(",
"p",
"*",
"pipeSet",
")",
"Close",
"(",
")",
"{",
"for",
"_",
",",
"cn",
":=",
"range",
"[",
"]",
"net",
".",
"Conn",
"{",
"p",
".",
"stdin",
",",
"p",
".",
"stdout",
",",
"p",
".",
"stderr",
"}",
"{",
"if",
"cn",
"!=",
"nil",
... | // Close terminates all successfully dialed IO connections | [
"Close",
"terminates",
"all",
"successfully",
"dialed",
"IO",
"connections"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/windows/io.go#L120-L126 |
130,165 | containerd/containerd | services/server/server_linux.go | apply | func apply(ctx context.Context, config *srvconfig.Config) error {
if config.OOMScore != 0 {
log.G(ctx).Debugf("changing OOM score to %d", config.OOMScore)
if err := sys.SetOOMScore(os.Getpid(), config.OOMScore); err != nil {
log.G(ctx).WithError(err).Errorf("failed to change OOM score to %d", config.OOMScore)
... | go | func apply(ctx context.Context, config *srvconfig.Config) error {
if config.OOMScore != 0 {
log.G(ctx).Debugf("changing OOM score to %d", config.OOMScore)
if err := sys.SetOOMScore(os.Getpid(), config.OOMScore); err != nil {
log.G(ctx).WithError(err).Errorf("failed to change OOM score to %d", config.OOMScore)
... | [
"func",
"apply",
"(",
"ctx",
"context",
".",
"Context",
",",
"config",
"*",
"srvconfig",
".",
"Config",
")",
"error",
"{",
"if",
"config",
".",
"OOMScore",
"!=",
"0",
"{",
"log",
".",
"G",
"(",
"ctx",
")",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"co... | // apply sets config settings on the server process | [
"apply",
"sets",
"config",
"settings",
"on",
"the",
"server",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/services/server/server_linux.go#L32-L56 |
130,166 | containerd/containerd | signals.go | GetOCIStopSignal | func GetOCIStopSignal(ctx context.Context, image Image, defaultSignal string) (string, error) {
_, err := ParseSignal(defaultSignal)
if err != nil {
return "", err
}
ic, err := image.Config(ctx)
if err != nil {
return "", err
}
var (
ociimage v1.Image
config v1.ImageConfig
)
switch ic.MediaType {
ca... | go | func GetOCIStopSignal(ctx context.Context, image Image, defaultSignal string) (string, error) {
_, err := ParseSignal(defaultSignal)
if err != nil {
return "", err
}
ic, err := image.Config(ctx)
if err != nil {
return "", err
}
var (
ociimage v1.Image
config v1.ImageConfig
)
switch ic.MediaType {
ca... | [
"func",
"GetOCIStopSignal",
"(",
"ctx",
"context",
".",
"Context",
",",
"image",
"Image",
",",
"defaultSignal",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"ParseSignal",
"(",
"defaultSignal",
")",
"\n",
"if",
"err",
"!="... | // GetOCIStopSignal retrieves the stop signal specified in the OCI image config | [
"GetOCIStopSignal",
"retrieves",
"the",
"stop",
"signal",
"specified",
"in",
"the",
"OCI",
"image",
"config"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/signals.go#L50-L83 |
130,167 | containerd/containerd | metadata/boltutil/helpers.go | ReadLabels | func ReadLabels(bkt *bolt.Bucket) (map[string]string, error) {
return readMap(bkt, bucketKeyLabels)
} | go | func ReadLabels(bkt *bolt.Bucket) (map[string]string, error) {
return readMap(bkt, bucketKeyLabels)
} | [
"func",
"ReadLabels",
"(",
"bkt",
"*",
"bolt",
".",
"Bucket",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"return",
"readMap",
"(",
"bkt",
",",
"bucketKeyLabels",
")",
"\n",
"}"
] | // ReadLabels reads the labels key from the bucket
// Uses the key "labels" | [
"ReadLabels",
"reads",
"the",
"labels",
"key",
"from",
"the",
"bucket",
"Uses",
"the",
"key",
"labels"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/metadata/boltutil/helpers.go#L35-L37 |
130,168 | containerd/containerd | metadata/boltutil/helpers.go | ReadAnnotations | func ReadAnnotations(bkt *bolt.Bucket) (map[string]string, error) {
return readMap(bkt, bucketKeyAnnotations)
} | go | func ReadAnnotations(bkt *bolt.Bucket) (map[string]string, error) {
return readMap(bkt, bucketKeyAnnotations)
} | [
"func",
"ReadAnnotations",
"(",
"bkt",
"*",
"bolt",
".",
"Bucket",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"return",
"readMap",
"(",
"bkt",
",",
"bucketKeyAnnotations",
")",
"\n",
"}"
] | // ReadAnnotations reads the OCI Descriptor Annotations key from the bucket
// Uses the key "annotations" | [
"ReadAnnotations",
"reads",
"the",
"OCI",
"Descriptor",
"Annotations",
"key",
"from",
"the",
"bucket",
"Uses",
"the",
"key",
"annotations"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/metadata/boltutil/helpers.go#L41-L43 |
130,169 | containerd/containerd | metadata/boltutil/helpers.go | WriteLabels | func WriteLabels(bkt *bolt.Bucket, labels map[string]string) error {
return writeMap(bkt, bucketKeyLabels, labels)
} | go | func WriteLabels(bkt *bolt.Bucket, labels map[string]string) error {
return writeMap(bkt, bucketKeyLabels, labels)
} | [
"func",
"WriteLabels",
"(",
"bkt",
"*",
"bolt",
".",
"Bucket",
",",
"labels",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"return",
"writeMap",
"(",
"bkt",
",",
"bucketKeyLabels",
",",
"labels",
")",
"\n",
"}"
] | // WriteLabels will write a new labels bucket to the provided bucket at key
// bucketKeyLabels, replacing the contents of the bucket with the provided map.
//
// The provide map labels will be modified to have the final contents of the
// bucket. Typically, this removes zero-value entries.
// Uses the key "labels" | [
"WriteLabels",
"will",
"write",
"a",
"new",
"labels",
"bucket",
"to",
"the",
"provided",
"bucket",
"at",
"key",
"bucketKeyLabels",
"replacing",
"the",
"contents",
"of",
"the",
"bucket",
"with",
"the",
"provided",
"map",
".",
"The",
"provide",
"map",
"labels",
... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/metadata/boltutil/helpers.go#L66-L68 |
130,170 | containerd/containerd | metadata/boltutil/helpers.go | WriteAnnotations | func WriteAnnotations(bkt *bolt.Bucket, labels map[string]string) error {
return writeMap(bkt, bucketKeyAnnotations, labels)
} | go | func WriteAnnotations(bkt *bolt.Bucket, labels map[string]string) error {
return writeMap(bkt, bucketKeyAnnotations, labels)
} | [
"func",
"WriteAnnotations",
"(",
"bkt",
"*",
"bolt",
".",
"Bucket",
",",
"labels",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"return",
"writeMap",
"(",
"bkt",
",",
"bucketKeyAnnotations",
",",
"labels",
")",
"\n",
"}"
] | // WriteAnnotations writes the OCI Descriptor Annotations | [
"WriteAnnotations",
"writes",
"the",
"OCI",
"Descriptor",
"Annotations"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/metadata/boltutil/helpers.go#L71-L73 |
130,171 | containerd/containerd | metadata/boltutil/helpers.go | ReadTimestamps | func ReadTimestamps(bkt *bolt.Bucket, created, updated *time.Time) error {
for _, f := range []struct {
b []byte
t *time.Time
}{
{bucketKeyCreatedAt, created},
{bucketKeyUpdatedAt, updated},
} {
v := bkt.Get(f.b)
if v != nil {
if err := f.t.UnmarshalBinary(v); err != nil {
return err
}
}
}
... | go | func ReadTimestamps(bkt *bolt.Bucket, created, updated *time.Time) error {
for _, f := range []struct {
b []byte
t *time.Time
}{
{bucketKeyCreatedAt, created},
{bucketKeyUpdatedAt, updated},
} {
v := bkt.Get(f.b)
if v != nil {
if err := f.t.UnmarshalBinary(v); err != nil {
return err
}
}
}
... | [
"func",
"ReadTimestamps",
"(",
"bkt",
"*",
"bolt",
".",
"Bucket",
",",
"created",
",",
"updated",
"*",
"time",
".",
"Time",
")",
"error",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"[",
"]",
"struct",
"{",
"b",
"[",
"]",
"byte",
"\n",
"t",
"*",
... | // ReadTimestamps reads created and updated timestamps from a bucket.
// Uses keys "createdat" and "updatedat" | [
"ReadTimestamps",
"reads",
"created",
"and",
"updated",
"timestamps",
"from",
"a",
"bucket",
".",
"Uses",
"keys",
"createdat",
"and",
"updatedat"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/metadata/boltutil/helpers.go#L108-L124 |
130,172 | containerd/containerd | metadata/boltutil/helpers.go | WriteTimestamps | func WriteTimestamps(bkt *bolt.Bucket, created, updated time.Time) error {
createdAt, err := created.MarshalBinary()
if err != nil {
return err
}
updatedAt, err := updated.MarshalBinary()
if err != nil {
return err
}
for _, v := range [][2][]byte{
{bucketKeyCreatedAt, createdAt},
{bucketKeyUpdatedAt, upd... | go | func WriteTimestamps(bkt *bolt.Bucket, created, updated time.Time) error {
createdAt, err := created.MarshalBinary()
if err != nil {
return err
}
updatedAt, err := updated.MarshalBinary()
if err != nil {
return err
}
for _, v := range [][2][]byte{
{bucketKeyCreatedAt, createdAt},
{bucketKeyUpdatedAt, upd... | [
"func",
"WriteTimestamps",
"(",
"bkt",
"*",
"bolt",
".",
"Bucket",
",",
"created",
",",
"updated",
"time",
".",
"Time",
")",
"error",
"{",
"createdAt",
",",
"err",
":=",
"created",
".",
"MarshalBinary",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // WriteTimestamps writes created and updated timestamps to a bucket.
// Uses keys "createdat" and "updatedat" | [
"WriteTimestamps",
"writes",
"created",
"and",
"updated",
"timestamps",
"to",
"a",
"bucket",
".",
"Uses",
"keys",
"createdat",
"and",
"updatedat"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/metadata/boltutil/helpers.go#L128-L147 |
130,173 | containerd/containerd | process.go | NewExitStatus | func NewExitStatus(code uint32, t time.Time, err error) *ExitStatus {
return &ExitStatus{
code: code,
exitedAt: t,
err: err,
}
} | go | func NewExitStatus(code uint32, t time.Time, err error) *ExitStatus {
return &ExitStatus{
code: code,
exitedAt: t,
err: err,
}
} | [
"func",
"NewExitStatus",
"(",
"code",
"uint32",
",",
"t",
"time",
".",
"Time",
",",
"err",
"error",
")",
"*",
"ExitStatus",
"{",
"return",
"&",
"ExitStatus",
"{",
"code",
":",
"code",
",",
"exitedAt",
":",
"t",
",",
"err",
":",
"err",
",",
"}",
"\n... | // NewExitStatus populates an ExitStatus | [
"NewExitStatus",
"populates",
"an",
"ExitStatus"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/process.go#L56-L62 |
130,174 | containerd/containerd | process.go | Result | func (s ExitStatus) Result() (uint32, time.Time, error) {
return s.code, s.exitedAt, s.err
} | go | func (s ExitStatus) Result() (uint32, time.Time, error) {
return s.code, s.exitedAt, s.err
} | [
"func",
"(",
"s",
"ExitStatus",
")",
"Result",
"(",
")",
"(",
"uint32",
",",
"time",
".",
"Time",
",",
"error",
")",
"{",
"return",
"s",
".",
"code",
",",
"s",
".",
"exitedAt",
",",
"s",
".",
"err",
"\n",
"}"
] | // Result returns the exit code and time of the exit status.
// An error may be returned here to which indicates there was an error
// at some point while waiting for the exit status. It does not signify
// an error with the process itself.
// If an error is returned, the process may still be running. | [
"Result",
"returns",
"the",
"exit",
"code",
"and",
"time",
"of",
"the",
"exit",
"status",
".",
"An",
"error",
"may",
"be",
"returned",
"here",
"to",
"which",
"indicates",
"there",
"was",
"an",
"error",
"at",
"some",
"point",
"while",
"waiting",
"for",
"t... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/process.go#L77-L79 |
130,175 | containerd/containerd | process.go | Start | func (p *process) Start(ctx context.Context) error {
r, err := p.task.client.TaskService().Start(ctx, &tasks.StartRequest{
ContainerID: p.task.id,
ExecID: p.id,
})
if err != nil {
if p.io != nil {
p.io.Cancel()
p.io.Wait()
p.io.Close()
}
return errdefs.FromGRPC(err)
}
p.pid = r.Pid
return ... | go | func (p *process) Start(ctx context.Context) error {
r, err := p.task.client.TaskService().Start(ctx, &tasks.StartRequest{
ContainerID: p.task.id,
ExecID: p.id,
})
if err != nil {
if p.io != nil {
p.io.Cancel()
p.io.Wait()
p.io.Close()
}
return errdefs.FromGRPC(err)
}
p.pid = r.Pid
return ... | [
"func",
"(",
"p",
"*",
"process",
")",
"Start",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"r",
",",
"err",
":=",
"p",
".",
"task",
".",
"client",
".",
"TaskService",
"(",
")",
".",
"Start",
"(",
"ctx",
",",
"&",
"tasks",
".",
"S... | // Start starts the exec process | [
"Start",
"starts",
"the",
"exec",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/process.go#L117-L132 |
130,176 | containerd/containerd | namespaces/context.go | WithNamespace | func WithNamespace(ctx context.Context, namespace string) context.Context {
ctx = context.WithValue(ctx, namespaceKey{}, namespace) // set our key for namespace
// also store on the grpc headers so it gets picked up by any clients that
// are using this.
return withGRPCNamespaceHeader(ctx, namespace)
} | go | func WithNamespace(ctx context.Context, namespace string) context.Context {
ctx = context.WithValue(ctx, namespaceKey{}, namespace) // set our key for namespace
// also store on the grpc headers so it gets picked up by any clients that
// are using this.
return withGRPCNamespaceHeader(ctx, namespace)
} | [
"func",
"WithNamespace",
"(",
"ctx",
"context",
".",
"Context",
",",
"namespace",
"string",
")",
"context",
".",
"Context",
"{",
"ctx",
"=",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"namespaceKey",
"{",
"}",
",",
"namespace",
")",
"// set our key for na... | // WithNamespace sets a given namespace on the context | [
"WithNamespace",
"sets",
"a",
"given",
"namespace",
"on",
"the",
"context"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/namespaces/context.go#L37-L43 |
130,177 | containerd/containerd | namespaces/context.go | NamespaceFromEnv | func NamespaceFromEnv(ctx context.Context) context.Context {
namespace := os.Getenv(NamespaceEnvVar)
if namespace == "" {
namespace = Default
}
return WithNamespace(ctx, namespace)
} | go | func NamespaceFromEnv(ctx context.Context) context.Context {
namespace := os.Getenv(NamespaceEnvVar)
if namespace == "" {
namespace = Default
}
return WithNamespace(ctx, namespace)
} | [
"func",
"NamespaceFromEnv",
"(",
"ctx",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"namespace",
":=",
"os",
".",
"Getenv",
"(",
"NamespaceEnvVar",
")",
"\n",
"if",
"namespace",
"==",
"\"",
"\"",
"{",
"namespace",
"=",
"Default",
"\n",
... | // NamespaceFromEnv uses the namespace defined in CONTAINERD_NAMESPACE or
// default | [
"NamespaceFromEnv",
"uses",
"the",
"namespace",
"defined",
"in",
"CONTAINERD_NAMESPACE",
"or",
"default"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/namespaces/context.go#L47-L53 |
130,178 | containerd/containerd | namespaces/context.go | Namespace | func Namespace(ctx context.Context) (string, bool) {
namespace, ok := ctx.Value(namespaceKey{}).(string)
if !ok {
return fromGRPCHeader(ctx)
}
return namespace, ok
} | go | func Namespace(ctx context.Context) (string, bool) {
namespace, ok := ctx.Value(namespaceKey{}).(string)
if !ok {
return fromGRPCHeader(ctx)
}
return namespace, ok
} | [
"func",
"Namespace",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"bool",
")",
"{",
"namespace",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"namespaceKey",
"{",
"}",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"re... | // Namespace returns the namespace from the context.
//
// The namespace is not guaranteed to be valid. | [
"Namespace",
"returns",
"the",
"namespace",
"from",
"the",
"context",
".",
"The",
"namespace",
"is",
"not",
"guaranteed",
"to",
"be",
"valid",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/namespaces/context.go#L58-L65 |
130,179 | containerd/containerd | namespaces/context.go | NamespaceRequired | func NamespaceRequired(ctx context.Context) (string, error) {
namespace, ok := Namespace(ctx)
if !ok || namespace == "" {
return "", errors.Wrapf(errdefs.ErrFailedPrecondition, "namespace is required")
}
if err := Validate(namespace); err != nil {
return "", errors.Wrap(err, "namespace validation")
}
return... | go | func NamespaceRequired(ctx context.Context) (string, error) {
namespace, ok := Namespace(ctx)
if !ok || namespace == "" {
return "", errors.Wrapf(errdefs.ErrFailedPrecondition, "namespace is required")
}
if err := Validate(namespace); err != nil {
return "", errors.Wrap(err, "namespace validation")
}
return... | [
"func",
"NamespaceRequired",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"string",
",",
"error",
")",
"{",
"namespace",
",",
"ok",
":=",
"Namespace",
"(",
"ctx",
")",
"\n",
"if",
"!",
"ok",
"||",
"namespace",
"==",
"\"",
"\"",
"{",
"return",
"\"... | // NamespaceRequired returns the valid namepace from the context or an error. | [
"NamespaceRequired",
"returns",
"the",
"valid",
"namepace",
"from",
"the",
"context",
"or",
"an",
"error",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/namespaces/context.go#L68-L79 |
130,180 | containerd/containerd | runtime/v2/runc/util.go | GetTopic | func GetTopic(e interface{}) string {
switch e.(type) {
case *events.TaskCreate:
return runtime.TaskCreateEventTopic
case *events.TaskStart:
return runtime.TaskStartEventTopic
case *events.TaskOOM:
return runtime.TaskOOMEventTopic
case *events.TaskExit:
return runtime.TaskExitEventTopic
case *events.TaskD... | go | func GetTopic(e interface{}) string {
switch e.(type) {
case *events.TaskCreate:
return runtime.TaskCreateEventTopic
case *events.TaskStart:
return runtime.TaskStartEventTopic
case *events.TaskOOM:
return runtime.TaskOOMEventTopic
case *events.TaskExit:
return runtime.TaskExitEventTopic
case *events.TaskD... | [
"func",
"GetTopic",
"(",
"e",
"interface",
"{",
"}",
")",
"string",
"{",
"switch",
"e",
".",
"(",
"type",
")",
"{",
"case",
"*",
"events",
".",
"TaskCreate",
":",
"return",
"runtime",
".",
"TaskCreateEventTopic",
"\n",
"case",
"*",
"events",
".",
"Task... | // GetTopic converts an event from an interface type to the specific
// event topic id | [
"GetTopic",
"converts",
"an",
"event",
"from",
"an",
"interface",
"type",
"to",
"the",
"specific",
"event",
"topic",
"id"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/v2/runc/util.go#L29-L55 |
130,181 | containerd/containerd | rootfs/diff.go | CreateDiff | func CreateDiff(ctx context.Context, snapshotID string, sn snapshots.Snapshotter, d diff.Comparer, opts ...diff.Opt) (ocispec.Descriptor, error) {
info, err := sn.Stat(ctx, snapshotID)
if err != nil {
return ocispec.Descriptor{}, err
}
lowerKey := fmt.Sprintf("%s-parent-view", info.Parent)
lower, err := sn.View... | go | func CreateDiff(ctx context.Context, snapshotID string, sn snapshots.Snapshotter, d diff.Comparer, opts ...diff.Opt) (ocispec.Descriptor, error) {
info, err := sn.Stat(ctx, snapshotID)
if err != nil {
return ocispec.Descriptor{}, err
}
lowerKey := fmt.Sprintf("%s-parent-view", info.Parent)
lower, err := sn.View... | [
"func",
"CreateDiff",
"(",
"ctx",
"context",
".",
"Context",
",",
"snapshotID",
"string",
",",
"sn",
"snapshots",
".",
"Snapshotter",
",",
"d",
"diff",
".",
"Comparer",
",",
"opts",
"...",
"diff",
".",
"Opt",
")",
"(",
"ocispec",
".",
"Descriptor",
",",
... | // CreateDiff creates a layer diff for the given snapshot identifier from the
// parent of the snapshot. A content ref is provided to track the progress of
// the content creation and the provided snapshotter and mount differ are used
// for calculating the diff. The descriptor for the layer diff is returned. | [
"CreateDiff",
"creates",
"a",
"layer",
"diff",
"for",
"the",
"given",
"snapshot",
"identifier",
"from",
"the",
"parent",
"of",
"the",
"snapshot",
".",
"A",
"content",
"ref",
"is",
"provided",
"to",
"track",
"the",
"progress",
"of",
"the",
"content",
"creatio... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/rootfs/diff.go#L33-L62 |
130,182 | containerd/containerd | pkg/progress/writer.go | Write | func (w *Writer) Write(p []byte) (n int, err error) {
return w.buf.Write(p)
} | go | func (w *Writer) Write(p []byte) (n int, err error) {
return w.buf.Write(p)
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"return",
"w",
".",
"buf",
".",
"Write",
"(",
"p",
")",
"\n",
"}"
] | // Write the provided bytes | [
"Write",
"the",
"provided",
"bytes"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/pkg/progress/writer.go#L52-L54 |
130,183 | containerd/containerd | pkg/progress/writer.go | Flush | func (w *Writer) Flush() error {
if w.buf.Len() == 0 {
return nil
}
if err := w.clearLines(); err != nil {
return err
}
w.lines = countLines(w.buf.String())
if _, err := w.w.Write(w.buf.Bytes()); err != nil {
return err
}
w.buf.Reset()
return nil
} | go | func (w *Writer) Flush() error {
if w.buf.Len() == 0 {
return nil
}
if err := w.clearLines(); err != nil {
return err
}
w.lines = countLines(w.buf.String())
if _, err := w.w.Write(w.buf.Bytes()); err != nil {
return err
}
w.buf.Reset()
return nil
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Flush",
"(",
")",
"error",
"{",
"if",
"w",
".",
"buf",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"w",
".",
"clearLines",
"(",
")",
";",
"err",
"!=",
"... | // Flush should be called when refreshing the current display. | [
"Flush",
"should",
"be",
"called",
"when",
"refreshing",
"the",
"current",
"display",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/pkg/progress/writer.go#L57-L73 |
130,184 | containerd/containerd | pkg/progress/writer.go | countLines | func countLines(output string) int {
con, err := console.ConsoleFromFile(os.Stdin)
if err != nil {
return 0
}
ws, err := con.Size()
if err != nil {
return 0
}
width := int(ws.Width)
if width <= 0 {
return 0
}
strlines := strings.Split(output, "\n")
lines := -1
for _, line := range strlines {
lines +... | go | func countLines(output string) int {
con, err := console.ConsoleFromFile(os.Stdin)
if err != nil {
return 0
}
ws, err := con.Size()
if err != nil {
return 0
}
width := int(ws.Width)
if width <= 0 {
return 0
}
strlines := strings.Split(output, "\n")
lines := -1
for _, line := range strlines {
lines +... | [
"func",
"countLines",
"(",
"output",
"string",
")",
"int",
"{",
"con",
",",
"err",
":=",
"console",
".",
"ConsoleFromFile",
"(",
"os",
".",
"Stdin",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"ws",
",",
"err",
":=",
... | // countLines in the output. If a line is longer than the console width then
// an extra line is added to the count for each wrapped line. If the console
// width is undefined then 0 is returned so that no lines are cleared on the next
// flush. | [
"countLines",
"in",
"the",
"output",
".",
"If",
"a",
"line",
"is",
"longer",
"than",
"the",
"console",
"width",
"then",
"an",
"extra",
"line",
"is",
"added",
"to",
"the",
"count",
"for",
"each",
"wrapped",
"line",
".",
"If",
"the",
"console",
"width",
... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/pkg/progress/writer.go#L92-L111 |
130,185 | containerd/containerd | sys/reaper_linux.go | GetSubreaper | func GetSubreaper() (int, error) {
var i uintptr
if err := unix.Prctl(unix.PR_GET_CHILD_SUBREAPER, uintptr(unsafe.Pointer(&i)), 0, 0, 0); err != nil {
return -1, err
}
return int(i), nil
} | go | func GetSubreaper() (int, error) {
var i uintptr
if err := unix.Prctl(unix.PR_GET_CHILD_SUBREAPER, uintptr(unsafe.Pointer(&i)), 0, 0, 0); err != nil {
return -1, err
}
return int(i), nil
} | [
"func",
"GetSubreaper",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"i",
"uintptr",
"\n\n",
"if",
"err",
":=",
"unix",
".",
"Prctl",
"(",
"unix",
".",
"PR_GET_CHILD_SUBREAPER",
",",
"uintptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"i",
")... | // GetSubreaper returns the subreaper setting for the calling process | [
"GetSubreaper",
"returns",
"the",
"subreaper",
"setting",
"for",
"the",
"calling",
"process"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/sys/reaper_linux.go#L44-L52 |
130,186 | containerd/containerd | images/archive/reference.go | refTranslator | func refTranslator(image string, checkPrefix bool) func(string) string {
return func(ref string) string {
// Check if ref is full reference
if strings.ContainsAny(ref, "/:@") {
// If not prefixed, don't include image
if checkPrefix && !isImagePrefix(ref, image) {
return ""
}
return ref
}
return... | go | func refTranslator(image string, checkPrefix bool) func(string) string {
return func(ref string) string {
// Check if ref is full reference
if strings.ContainsAny(ref, "/:@") {
// If not prefixed, don't include image
if checkPrefix && !isImagePrefix(ref, image) {
return ""
}
return ref
}
return... | [
"func",
"refTranslator",
"(",
"image",
"string",
",",
"checkPrefix",
"bool",
")",
"func",
"(",
"string",
")",
"string",
"{",
"return",
"func",
"(",
"ref",
"string",
")",
"string",
"{",
"// Check if ref is full reference",
"if",
"strings",
".",
"ContainsAny",
"... | // refTranslator creates a reference which only has a tag or verifies
// a full reference. | [
"refTranslator",
"creates",
"a",
"reference",
"which",
"only",
"has",
"a",
"tag",
"or",
"verifies",
"a",
"full",
"reference",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/images/archive/reference.go#L41-L53 |
130,187 | containerd/containerd | images/archive/reference.go | DigestTranslator | func DigestTranslator(prefix string) func(digest.Digest) string {
return func(dgst digest.Digest) string {
return prefix + "@" + dgst.String()
}
} | go | func DigestTranslator(prefix string) func(digest.Digest) string {
return func(dgst digest.Digest) string {
return prefix + "@" + dgst.String()
}
} | [
"func",
"DigestTranslator",
"(",
"prefix",
"string",
")",
"func",
"(",
"digest",
".",
"Digest",
")",
"string",
"{",
"return",
"func",
"(",
"dgst",
"digest",
".",
"Digest",
")",
"string",
"{",
"return",
"prefix",
"+",
"\"",
"\"",
"+",
"dgst",
".",
"Stri... | // DigestTranslator creates a digest reference by adding the
// digest to an image name | [
"DigestTranslator",
"creates",
"a",
"digest",
"reference",
"by",
"adding",
"the",
"digest",
"to",
"an",
"image",
"name"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/images/archive/reference.go#L82-L86 |
130,188 | containerd/containerd | runtime/restart/restart.go | WithLogPath | func WithLogPath(path string) func(context.Context, *containerd.Client, *containers.Container) error {
return func(_ context.Context, _ *containerd.Client, c *containers.Container) error {
ensureLabels(c)
c.Labels[LogPathLabel] = path
return nil
}
} | go | func WithLogPath(path string) func(context.Context, *containerd.Client, *containers.Container) error {
return func(_ context.Context, _ *containerd.Client, c *containers.Container) error {
ensureLabels(c)
c.Labels[LogPathLabel] = path
return nil
}
} | [
"func",
"WithLogPath",
"(",
"path",
"string",
")",
"func",
"(",
"context",
".",
"Context",
",",
"*",
"containerd",
".",
"Client",
",",
"*",
"containers",
".",
"Container",
")",
"error",
"{",
"return",
"func",
"(",
"_",
"context",
".",
"Context",
",",
"... | // WithLogPath sets the log path for a container | [
"WithLogPath",
"sets",
"the",
"log",
"path",
"for",
"a",
"container"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/restart/restart.go#L47-L53 |
130,189 | containerd/containerd | runtime/restart/restart.go | WithStatus | func WithStatus(status containerd.ProcessStatus) func(context.Context, *containerd.Client, *containers.Container) error {
return func(_ context.Context, _ *containerd.Client, c *containers.Container) error {
ensureLabels(c)
c.Labels[StatusLabel] = string(status)
return nil
}
} | go | func WithStatus(status containerd.ProcessStatus) func(context.Context, *containerd.Client, *containers.Container) error {
return func(_ context.Context, _ *containerd.Client, c *containers.Container) error {
ensureLabels(c)
c.Labels[StatusLabel] = string(status)
return nil
}
} | [
"func",
"WithStatus",
"(",
"status",
"containerd",
".",
"ProcessStatus",
")",
"func",
"(",
"context",
".",
"Context",
",",
"*",
"containerd",
".",
"Client",
",",
"*",
"containers",
".",
"Container",
")",
"error",
"{",
"return",
"func",
"(",
"_",
"context",... | // WithStatus sets the status for a container | [
"WithStatus",
"sets",
"the",
"status",
"for",
"a",
"container"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/restart/restart.go#L56-L62 |
130,190 | containerd/containerd | runtime/restart/restart.go | WithNoRestarts | func WithNoRestarts(_ context.Context, _ *containerd.Client, c *containers.Container) error {
if c.Labels == nil {
return nil
}
delete(c.Labels, StatusLabel)
delete(c.Labels, LogPathLabel)
return nil
} | go | func WithNoRestarts(_ context.Context, _ *containerd.Client, c *containers.Container) error {
if c.Labels == nil {
return nil
}
delete(c.Labels, StatusLabel)
delete(c.Labels, LogPathLabel)
return nil
} | [
"func",
"WithNoRestarts",
"(",
"_",
"context",
".",
"Context",
",",
"_",
"*",
"containerd",
".",
"Client",
",",
"c",
"*",
"containers",
".",
"Container",
")",
"error",
"{",
"if",
"c",
".",
"Labels",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",... | // WithNoRestarts clears any restart information from the container | [
"WithNoRestarts",
"clears",
"any",
"restart",
"information",
"from",
"the",
"container"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/runtime/restart/restart.go#L65-L72 |
130,191 | containerd/containerd | snapshots/storage/metastore.go | TransactionContext | func (ms *MetaStore) TransactionContext(ctx context.Context, writable bool) (context.Context, Transactor, error) {
ms.dbL.Lock()
if ms.db == nil {
db, err := bolt.Open(ms.dbfile, 0600, nil)
if err != nil {
ms.dbL.Unlock()
return ctx, nil, errors.Wrap(err, "failed to open database file")
}
ms.db = db
}
... | go | func (ms *MetaStore) TransactionContext(ctx context.Context, writable bool) (context.Context, Transactor, error) {
ms.dbL.Lock()
if ms.db == nil {
db, err := bolt.Open(ms.dbfile, 0600, nil)
if err != nil {
ms.dbL.Unlock()
return ctx, nil, errors.Wrap(err, "failed to open database file")
}
ms.db = db
}
... | [
"func",
"(",
"ms",
"*",
"MetaStore",
")",
"TransactionContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"writable",
"bool",
")",
"(",
"context",
".",
"Context",
",",
"Transactor",
",",
"error",
")",
"{",
"ms",
".",
"dbL",
".",
"Lock",
"(",
")",
"... | // TransactionContext creates a new transaction context. The writable value
// should be set to true for transactions which are expected to mutate data. | [
"TransactionContext",
"creates",
"a",
"new",
"transaction",
"context",
".",
"The",
"writable",
"value",
"should",
"be",
"set",
"to",
"true",
"for",
"transactions",
"which",
"are",
"expected",
"to",
"mutate",
"data",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/storage/metastore.go#L85-L105 |
130,192 | containerd/containerd | snapshots/storage/metastore.go | Close | func (ms *MetaStore) Close() error {
ms.dbL.Lock()
defer ms.dbL.Unlock()
if ms.db == nil {
return nil
}
return ms.db.Close()
} | go | func (ms *MetaStore) Close() error {
ms.dbL.Lock()
defer ms.dbL.Unlock()
if ms.db == nil {
return nil
}
return ms.db.Close()
} | [
"func",
"(",
"ms",
"*",
"MetaStore",
")",
"Close",
"(",
")",
"error",
"{",
"ms",
".",
"dbL",
".",
"Lock",
"(",
")",
"\n",
"defer",
"ms",
".",
"dbL",
".",
"Unlock",
"(",
")",
"\n",
"if",
"ms",
".",
"db",
"==",
"nil",
"{",
"return",
"nil",
"\n"... | // Close closes the metastore and any underlying database connections | [
"Close",
"closes",
"the",
"metastore",
"and",
"any",
"underlying",
"database",
"connections"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/snapshots/storage/metastore.go#L108-L115 |
130,193 | containerd/containerd | cmd/ctr/commands/resolver.go | GetResolver | func GetResolver(ctx gocontext.Context, clicontext *cli.Context) (remotes.Resolver, error) {
username := clicontext.String("user")
var secret string
if i := strings.IndexByte(username, ':'); i > 0 {
secret = username[i+1:]
username = username[0:i]
}
options := docker.ResolverOptions{
PlainHTTP: clicontext.Bo... | go | func GetResolver(ctx gocontext.Context, clicontext *cli.Context) (remotes.Resolver, error) {
username := clicontext.String("user")
var secret string
if i := strings.IndexByte(username, ':'); i > 0 {
secret = username[i+1:]
username = username[0:i]
}
options := docker.ResolverOptions{
PlainHTTP: clicontext.Bo... | [
"func",
"GetResolver",
"(",
"ctx",
"gocontext",
".",
"Context",
",",
"clicontext",
"*",
"cli",
".",
"Context",
")",
"(",
"remotes",
".",
"Resolver",
",",
"error",
")",
"{",
"username",
":=",
"clicontext",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"var... | // GetResolver prepares the resolver from the environment and options | [
"GetResolver",
"prepares",
"the",
"resolver",
"from",
"the",
"environment",
"and",
"options"
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/cmd/ctr/commands/resolver.go#L55-L109 |
130,194 | containerd/containerd | images/image.go | Size | func (image *Image) Size(ctx context.Context, provider content.Provider, platform platforms.MatchComparer) (int64, error) {
var size int64
return size, Walk(ctx, Handlers(HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
if desc.Size < 0 {
return nil, errors.Errorf("i... | go | func (image *Image) Size(ctx context.Context, provider content.Provider, platform platforms.MatchComparer) (int64, error) {
var size int64
return size, Walk(ctx, Handlers(HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
if desc.Size < 0 {
return nil, errors.Errorf("i... | [
"func",
"(",
"image",
"*",
"Image",
")",
"Size",
"(",
"ctx",
"context",
".",
"Context",
",",
"provider",
"content",
".",
"Provider",
",",
"platform",
"platforms",
".",
"MatchComparer",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"size",
"int64",
... | // Size returns the total size of an image's packed resources. | [
"Size",
"returns",
"the",
"total",
"size",
"of",
"an",
"image",
"s",
"packed",
"resources",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/images/image.go#L114-L123 |
130,195 | containerd/containerd | images/image.go | Config | func Config(ctx context.Context, provider content.Provider, image ocispec.Descriptor, platform platforms.MatchComparer) (ocispec.Descriptor, error) {
manifest, err := Manifest(ctx, provider, image, platform)
if err != nil {
return ocispec.Descriptor{}, err
}
return manifest.Config, err
} | go | func Config(ctx context.Context, provider content.Provider, image ocispec.Descriptor, platform platforms.MatchComparer) (ocispec.Descriptor, error) {
manifest, err := Manifest(ctx, provider, image, platform)
if err != nil {
return ocispec.Descriptor{}, err
}
return manifest.Config, err
} | [
"func",
"Config",
"(",
"ctx",
"context",
".",
"Context",
",",
"provider",
"content",
".",
"Provider",
",",
"image",
"ocispec",
".",
"Descriptor",
",",
"platform",
"platforms",
".",
"MatchComparer",
")",
"(",
"ocispec",
".",
"Descriptor",
",",
"error",
")",
... | // Config resolves the image configuration descriptor using a content provided
// to resolve child resources on the image.
//
// The caller can then use the descriptor to resolve and process the
// configuration of the image. | [
"Config",
"resolves",
"the",
"image",
"configuration",
"descriptor",
"using",
"a",
"content",
"provided",
"to",
"resolve",
"child",
"resources",
"on",
"the",
"image",
".",
"The",
"caller",
"can",
"then",
"use",
"the",
"descriptor",
"to",
"resolve",
"and",
"pro... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/images/image.go#L249-L255 |
130,196 | containerd/containerd | images/image.go | Check | func Check(ctx context.Context, provider content.Provider, image ocispec.Descriptor, platform platforms.MatchComparer) (available bool, required, present, missing []ocispec.Descriptor, err error) {
mfst, err := Manifest(ctx, provider, image, platform)
if err != nil {
if errdefs.IsNotFound(err) {
return false, []... | go | func Check(ctx context.Context, provider content.Provider, image ocispec.Descriptor, platform platforms.MatchComparer) (available bool, required, present, missing []ocispec.Descriptor, err error) {
mfst, err := Manifest(ctx, provider, image, platform)
if err != nil {
if errdefs.IsNotFound(err) {
return false, []... | [
"func",
"Check",
"(",
"ctx",
"context",
".",
"Context",
",",
"provider",
"content",
".",
"Provider",
",",
"image",
"ocispec",
".",
"Descriptor",
",",
"platform",
"platforms",
".",
"MatchComparer",
")",
"(",
"available",
"bool",
",",
"required",
",",
"present... | // Check returns nil if the all components of an image are available in the
// provider for the specified platform.
//
// If available is true, the caller can assume that required represents the
// complete set of content required for the image.
//
// missing will have the components that are part of required but not a... | [
"Check",
"returns",
"nil",
"if",
"the",
"all",
"components",
"of",
"an",
"image",
"are",
"available",
"in",
"the",
"provider",
"for",
"the",
"specified",
"platform",
".",
"If",
"available",
"is",
"true",
"the",
"caller",
"can",
"assume",
"that",
"required",
... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/images/image.go#L295-L326 |
130,197 | containerd/containerd | images/image.go | Children | func Children(ctx context.Context, provider content.Provider, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
var descs []ocispec.Descriptor
switch desc.MediaType {
case MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest:
p, err := content.ReadBlob(ctx, provider, desc)
if err != nil {
ret... | go | func Children(ctx context.Context, provider content.Provider, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
var descs []ocispec.Descriptor
switch desc.MediaType {
case MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest:
p, err := content.ReadBlob(ctx, provider, desc)
if err != nil {
ret... | [
"func",
"Children",
"(",
"ctx",
"context",
".",
"Context",
",",
"provider",
"content",
".",
"Provider",
",",
"desc",
"ocispec",
".",
"Descriptor",
")",
"(",
"[",
"]",
"ocispec",
".",
"Descriptor",
",",
"error",
")",
"{",
"var",
"descs",
"[",
"]",
"ocis... | // Children returns the immediate children of content described by the descriptor. | [
"Children",
"returns",
"the",
"immediate",
"children",
"of",
"content",
"described",
"by",
"the",
"descriptor",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/images/image.go#L329-L372 |
130,198 | containerd/containerd | images/image.go | IsCompressedDiff | func IsCompressedDiff(ctx context.Context, mediaType string) (bool, error) {
switch mediaType {
case ocispec.MediaTypeImageLayer, MediaTypeDockerSchema2Layer:
case ocispec.MediaTypeImageLayerGzip, MediaTypeDockerSchema2LayerGzip:
return true, nil
default:
// Still apply all generic media types *.tar[.+]gzip and... | go | func IsCompressedDiff(ctx context.Context, mediaType string) (bool, error) {
switch mediaType {
case ocispec.MediaTypeImageLayer, MediaTypeDockerSchema2Layer:
case ocispec.MediaTypeImageLayerGzip, MediaTypeDockerSchema2LayerGzip:
return true, nil
default:
// Still apply all generic media types *.tar[.+]gzip and... | [
"func",
"IsCompressedDiff",
"(",
"ctx",
"context",
".",
"Context",
",",
"mediaType",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"switch",
"mediaType",
"{",
"case",
"ocispec",
".",
"MediaTypeImageLayer",
",",
"MediaTypeDockerSchema2Layer",
":",
"case",
... | // IsCompressedDiff returns true if mediaType is a known compressed diff media type.
// It returns false if the media type is a diff, but not compressed. If the media type
// is not a known diff type, it returns errdefs.ErrNotImplemented | [
"IsCompressedDiff",
"returns",
"true",
"if",
"mediaType",
"is",
"a",
"known",
"compressed",
"diff",
"media",
"type",
".",
"It",
"returns",
"false",
"if",
"the",
"media",
"type",
"is",
"a",
"diff",
"but",
"not",
"compressed",
".",
"If",
"the",
"media",
"typ... | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/images/image.go#L394-L408 |
130,199 | containerd/containerd | container_opts_unix.go | WithRemappedSnapshotView | func WithRemappedSnapshotView(id string, i Image, uid, gid uint32) NewContainerOpts {
return withRemappedSnapshotBase(id, i, uid, gid, true)
} | go | func WithRemappedSnapshotView(id string, i Image, uid, gid uint32) NewContainerOpts {
return withRemappedSnapshotBase(id, i, uid, gid, true)
} | [
"func",
"WithRemappedSnapshotView",
"(",
"id",
"string",
",",
"i",
"Image",
",",
"uid",
",",
"gid",
"uint32",
")",
"NewContainerOpts",
"{",
"return",
"withRemappedSnapshotBase",
"(",
"id",
",",
"i",
",",
"uid",
",",
"gid",
",",
"true",
")",
"\n",
"}"
] | // WithRemappedSnapshotView is similar to WithRemappedSnapshot but rootfs is mounted as read-only. | [
"WithRemappedSnapshotView",
"is",
"similar",
"to",
"WithRemappedSnapshot",
"but",
"rootfs",
"is",
"mounted",
"as",
"read",
"-",
"only",
"."
] | a17c8095716415cebb1157a27db5fccace56b0fc | https://github.com/containerd/containerd/blob/a17c8095716415cebb1157a27db5fccace56b0fc/container_opts_unix.go#L42-L44 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.