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 sequence | docstring stringlengths 6 2.61k | docstring_tokens sequence | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
rkt/rkt | tools/depsgen/main.go | getAllDepTypes | func getAllDepTypes() []string {
depTypes := make([]string, 0, len(cmds))
for depType := range cmds {
depTypes = append(depTypes, depType)
}
sort.Strings(depTypes)
return depTypes
} | go | func getAllDepTypes() []string {
depTypes := make([]string, 0, len(cmds))
for depType := range cmds {
depTypes = append(depTypes, depType)
}
sort.Strings(depTypes)
return depTypes
} | [
"func",
"getAllDepTypes",
"(",
")",
"[",
"]",
"string",
"{",
"depTypes",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"cmds",
")",
")",
"\n",
"for",
"depType",
":=",
"range",
"cmds",
"{",
"depTypes",
"=",
"append",
"(",
"depTyp... | // getAllDepTypes returns a sorted list of names of all dep type
// commands. | [
"getAllDepTypes",
"returns",
"a",
"sorted",
"list",
"of",
"names",
"of",
"all",
"dep",
"type",
"commands",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/tools/depsgen/main.go#L47-L54 | train |
rkt/rkt | rkt/image/io.go | getIoProgressReader | func getIoProgressReader(label string, res *http.Response) io.Reader {
prefix := "Downloading " + label
fmtBytesSize := 18
barSize := int64(80 - len(prefix) - fmtBytesSize)
bar := ioprogress.DrawTextFormatBarForW(barSize, os.Stderr)
fmtfunc := func(progress, total int64) string {
// Content-Length is set to -1 w... | go | func getIoProgressReader(label string, res *http.Response) io.Reader {
prefix := "Downloading " + label
fmtBytesSize := 18
barSize := int64(80 - len(prefix) - fmtBytesSize)
bar := ioprogress.DrawTextFormatBarForW(barSize, os.Stderr)
fmtfunc := func(progress, total int64) string {
// Content-Length is set to -1 w... | [
"func",
"getIoProgressReader",
"(",
"label",
"string",
",",
"res",
"*",
"http",
".",
"Response",
")",
"io",
".",
"Reader",
"{",
"prefix",
":=",
"\"",
"\"",
"+",
"label",
"\n",
"fmtBytesSize",
":=",
"18",
"\n",
"barSize",
":=",
"int64",
"(",
"80",
"-",
... | // getIoProgressReader returns a reader that wraps the HTTP response
// body, so it prints a pretty progress bar when reading data from it. | [
"getIoProgressReader",
"returns",
"a",
"reader",
"that",
"wraps",
"the",
"HTTP",
"response",
"body",
"so",
"it",
"prints",
"a",
"pretty",
"progress",
"bar",
"when",
"reading",
"data",
"from",
"it",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/io.go#L60-L87 | train |
rkt/rkt | rkt/image/io.go | Close | func (f *removeOnClose) Close() error {
if f == nil || f.File == nil {
return nil
}
name := f.File.Name()
if err := f.File.Close(); err != nil {
return err
}
if err := os.Remove(name); err != nil && !os.IsNotExist(err) {
return err
}
return nil
} | go | func (f *removeOnClose) Close() error {
if f == nil || f.File == nil {
return nil
}
name := f.File.Name()
if err := f.File.Close(); err != nil {
return err
}
if err := os.Remove(name); err != nil && !os.IsNotExist(err) {
return err
}
return nil
} | [
"func",
"(",
"f",
"*",
"removeOnClose",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"f",
"==",
"nil",
"||",
"f",
".",
"File",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"name",
":=",
"f",
".",
"File",
".",
"Name",
"(",
")",
"\n",
"if... | // Close closes the file and then removes it from disk. No error is
// returned if the file did not exist at the point of removal. | [
"Close",
"closes",
"the",
"file",
"and",
"then",
"removes",
"it",
"from",
"disk",
".",
"No",
"error",
"is",
"returned",
"if",
"the",
"file",
"did",
"not",
"exist",
"at",
"the",
"point",
"of",
"removal",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/io.go#L107-L119 | train |
rkt/rkt | rkt/image/io.go | getTmpROC | func getTmpROC(s *imagestore.Store, path string) (*removeOnClose, error) {
h := sha512.New()
h.Write([]byte(path))
pathHash := s.HashToKey(h)
tmp, err := s.TmpNamedFile(pathHash)
if err != nil {
return nil, errwrap.Wrap(errors.New("error setting up temporary file"), err)
}
// let's lock the file to avoid con... | go | func getTmpROC(s *imagestore.Store, path string) (*removeOnClose, error) {
h := sha512.New()
h.Write([]byte(path))
pathHash := s.HashToKey(h)
tmp, err := s.TmpNamedFile(pathHash)
if err != nil {
return nil, errwrap.Wrap(errors.New("error setting up temporary file"), err)
}
// let's lock the file to avoid con... | [
"func",
"getTmpROC",
"(",
"s",
"*",
"imagestore",
".",
"Store",
",",
"path",
"string",
")",
"(",
"*",
"removeOnClose",
",",
"error",
")",
"{",
"h",
":=",
"sha512",
".",
"New",
"(",
")",
"\n",
"h",
".",
"Write",
"(",
"[",
"]",
"byte",
"(",
"path",... | // getTmpROC returns a removeOnClose instance wrapping a temporary
// file provided by the passed store. The actual file name is based on
// a hash of the passed path. | [
"getTmpROC",
"returns",
"a",
"removeOnClose",
"instance",
"wrapping",
"a",
"temporary",
"file",
"provided",
"by",
"the",
"passed",
"store",
".",
"The",
"actual",
"file",
"name",
"is",
"based",
"on",
"a",
"hash",
"of",
"the",
"passed",
"path",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/io.go#L124-L149 | train |
rkt/rkt | stage0/manifest.go | getStage1Entrypoint | func getStage1Entrypoint(cdir string, entrypoint string) (string, error) {
b, err := ioutil.ReadFile(common.Stage1ManifestPath(cdir))
if err != nil {
return "", errwrap.Wrap(errors.New("error reading pod manifest"), err)
}
s1m := schema.ImageManifest{}
if err := json.Unmarshal(b, &s1m); err != nil {
return ""... | go | func getStage1Entrypoint(cdir string, entrypoint string) (string, error) {
b, err := ioutil.ReadFile(common.Stage1ManifestPath(cdir))
if err != nil {
return "", errwrap.Wrap(errors.New("error reading pod manifest"), err)
}
s1m := schema.ImageManifest{}
if err := json.Unmarshal(b, &s1m); err != nil {
return ""... | [
"func",
"getStage1Entrypoint",
"(",
"cdir",
"string",
",",
"entrypoint",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"common",
".",
"Stage1ManifestPath",
"(",
"cdir",
")",
")",
"\n",
"if",
... | // getStage1Entrypoint retrieves the named entrypoint from the stage1 manifest for a given pod | [
"getStage1Entrypoint",
"retrieves",
"the",
"named",
"entrypoint",
"from",
"the",
"stage1",
"manifest",
"for",
"a",
"given",
"pod"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/manifest.go#L69-L85 | train |
rkt/rkt | stage0/manifest.go | getStage1InterfaceVersion | func getStage1InterfaceVersion(cdir string) (int, error) {
b, err := ioutil.ReadFile(common.Stage1ManifestPath(cdir))
if err != nil {
return -1, errwrap.Wrap(errors.New("error reading pod manifest"), err)
}
s1m := schema.ImageManifest{}
if err := json.Unmarshal(b, &s1m); err != nil {
return -1, errwrap.Wrap(e... | go | func getStage1InterfaceVersion(cdir string) (int, error) {
b, err := ioutil.ReadFile(common.Stage1ManifestPath(cdir))
if err != nil {
return -1, errwrap.Wrap(errors.New("error reading pod manifest"), err)
}
s1m := schema.ImageManifest{}
if err := json.Unmarshal(b, &s1m); err != nil {
return -1, errwrap.Wrap(e... | [
"func",
"getStage1InterfaceVersion",
"(",
"cdir",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"common",
".",
"Stage1ManifestPath",
"(",
"cdir",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // getStage1InterfaceVersion retrieves the interface version from the stage1
// manifest for a given pod | [
"getStage1InterfaceVersion",
"retrieves",
"the",
"interface",
"version",
"from",
"the",
"stage1",
"manifest",
"for",
"a",
"given",
"pod"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/manifest.go#L89-L110 | train |
rkt/rkt | networking/podenv.go | loadNets | func (e *podEnv) loadNets() ([]activeNet, error) {
if e.netsLoadList.None() {
stderr.Printf("networking namespace with loopback only")
return nil, nil
}
nets, err := e.newNetLoader().loadNets(e.netsLoadList)
if err != nil {
return nil, err
}
netSlice := make([]activeNet, 0, len(nets))
for _, net := range ... | go | func (e *podEnv) loadNets() ([]activeNet, error) {
if e.netsLoadList.None() {
stderr.Printf("networking namespace with loopback only")
return nil, nil
}
nets, err := e.newNetLoader().loadNets(e.netsLoadList)
if err != nil {
return nil, err
}
netSlice := make([]activeNet, 0, len(nets))
for _, net := range ... | [
"func",
"(",
"e",
"*",
"podEnv",
")",
"loadNets",
"(",
")",
"(",
"[",
"]",
"activeNet",
",",
"error",
")",
"{",
"if",
"e",
".",
"netsLoadList",
".",
"None",
"(",
")",
"{",
"stderr",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
",... | // Loads nets specified by user, both from a configurable user location and builtin from stage1. User supplied network
// configs override what is built into stage1.
// The order in which networks are applied to pods will be defined by their filenames. | [
"Loads",
"nets",
"specified",
"by",
"user",
"both",
"from",
"a",
"configurable",
"user",
"location",
"and",
"builtin",
"from",
"stage1",
".",
"User",
"supplied",
"network",
"configs",
"override",
"what",
"is",
"built",
"into",
"stage1",
".",
"The",
"order",
... | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/podenv.go#L75-L102 | train |
rkt/rkt | stage1/init/common/app.go | prepareApp | func prepareApp(p *stage1commontypes.Pod, ra *schema.RuntimeApp) (*preparedApp, error) {
pa := preparedApp{
app: ra,
env: ra.App.Environment,
noNewPrivileges: getAppNoNewPrivileges(ra.App.Isolators),
}
var err error
// Determine numeric uid and gid
u, g, err := ParseUserGroup(p, ra)
... | go | func prepareApp(p *stage1commontypes.Pod, ra *schema.RuntimeApp) (*preparedApp, error) {
pa := preparedApp{
app: ra,
env: ra.App.Environment,
noNewPrivileges: getAppNoNewPrivileges(ra.App.Isolators),
}
var err error
// Determine numeric uid and gid
u, g, err := ParseUserGroup(p, ra)
... | [
"func",
"prepareApp",
"(",
"p",
"*",
"stage1commontypes",
".",
"Pod",
",",
"ra",
"*",
"schema",
".",
"RuntimeApp",
")",
"(",
"*",
"preparedApp",
",",
"error",
")",
"{",
"pa",
":=",
"preparedApp",
"{",
"app",
":",
"ra",
",",
"env",
":",
"ra",
".",
"... | // prepareApp sets up the internal runtime context for a specific app. | [
"prepareApp",
"sets",
"up",
"the",
"internal",
"runtime",
"context",
"for",
"a",
"specific",
"app",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/common/app.go#L98-L166 | train |
rkt/rkt | stage1/init/common/app.go | computeAppResources | func computeAppResources(isolators types.Isolators) (appResources, error) {
res := appResources{}
var err error
withIsolator := func(name string, f func() error) error {
ok, err := cgroup.IsIsolatorSupported(name)
if err != nil {
return errwrap.Wrapf("could not check for isolator "+name, err)
}
if !ok {... | go | func computeAppResources(isolators types.Isolators) (appResources, error) {
res := appResources{}
var err error
withIsolator := func(name string, f func() error) error {
ok, err := cgroup.IsIsolatorSupported(name)
if err != nil {
return errwrap.Wrapf("could not check for isolator "+name, err)
}
if !ok {... | [
"func",
"computeAppResources",
"(",
"isolators",
"types",
".",
"Isolators",
")",
"(",
"appResources",
",",
"error",
")",
"{",
"res",
":=",
"appResources",
"{",
"}",
"\n",
"var",
"err",
"error",
"\n\n",
"withIsolator",
":=",
"func",
"(",
"name",
"string",
"... | // computeAppResources processes any isolators that manipulate cgroups. | [
"computeAppResources",
"processes",
"any",
"isolators",
"that",
"manipulate",
"cgroups",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/common/app.go#L169-L229 | train |
rkt/rkt | store/imagestore/aciinfo.go | GetACIInfosWithKeyPrefix | func GetACIInfosWithKeyPrefix(tx *sql.Tx, prefix string) ([]*ACIInfo, error) {
var aciinfos []*ACIInfo
rows, err := tx.Query("SELECT * from aciinfo WHERE hasPrefix(blobkey, $1)", prefix)
if err != nil {
return nil, err
}
defer rows.Close()
for rows.Next() {
aciinfo := &ACIInfo{}
if err := aciinfoRowScan(row... | go | func GetACIInfosWithKeyPrefix(tx *sql.Tx, prefix string) ([]*ACIInfo, error) {
var aciinfos []*ACIInfo
rows, err := tx.Query("SELECT * from aciinfo WHERE hasPrefix(blobkey, $1)", prefix)
if err != nil {
return nil, err
}
defer rows.Close()
for rows.Next() {
aciinfo := &ACIInfo{}
if err := aciinfoRowScan(row... | [
"func",
"GetACIInfosWithKeyPrefix",
"(",
"tx",
"*",
"sql",
".",
"Tx",
",",
"prefix",
"string",
")",
"(",
"[",
"]",
"*",
"ACIInfo",
",",
"error",
")",
"{",
"var",
"aciinfos",
"[",
"]",
"*",
"ACIInfo",
"\n",
"rows",
",",
"err",
":=",
"tx",
".",
"Quer... | // GetAciInfosWithKeyPrefix returns all the ACIInfos with a blobkey starting with the given prefix. | [
"GetAciInfosWithKeyPrefix",
"returns",
"all",
"the",
"ACIInfos",
"with",
"a",
"blobkey",
"starting",
"with",
"the",
"given",
"prefix",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/aciinfo.go#L68-L86 | train |
rkt/rkt | store/imagestore/aciinfo.go | GetACIInfosWithName | func GetACIInfosWithName(tx *sql.Tx, name string) ([]*ACIInfo, bool, error) {
var aciinfos []*ACIInfo
found := false
rows, err := tx.Query("SELECT * from aciinfo WHERE name == $1", name)
if err != nil {
return nil, false, err
}
defer rows.Close()
for rows.Next() {
found = true
aciinfo := &ACIInfo{}
if er... | go | func GetACIInfosWithName(tx *sql.Tx, name string) ([]*ACIInfo, bool, error) {
var aciinfos []*ACIInfo
found := false
rows, err := tx.Query("SELECT * from aciinfo WHERE name == $1", name)
if err != nil {
return nil, false, err
}
defer rows.Close()
for rows.Next() {
found = true
aciinfo := &ACIInfo{}
if er... | [
"func",
"GetACIInfosWithName",
"(",
"tx",
"*",
"sql",
".",
"Tx",
",",
"name",
"string",
")",
"(",
"[",
"]",
"*",
"ACIInfo",
",",
"bool",
",",
"error",
")",
"{",
"var",
"aciinfos",
"[",
"]",
"*",
"ACIInfo",
"\n",
"found",
":=",
"false",
"\n",
"rows"... | // GetAciInfosWithName returns all the ACIInfos for a given name. found will be
// false if no aciinfo exists. | [
"GetAciInfosWithName",
"returns",
"all",
"the",
"ACIInfos",
"for",
"a",
"given",
"name",
".",
"found",
"will",
"be",
"false",
"if",
"no",
"aciinfo",
"exists",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/aciinfo.go#L90-L110 | train |
rkt/rkt | store/imagestore/aciinfo.go | GetACIInfoWithBlobKey | func GetACIInfoWithBlobKey(tx *sql.Tx, blobKey string) (*ACIInfo, bool, error) {
aciinfo := &ACIInfo{}
found := false
rows, err := tx.Query("SELECT * from aciinfo WHERE blobkey == $1", blobKey)
if err != nil {
return nil, false, err
}
defer rows.Close()
for rows.Next() {
found = true
if err := aciinfoRowSc... | go | func GetACIInfoWithBlobKey(tx *sql.Tx, blobKey string) (*ACIInfo, bool, error) {
aciinfo := &ACIInfo{}
found := false
rows, err := tx.Query("SELECT * from aciinfo WHERE blobkey == $1", blobKey)
if err != nil {
return nil, false, err
}
defer rows.Close()
for rows.Next() {
found = true
if err := aciinfoRowSc... | [
"func",
"GetACIInfoWithBlobKey",
"(",
"tx",
"*",
"sql",
".",
"Tx",
",",
"blobKey",
"string",
")",
"(",
"*",
"ACIInfo",
",",
"bool",
",",
"error",
")",
"{",
"aciinfo",
":=",
"&",
"ACIInfo",
"{",
"}",
"\n",
"found",
":=",
"false",
"\n",
"rows",
",",
... | // GetAciInfosWithBlobKey returns the ACIInfo with the given blobKey. found will be
// false if no aciinfo exists. | [
"GetAciInfosWithBlobKey",
"returns",
"the",
"ACIInfo",
"with",
"the",
"given",
"blobKey",
".",
"found",
"will",
"be",
"false",
"if",
"no",
"aciinfo",
"exists",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/aciinfo.go#L114-L134 | train |
rkt/rkt | store/imagestore/aciinfo.go | GetAllACIInfos | func GetAllACIInfos(tx *sql.Tx, sortfields []string, ascending bool) ([]*ACIInfo, error) {
var aciinfos []*ACIInfo
query := "SELECT * from aciinfo"
if len(sortfields) > 0 {
query += fmt.Sprintf(" ORDER BY %s ", strings.Join(sortfields, ", "))
if ascending {
query += "ASC"
} else {
query += "DESC"
}
}
... | go | func GetAllACIInfos(tx *sql.Tx, sortfields []string, ascending bool) ([]*ACIInfo, error) {
var aciinfos []*ACIInfo
query := "SELECT * from aciinfo"
if len(sortfields) > 0 {
query += fmt.Sprintf(" ORDER BY %s ", strings.Join(sortfields, ", "))
if ascending {
query += "ASC"
} else {
query += "DESC"
}
}
... | [
"func",
"GetAllACIInfos",
"(",
"tx",
"*",
"sql",
".",
"Tx",
",",
"sortfields",
"[",
"]",
"string",
",",
"ascending",
"bool",
")",
"(",
"[",
"]",
"*",
"ACIInfo",
",",
"error",
")",
"{",
"var",
"aciinfos",
"[",
"]",
"*",
"ACIInfo",
"\n",
"query",
":=... | // GetAllACIInfos returns all the ACIInfos sorted by optional sortfields and
// with ascending or descending order. | [
"GetAllACIInfos",
"returns",
"all",
"the",
"ACIInfos",
"sorted",
"by",
"optional",
"sortfields",
"and",
"with",
"ascending",
"or",
"descending",
"order",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/aciinfo.go#L138-L165 | train |
rkt/rkt | store/imagestore/aciinfo.go | WriteACIInfo | func WriteACIInfo(tx *sql.Tx, aciinfo *ACIInfo) error {
// ql doesn't have an INSERT OR UPDATE function so
// it's faster to remove and reinsert the row
_, err := tx.Exec("DELETE from aciinfo where blobkey == $1", aciinfo.BlobKey)
if err != nil {
return err
}
_, err = tx.Exec("INSERT into aciinfo (blobkey, name... | go | func WriteACIInfo(tx *sql.Tx, aciinfo *ACIInfo) error {
// ql doesn't have an INSERT OR UPDATE function so
// it's faster to remove and reinsert the row
_, err := tx.Exec("DELETE from aciinfo where blobkey == $1", aciinfo.BlobKey)
if err != nil {
return err
}
_, err = tx.Exec("INSERT into aciinfo (blobkey, name... | [
"func",
"WriteACIInfo",
"(",
"tx",
"*",
"sql",
".",
"Tx",
",",
"aciinfo",
"*",
"ACIInfo",
")",
"error",
"{",
"// ql doesn't have an INSERT OR UPDATE function so",
"// it's faster to remove and reinsert the row",
"_",
",",
"err",
":=",
"tx",
".",
"Exec",
"(",
"\"",
... | // WriteACIInfo adds or updates the provided aciinfo. | [
"WriteACIInfo",
"adds",
"or",
"updates",
"the",
"provided",
"aciinfo",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/aciinfo.go#L168-L181 | train |
rkt/rkt | stage1/init/kvm/hypervisor/hvqemu/qemu_driver.go | StartCmd | func StartCmd(wdPath, name, kernelPath string, nds []kvm.NetDescriber, cpu, mem int64, debug bool) []string {
var (
driverConfiguration = hypervisor.KvmHypervisor{
Bin: "./qemu",
KernelParams: []string{
"root=/dev/root",
"rootfstype=9p",
"rootflags=trans=virtio,version=9p2000.L,cache=mmap",
"rw... | go | func StartCmd(wdPath, name, kernelPath string, nds []kvm.NetDescriber, cpu, mem int64, debug bool) []string {
var (
driverConfiguration = hypervisor.KvmHypervisor{
Bin: "./qemu",
KernelParams: []string{
"root=/dev/root",
"rootfstype=9p",
"rootflags=trans=virtio,version=9p2000.L,cache=mmap",
"rw... | [
"func",
"StartCmd",
"(",
"wdPath",
",",
"name",
",",
"kernelPath",
"string",
",",
"nds",
"[",
"]",
"kvm",
".",
"NetDescriber",
",",
"cpu",
",",
"mem",
"int64",
",",
"debug",
"bool",
")",
"[",
"]",
"string",
"{",
"var",
"(",
"driverConfiguration",
"=",
... | // StartCmd takes path to stage1, name of the machine, path to kernel, network describers, memory in megabytes
// and quantity of cpus and prepares command line to run QEMU process | [
"StartCmd",
"takes",
"path",
"to",
"stage1",
"name",
"of",
"the",
"machine",
"path",
"to",
"kernel",
"network",
"describers",
"memory",
"in",
"megabytes",
"and",
"quantity",
"of",
"cpus",
"and",
"prepares",
"command",
"line",
"to",
"run",
"QEMU",
"process"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/hypervisor/hvqemu/qemu_driver.go#L29-L63 | train |
rkt/rkt | stage1/init/kvm/hypervisor/hvqemu/qemu_driver.go | kvmNetArgs | func kvmNetArgs(nds []kvm.NetDescriber) []string {
var qemuArgs []string
for _, nd := range nds {
qemuArgs = append(qemuArgs, []string{"-net", "nic,model=virtio"}...)
qemuNic := fmt.Sprintf("tap,ifname=%s,script=no,downscript=no,vhost=on", nd.IfName())
qemuArgs = append(qemuArgs, []string{"-net", qemuNic}...)
... | go | func kvmNetArgs(nds []kvm.NetDescriber) []string {
var qemuArgs []string
for _, nd := range nds {
qemuArgs = append(qemuArgs, []string{"-net", "nic,model=virtio"}...)
qemuNic := fmt.Sprintf("tap,ifname=%s,script=no,downscript=no,vhost=on", nd.IfName())
qemuArgs = append(qemuArgs, []string{"-net", qemuNic}...)
... | [
"func",
"kvmNetArgs",
"(",
"nds",
"[",
"]",
"kvm",
".",
"NetDescriber",
")",
"[",
"]",
"string",
"{",
"var",
"qemuArgs",
"[",
"]",
"string",
"\n\n",
"for",
"_",
",",
"nd",
":=",
"range",
"nds",
"{",
"qemuArgs",
"=",
"append",
"(",
"qemuArgs",
",",
... | // kvmNetArgs returns additional arguments that need to be passed
// to qemu to configure networks properly. Logic is based on
// network configuration extracted from Networking struct
// and essentially from activeNets that expose NetDescriber behavior | [
"kvmNetArgs",
"returns",
"additional",
"arguments",
"that",
"need",
"to",
"be",
"passed",
"to",
"qemu",
"to",
"configure",
"networks",
"properly",
".",
"Logic",
"is",
"based",
"on",
"network",
"configuration",
"extracted",
"from",
"Networking",
"struct",
"and",
... | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/hypervisor/hvqemu/qemu_driver.go#L69-L79 | train |
rkt/rkt | stage1/init/kvm/hypervisor/hypervisor.go | InitKernelParams | func (hv *KvmHypervisor) InitKernelParams(isDebug bool) {
hv.KernelParams = append(hv.KernelParams, []string{
"console=hvc0",
"init=/usr/lib/systemd/systemd",
"no_timer_check",
"noreplace-smp",
"tsc=reliable"}...)
if isDebug {
hv.KernelParams = append(hv.KernelParams, []string{
"debug",
"systemd.lo... | go | func (hv *KvmHypervisor) InitKernelParams(isDebug bool) {
hv.KernelParams = append(hv.KernelParams, []string{
"console=hvc0",
"init=/usr/lib/systemd/systemd",
"no_timer_check",
"noreplace-smp",
"tsc=reliable"}...)
if isDebug {
hv.KernelParams = append(hv.KernelParams, []string{
"debug",
"systemd.lo... | [
"func",
"(",
"hv",
"*",
"KvmHypervisor",
")",
"InitKernelParams",
"(",
"isDebug",
"bool",
")",
"{",
"hv",
".",
"KernelParams",
"=",
"append",
"(",
"hv",
".",
"KernelParams",
",",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
... | // InitKernelParams sets debug and common parameters passed to the kernel | [
"InitKernelParams",
"sets",
"debug",
"and",
"common",
"parameters",
"passed",
"to",
"the",
"kernel"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/hypervisor/hypervisor.go#L26-L54 | train |
rkt/rkt | rkt/image/dockerfetcher.go | Hash | func (f *dockerFetcher) Hash(u *url.URL) (string, error) {
ensureLogger(f.Debug)
dockerURL, err := d2acommon.ParseDockerURL(path.Join(u.Host, u.Path))
if err != nil {
return "", fmt.Errorf(`invalid docker URL %q; expected syntax is "docker://[REGISTRY_HOST[:REGISTRY_PORT]/]IMAGE_NAME[:TAG]"`, u)
}
latest := dock... | go | func (f *dockerFetcher) Hash(u *url.URL) (string, error) {
ensureLogger(f.Debug)
dockerURL, err := d2acommon.ParseDockerURL(path.Join(u.Host, u.Path))
if err != nil {
return "", fmt.Errorf(`invalid docker URL %q; expected syntax is "docker://[REGISTRY_HOST[:REGISTRY_PORT]/]IMAGE_NAME[:TAG]"`, u)
}
latest := dock... | [
"func",
"(",
"f",
"*",
"dockerFetcher",
")",
"Hash",
"(",
"u",
"*",
"url",
".",
"URL",
")",
"(",
"string",
",",
"error",
")",
"{",
"ensureLogger",
"(",
"f",
".",
"Debug",
")",
"\n",
"dockerURL",
",",
"err",
":=",
"d2acommon",
".",
"ParseDockerURL",
... | // Hash uses docker2aci to download the image and convert it to
// ACI, then stores it in the store and returns the hash. | [
"Hash",
"uses",
"docker2aci",
"to",
"download",
"the",
"image",
"and",
"convert",
"it",
"to",
"ACI",
"then",
"stores",
"it",
"in",
"the",
"store",
"and",
"returns",
"the",
"hash",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/dockerfetcher.go#L51-L59 | train |
rkt/rkt | stage0/registration.go | registerPod | func registerPod(root string, uuid *types.UUID, apps schema.AppList) (token string, rerr error) {
u := uuid.String()
var err error
token, err = generateMDSToken()
if err != nil {
rerr = errwrap.Wrap(errors.New("failed to generate MDS token"), err)
return
}
pmfPath := common.PodManifestPath(root)
pmf, err :... | go | func registerPod(root string, uuid *types.UUID, apps schema.AppList) (token string, rerr error) {
u := uuid.String()
var err error
token, err = generateMDSToken()
if err != nil {
rerr = errwrap.Wrap(errors.New("failed to generate MDS token"), err)
return
}
pmfPath := common.PodManifestPath(root)
pmf, err :... | [
"func",
"registerPod",
"(",
"root",
"string",
",",
"uuid",
"*",
"types",
".",
"UUID",
",",
"apps",
"schema",
".",
"AppList",
")",
"(",
"token",
"string",
",",
"rerr",
"error",
")",
"{",
"u",
":=",
"uuid",
".",
"String",
"(",
")",
"\n\n",
"var",
"er... | // registerPod registers pod with metadata service.
// Returns authentication token to be passed in the URL | [
"registerPod",
"registers",
"pod",
"with",
"metadata",
"service",
".",
"Returns",
"authentication",
"token",
"to",
"be",
"passed",
"in",
"the",
"URL"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/registration.go#L54-L109 | train |
rkt/rkt | stage0/registration.go | unregisterPod | func unregisterPod(root string, uuid *types.UUID) error {
_, err := os.Stat(filepath.Join(root, mdsRegisteredFile))
switch {
case err == nil:
pth := path.Join("/pods", uuid.String())
return httpRequest("DELETE", pth, nil)
case os.IsNotExist(err):
return nil
default:
return err
}
} | go | func unregisterPod(root string, uuid *types.UUID) error {
_, err := os.Stat(filepath.Join(root, mdsRegisteredFile))
switch {
case err == nil:
pth := path.Join("/pods", uuid.String())
return httpRequest("DELETE", pth, nil)
case os.IsNotExist(err):
return nil
default:
return err
}
} | [
"func",
"unregisterPod",
"(",
"root",
"string",
",",
"uuid",
"*",
"types",
".",
"UUID",
")",
"error",
"{",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"filepath",
".",
"Join",
"(",
"root",
",",
"mdsRegisteredFile",
")",
")",
"\n",
"switch",
"{",
... | // unregisterPod unregisters pod with the metadata service. | [
"unregisterPod",
"unregisters",
"pod",
"with",
"the",
"metadata",
"service",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/registration.go#L112-L125 | train |
rkt/rkt | stage0/registration.go | CheckMdsAvailability | func CheckMdsAvailability() error {
if conn, err := net.Dial("unix", common.MetadataServiceRegSock); err != nil {
return errUnreachable
} else {
conn.Close()
return nil
}
} | go | func CheckMdsAvailability() error {
if conn, err := net.Dial("unix", common.MetadataServiceRegSock); err != nil {
return errUnreachable
} else {
conn.Close()
return nil
}
} | [
"func",
"CheckMdsAvailability",
"(",
")",
"error",
"{",
"if",
"conn",
",",
"err",
":=",
"net",
".",
"Dial",
"(",
"\"",
"\"",
",",
"common",
".",
"MetadataServiceRegSock",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errUnreachable",
"\n",
"}",
"else",
... | // CheckMdsAvailability checks whether a local metadata service can be reached. | [
"CheckMdsAvailability",
"checks",
"whether",
"a",
"local",
"metadata",
"service",
"can",
"be",
"reached",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/registration.go#L196-L203 | train |
rkt/rkt | networking/netinfo/netinfo.go | MergeCNIResult | func (ni *NetInfo) MergeCNIResult(result types.Result) {
ni.IP = result.IP4.IP.IP
ni.Mask = net.IP(result.IP4.IP.Mask)
ni.HostIP = result.IP4.Gateway
ni.IP4 = result.IP4
ni.DNS = result.DNS
} | go | func (ni *NetInfo) MergeCNIResult(result types.Result) {
ni.IP = result.IP4.IP.IP
ni.Mask = net.IP(result.IP4.IP.Mask)
ni.HostIP = result.IP4.Gateway
ni.IP4 = result.IP4
ni.DNS = result.DNS
} | [
"func",
"(",
"ni",
"*",
"NetInfo",
")",
"MergeCNIResult",
"(",
"result",
"types",
".",
"Result",
")",
"{",
"ni",
".",
"IP",
"=",
"result",
".",
"IP4",
".",
"IP",
".",
"IP",
"\n",
"ni",
".",
"Mask",
"=",
"net",
".",
"IP",
"(",
"result",
".",
"IP... | // MergeCNIResult will incorporate the result of a CNI plugin's execution | [
"MergeCNIResult",
"will",
"incorporate",
"the",
"result",
"of",
"a",
"CNI",
"plugin",
"s",
"execution"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/netinfo/netinfo.go#L74-L80 | train |
rkt/rkt | pkg/multicall/multicall.go | Add | func Add(name string, fn commandFn) Entrypoint {
if _, ok := commands[name]; ok {
panic(fmt.Errorf("command with name %q already exists", name))
}
commands[name] = fn
return Entrypoint(name)
} | go | func Add(name string, fn commandFn) Entrypoint {
if _, ok := commands[name]; ok {
panic(fmt.Errorf("command with name %q already exists", name))
}
commands[name] = fn
return Entrypoint(name)
} | [
"func",
"Add",
"(",
"name",
"string",
",",
"fn",
"commandFn",
")",
"Entrypoint",
"{",
"if",
"_",
",",
"ok",
":=",
"commands",
"[",
"name",
"]",
";",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"name",
")",
")",
"\n",
"}... | // Add adds a new multicall command. name is the command name and fn is the
// function that will be executed for the specified command. It returns the
// related Entrypoint.
// Packages adding new multicall commands should call Add in their init
// function. | [
"Add",
"adds",
"a",
"new",
"multicall",
"command",
".",
"name",
"is",
"the",
"command",
"name",
"and",
"fn",
"is",
"the",
"function",
"that",
"will",
"be",
"executed",
"for",
"the",
"specified",
"command",
".",
"It",
"returns",
"the",
"related",
"Entrypoin... | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/multicall/multicall.go#L52-L58 | train |
rkt/rkt | rkt/stage1hash.go | addStage1ImageFlags | func addStage1ImageFlags(flags *pflag.FlagSet) {
for _, data := range stage1FlagsData {
wrapper := &stage1ImageLocationFlag{
loc: &overriddenStage1Location,
kind: data.kind,
}
flags.Var(wrapper, data.flag, data.help)
}
} | go | func addStage1ImageFlags(flags *pflag.FlagSet) {
for _, data := range stage1FlagsData {
wrapper := &stage1ImageLocationFlag{
loc: &overriddenStage1Location,
kind: data.kind,
}
flags.Var(wrapper, data.flag, data.help)
}
} | [
"func",
"addStage1ImageFlags",
"(",
"flags",
"*",
"pflag",
".",
"FlagSet",
")",
"{",
"for",
"_",
",",
"data",
":=",
"range",
"stage1FlagsData",
"{",
"wrapper",
":=",
"&",
"stage1ImageLocationFlag",
"{",
"loc",
":",
"&",
"overriddenStage1Location",
",",
"kind",... | // addStage1ImageFlags adds flags for specifying custom stage1 image | [
"addStage1ImageFlags",
"adds",
"flags",
"for",
"specifying",
"custom",
"stage1",
"image"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/stage1hash.go#L157-L165 | train |
rkt/rkt | pkg/sys/capability.go | HasChrootCapability | func HasChrootCapability() bool {
// Checking the capabilities should be enough, but in case there're
// problem retrieving them, fallback checking for the effective uid
// (hoping it hasn't dropped its CAP_SYS_CHROOT).
caps, err := capability.NewPid(0)
if err == nil {
return caps.Get(capability.EFFECTIVE, capab... | go | func HasChrootCapability() bool {
// Checking the capabilities should be enough, but in case there're
// problem retrieving them, fallback checking for the effective uid
// (hoping it hasn't dropped its CAP_SYS_CHROOT).
caps, err := capability.NewPid(0)
if err == nil {
return caps.Get(capability.EFFECTIVE, capab... | [
"func",
"HasChrootCapability",
"(",
")",
"bool",
"{",
"// Checking the capabilities should be enough, but in case there're",
"// problem retrieving them, fallback checking for the effective uid",
"// (hoping it hasn't dropped its CAP_SYS_CHROOT).",
"caps",
",",
"err",
":=",
"capability",
... | // HasChrootCapability checks if the current process has the CAP_SYS_CHROOT
// capability | [
"HasChrootCapability",
"checks",
"if",
"the",
"current",
"process",
"has",
"the",
"CAP_SYS_CHROOT",
"capability"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/sys/capability.go#L25-L35 | train |
rkt/rkt | pkg/group/group.go | LookupGidFromFile | func LookupGidFromFile(groupName, groupFile string) (gid int, err error) {
groups, err := parseGroupFile(groupFile)
if err != nil {
return -1, errwrap.Wrap(fmt.Errorf("error parsing %q file", groupFile), err)
}
group, ok := groups[groupName]
if !ok {
return -1, fmt.Errorf("%q group not found", groupName)
}
... | go | func LookupGidFromFile(groupName, groupFile string) (gid int, err error) {
groups, err := parseGroupFile(groupFile)
if err != nil {
return -1, errwrap.Wrap(fmt.Errorf("error parsing %q file", groupFile), err)
}
group, ok := groups[groupName]
if !ok {
return -1, fmt.Errorf("%q group not found", groupName)
}
... | [
"func",
"LookupGidFromFile",
"(",
"groupName",
",",
"groupFile",
"string",
")",
"(",
"gid",
"int",
",",
"err",
"error",
")",
"{",
"groups",
",",
"err",
":=",
"parseGroupFile",
"(",
"groupFile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"-",
"... | // LookupGid reads the group file specified by groupFile, and returns the gid of the group
// specified by groupName. | [
"LookupGid",
"reads",
"the",
"group",
"file",
"specified",
"by",
"groupFile",
"and",
"returns",
"the",
"gid",
"of",
"the",
"group",
"specified",
"by",
"groupName",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/group/group.go#L43-L55 | train |
rkt/rkt | pkg/lock/keylock.go | TryExclusiveKeyLock | func TryExclusiveKeyLock(lockDir string, key string) (*KeyLock, error) {
return createAndLock(lockDir, key, keyLockExclusive|keyLockNonBlocking)
} | go | func TryExclusiveKeyLock(lockDir string, key string) (*KeyLock, error) {
return createAndLock(lockDir, key, keyLockExclusive|keyLockNonBlocking)
} | [
"func",
"TryExclusiveKeyLock",
"(",
"lockDir",
"string",
",",
"key",
"string",
")",
"(",
"*",
"KeyLock",
",",
"error",
")",
"{",
"return",
"createAndLock",
"(",
"lockDir",
",",
"key",
",",
"keyLockExclusive",
"|",
"keyLockNonBlocking",
")",
"\n",
"}"
] | // TryExclusiveLock takes an exclusive lock on the key without blocking.
// lockDir is the directory where the lock file will be created.
// It will return ErrLocked if any lock is already held. | [
"TryExclusiveLock",
"takes",
"an",
"exclusive",
"lock",
"on",
"the",
"key",
"without",
"blocking",
".",
"lockDir",
"is",
"the",
"directory",
"where",
"the",
"lock",
"file",
"will",
"be",
"created",
".",
"It",
"will",
"return",
"ErrLocked",
"if",
"any",
"lock... | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/lock/keylock.go#L94-L96 | train |
rkt/rkt | pkg/lock/keylock.go | ExclusiveKeyLock | func ExclusiveKeyLock(lockDir string, key string) (*KeyLock, error) {
return createAndLock(lockDir, key, keyLockExclusive)
} | go | func ExclusiveKeyLock(lockDir string, key string) (*KeyLock, error) {
return createAndLock(lockDir, key, keyLockExclusive)
} | [
"func",
"ExclusiveKeyLock",
"(",
"lockDir",
"string",
",",
"key",
"string",
")",
"(",
"*",
"KeyLock",
",",
"error",
")",
"{",
"return",
"createAndLock",
"(",
"lockDir",
",",
"key",
",",
"keyLockExclusive",
")",
"\n",
"}"
] | // ExclusiveLock takes an exclusive lock on a key.
// lockDir is the directory where the lock file will be created.
// It will block if an exclusive lock is already held on the key. | [
"ExclusiveLock",
"takes",
"an",
"exclusive",
"lock",
"on",
"a",
"key",
".",
"lockDir",
"is",
"the",
"directory",
"where",
"the",
"lock",
"file",
"will",
"be",
"created",
".",
"It",
"will",
"block",
"if",
"an",
"exclusive",
"lock",
"is",
"already",
"held",
... | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/lock/keylock.go#L109-L111 | train |
rkt/rkt | pkg/lock/keylock.go | Unlock | func (l *KeyLock) Unlock() error {
err := l.keyLock.Unlock()
if err != nil {
return err
}
return nil
} | go | func (l *KeyLock) Unlock() error {
err := l.keyLock.Unlock()
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"l",
"*",
"KeyLock",
")",
"Unlock",
"(",
")",
"error",
"{",
"err",
":=",
"l",
".",
"keyLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Unlock unlocks the key lock. | [
"Unlock",
"unlocks",
"the",
"key",
"lock",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/lock/keylock.go#L238-L244 | train |
rkt/rkt | pkg/lock/keylock.go | CleanKeyLocks | func CleanKeyLocks(lockDir string) error {
f, err := os.Open(lockDir)
if err != nil {
return errwrap.Wrap(errors.New("error opening lockDir"), err)
}
defer f.Close()
files, err := f.Readdir(0)
if err != nil {
return errwrap.Wrap(errors.New("error getting lock files list"), err)
}
for _, f := range files {
... | go | func CleanKeyLocks(lockDir string) error {
f, err := os.Open(lockDir)
if err != nil {
return errwrap.Wrap(errors.New("error opening lockDir"), err)
}
defer f.Close()
files, err := f.Readdir(0)
if err != nil {
return errwrap.Wrap(errors.New("error getting lock files list"), err)
}
for _, f := range files {
... | [
"func",
"CleanKeyLocks",
"(",
"lockDir",
"string",
")",
"error",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"lockDir",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errwrap",
".",
"Wrap",
"(",
"errors",
".",
"New",
"(",
"\"",
"\"",
... | // CleanKeyLocks remove lock files from the lockDir.
// For every key it tries to take an Exclusive lock on it and skip it if it
// fails with ErrLocked | [
"CleanKeyLocks",
"remove",
"lock",
"files",
"from",
"the",
"lockDir",
".",
"For",
"every",
"key",
"it",
"tries",
"to",
"take",
"an",
"Exclusive",
"lock",
"on",
"it",
"and",
"skip",
"it",
"if",
"it",
"fails",
"with",
"ErrLocked"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/lock/keylock.go#L249-L277 | train |
rkt/rkt | rkt/pubkey/pubkey.go | GetPubKeyLocations | func (m *Manager) GetPubKeyLocations(prefix string) ([]string, error) {
ensureLogger(m.Debug)
if prefix == "" {
return nil, fmt.Errorf("empty prefix")
}
kls, err := m.metaDiscoverPubKeyLocations(prefix)
if err != nil {
return nil, errwrap.Wrap(errors.New("prefix meta discovery error"), err)
}
if len(kls) =... | go | func (m *Manager) GetPubKeyLocations(prefix string) ([]string, error) {
ensureLogger(m.Debug)
if prefix == "" {
return nil, fmt.Errorf("empty prefix")
}
kls, err := m.metaDiscoverPubKeyLocations(prefix)
if err != nil {
return nil, errwrap.Wrap(errors.New("prefix meta discovery error"), err)
}
if len(kls) =... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"GetPubKeyLocations",
"(",
"prefix",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"ensureLogger",
"(",
"m",
".",
"Debug",
")",
"\n",
"if",
"prefix",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"... | // GetPubKeyLocations discovers locations at prefix | [
"GetPubKeyLocations",
"discovers",
"locations",
"at",
"prefix"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L72-L88 | train |
rkt/rkt | rkt/pubkey/pubkey.go | AddKeys | func (m *Manager) AddKeys(pkls []string, prefix string, accept AcceptOption) error {
ensureLogger(m.Debug)
if m.Ks == nil {
return fmt.Errorf("no keystore available to add keys to")
}
for _, pkl := range pkls {
u, err := url.Parse(pkl)
if err != nil {
return err
}
pk, err := m.getPubKey(u)
if err !=... | go | func (m *Manager) AddKeys(pkls []string, prefix string, accept AcceptOption) error {
ensureLogger(m.Debug)
if m.Ks == nil {
return fmt.Errorf("no keystore available to add keys to")
}
for _, pkl := range pkls {
u, err := url.Parse(pkl)
if err != nil {
return err
}
pk, err := m.getPubKey(u)
if err !=... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"AddKeys",
"(",
"pkls",
"[",
"]",
"string",
",",
"prefix",
"string",
",",
"accept",
"AcceptOption",
")",
"error",
"{",
"ensureLogger",
"(",
"m",
".",
"Debug",
")",
"\n",
"if",
"m",
".",
"Ks",
"==",
"nil",
"{",... | // AddKeys adds the keys listed in pkls at prefix | [
"AddKeys",
"adds",
"the",
"keys",
"listed",
"in",
"pkls",
"at",
"prefix"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L91-L155 | train |
rkt/rkt | rkt/pubkey/pubkey.go | metaDiscoverPubKeyLocations | func (m *Manager) metaDiscoverPubKeyLocations(prefix string) ([]string, error) {
app, err := discovery.NewAppFromString(prefix)
if err != nil {
return nil, err
}
hostHeaders := config.ResolveAuthPerHost(m.AuthPerHost)
insecure := discovery.InsecureNone
if m.InsecureAllowHTTP {
insecure = insecure | discovery... | go | func (m *Manager) metaDiscoverPubKeyLocations(prefix string) ([]string, error) {
app, err := discovery.NewAppFromString(prefix)
if err != nil {
return nil, err
}
hostHeaders := config.ResolveAuthPerHost(m.AuthPerHost)
insecure := discovery.InsecureNone
if m.InsecureAllowHTTP {
insecure = insecure | discovery... | [
"func",
"(",
"m",
"*",
"Manager",
")",
"metaDiscoverPubKeyLocations",
"(",
"prefix",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"app",
",",
"err",
":=",
"discovery",
".",
"NewAppFromString",
"(",
"prefix",
")",
"\n",
"if",
"err",
"... | // metaDiscoverPubKeyLocations discovers the locations of public keys through ACDiscovery by applying prefix as an ACApp | [
"metaDiscoverPubKeyLocations",
"discovers",
"the",
"locations",
"of",
"public",
"keys",
"through",
"ACDiscovery",
"by",
"applying",
"prefix",
"as",
"an",
"ACApp"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L158-L181 | train |
rkt/rkt | rkt/pubkey/pubkey.go | downloadKey | func downloadKey(u *url.URL, skipTLSCheck bool) (*os.File, error) {
tf, err := ioutil.TempFile("", "")
if err != nil {
return nil, errwrap.Wrap(errors.New("error creating tempfile"), err)
}
os.Remove(tf.Name()) // no need to keep the tempfile around
defer func() {
if tf != nil {
tf.Close()
}
}()
// TO... | go | func downloadKey(u *url.URL, skipTLSCheck bool) (*os.File, error) {
tf, err := ioutil.TempFile("", "")
if err != nil {
return nil, errwrap.Wrap(errors.New("error creating tempfile"), err)
}
os.Remove(tf.Name()) // no need to keep the tempfile around
defer func() {
if tf != nil {
tf.Close()
}
}()
// TO... | [
"func",
"downloadKey",
"(",
"u",
"*",
"url",
".",
"URL",
",",
"skipTLSCheck",
"bool",
")",
"(",
"*",
"os",
".",
"File",
",",
"error",
")",
"{",
"tf",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if"... | // downloadKey retrieves the file, storing it in a deleted tempfile | [
"downloadKey",
"retrieves",
"the",
"file",
"storing",
"it",
"in",
"a",
"deleted",
"tempfile"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L201-L244 | train |
rkt/rkt | rkt/pubkey/pubkey.go | displayKey | func displayKey(prefix, location string, key *os.File) error {
defer key.Seek(0, os.SEEK_SET)
kr, err := openpgp.ReadArmoredKeyRing(key)
if err != nil {
return errwrap.Wrap(errors.New("error reading key"), err)
}
log.Printf("prefix: %q\nkey: %q", prefix, location)
for _, k := range kr {
stdout.Printf("gpg k... | go | func displayKey(prefix, location string, key *os.File) error {
defer key.Seek(0, os.SEEK_SET)
kr, err := openpgp.ReadArmoredKeyRing(key)
if err != nil {
return errwrap.Wrap(errors.New("error reading key"), err)
}
log.Printf("prefix: %q\nkey: %q", prefix, location)
for _, k := range kr {
stdout.Printf("gpg k... | [
"func",
"displayKey",
"(",
"prefix",
",",
"location",
"string",
",",
"key",
"*",
"os",
".",
"File",
")",
"error",
"{",
"defer",
"key",
".",
"Seek",
"(",
"0",
",",
"os",
".",
"SEEK_SET",
")",
"\n\n",
"kr",
",",
"err",
":=",
"openpgp",
".",
"ReadArmo... | // displayKey shows the key summary | [
"displayKey",
"shows",
"the",
"key",
"summary"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L275-L296 | train |
rkt/rkt | rkt/pubkey/pubkey.go | reviewKey | func reviewKey() (bool, error) {
in := bufio.NewReader(os.Stdin)
for {
stdout.Printf("Are you sure you want to trust this key (yes/no)?")
input, err := in.ReadString('\n')
if err != nil {
return false, errwrap.Wrap(errors.New("error reading input"), err)
}
switch input {
case "yes\n":
return true, n... | go | func reviewKey() (bool, error) {
in := bufio.NewReader(os.Stdin)
for {
stdout.Printf("Are you sure you want to trust this key (yes/no)?")
input, err := in.ReadString('\n')
if err != nil {
return false, errwrap.Wrap(errors.New("error reading input"), err)
}
switch input {
case "yes\n":
return true, n... | [
"func",
"reviewKey",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"in",
":=",
"bufio",
".",
"NewReader",
"(",
"os",
".",
"Stdin",
")",
"\n",
"for",
"{",
"stdout",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n",
"input",
",",
"err",
":=",
"in",
"."... | // reviewKey asks the user to accept the key | [
"reviewKey",
"asks",
"the",
"user",
"to",
"accept",
"the",
"key"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L299-L316 | train |
rkt/rkt | networking/kvm.go | setupTapDevice | func setupTapDevice(podID types.UUID) (netlink.Link, error) {
// network device names are limited to 16 characters
// the suffix %d will be replaced by the kernel with a suitable number
nameTemplate := fmt.Sprintf("rkt-%s-tap%%d", podID.String()[0:4])
ifName, err := tuntap.CreatePersistentIface(nameTemplate, tuntap... | go | func setupTapDevice(podID types.UUID) (netlink.Link, error) {
// network device names are limited to 16 characters
// the suffix %d will be replaced by the kernel with a suitable number
nameTemplate := fmt.Sprintf("rkt-%s-tap%%d", podID.String()[0:4])
ifName, err := tuntap.CreatePersistentIface(nameTemplate, tuntap... | [
"func",
"setupTapDevice",
"(",
"podID",
"types",
".",
"UUID",
")",
"(",
"netlink",
".",
"Link",
",",
"error",
")",
"{",
"// network device names are limited to 16 characters",
"// the suffix %d will be replaced by the kernel with a suitable number",
"nameTemplate",
":=",
"fmt... | // setupTapDevice creates persistent tap device
// and returns a newly created netlink.Link structure | [
"setupTapDevice",
"creates",
"persistent",
"tap",
"device",
"and",
"returns",
"a",
"newly",
"created",
"netlink",
".",
"Link",
"structure"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/kvm.go#L59-L77 | train |
rkt/rkt | networking/kvm.go | setupMacVTapDevice | func setupMacVTapDevice(podID types.UUID, config MacVTapNetConf, interfaceNumber int) (netlink.Link, error) {
master, err := netlink.LinkByName(config.Master)
if err != nil {
return nil, errwrap.Wrap(fmt.Errorf("cannot find master device '%v'", config.Master), err)
}
var mode netlink.MacvlanMode
switch config.Mo... | go | func setupMacVTapDevice(podID types.UUID, config MacVTapNetConf, interfaceNumber int) (netlink.Link, error) {
master, err := netlink.LinkByName(config.Master)
if err != nil {
return nil, errwrap.Wrap(fmt.Errorf("cannot find master device '%v'", config.Master), err)
}
var mode netlink.MacvlanMode
switch config.Mo... | [
"func",
"setupMacVTapDevice",
"(",
"podID",
"types",
".",
"UUID",
",",
"config",
"MacVTapNetConf",
",",
"interfaceNumber",
"int",
")",
"(",
"netlink",
".",
"Link",
",",
"error",
")",
"{",
"master",
",",
"err",
":=",
"netlink",
".",
"LinkByName",
"(",
"conf... | // setupTapDevice creates persistent macvtap device
// and returns a newly created netlink.Link structure
// using part of pod hash and interface number in interface name | [
"setupTapDevice",
"creates",
"persistent",
"macvtap",
"device",
"and",
"returns",
"a",
"newly",
"created",
"netlink",
".",
"Link",
"structure",
"using",
"part",
"of",
"pod",
"hash",
"and",
"interface",
"number",
"in",
"interface",
"name"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/kvm.go#L92-L146 | train |
rkt/rkt | networking/kvm.go | kvmTeardown | func (n *Networking) kvmTeardown() {
if err := n.teardownForwarding(); err != nil {
stderr.PrintE("error removing forwarded ports (kvm)", err)
}
n.teardownKvmNets()
} | go | func (n *Networking) kvmTeardown() {
if err := n.teardownForwarding(); err != nil {
stderr.PrintE("error removing forwarded ports (kvm)", err)
}
n.teardownKvmNets()
} | [
"func",
"(",
"n",
"*",
"Networking",
")",
"kvmTeardown",
"(",
")",
"{",
"if",
"err",
":=",
"n",
".",
"teardownForwarding",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"stderr",
".",
"PrintE",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"n",
... | // kvmTeardown network teardown for kvm flavor based pods
// similar to Networking.Teardown but without host namespaces | [
"kvmTeardown",
"network",
"teardown",
"for",
"kvm",
"flavor",
"based",
"pods",
"similar",
"to",
"Networking",
".",
"Teardown",
"but",
"without",
"host",
"namespaces"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/kvm.go#L705-L711 | train |
rkt/rkt | rkt/image/filefetcher.go | Hash | func (f *fileFetcher) Hash(aciPath string, a *asc) (string, error) {
ensureLogger(f.Debug)
absPath, err := filepath.Abs(aciPath)
if err != nil {
return "", errwrap.Wrap(fmt.Errorf("failed to get an absolute path for %q", aciPath), err)
}
aciPath = absPath
aciFile, err := f.getFile(aciPath, a)
if err != nil {
... | go | func (f *fileFetcher) Hash(aciPath string, a *asc) (string, error) {
ensureLogger(f.Debug)
absPath, err := filepath.Abs(aciPath)
if err != nil {
return "", errwrap.Wrap(fmt.Errorf("failed to get an absolute path for %q", aciPath), err)
}
aciPath = absPath
aciFile, err := f.getFile(aciPath, a)
if err != nil {
... | [
"func",
"(",
"f",
"*",
"fileFetcher",
")",
"Hash",
"(",
"aciPath",
"string",
",",
"a",
"*",
"asc",
")",
"(",
"string",
",",
"error",
")",
"{",
"ensureLogger",
"(",
"f",
".",
"Debug",
")",
"\n",
"absPath",
",",
"err",
":=",
"filepath",
".",
"Abs",
... | // Hash opens a file, optionally verifies it against passed asc,
// stores it in the store and returns the hash. | [
"Hash",
"opens",
"a",
"file",
"optionally",
"verifies",
"it",
"against",
"passed",
"asc",
"stores",
"it",
"in",
"the",
"store",
"and",
"returns",
"the",
"hash",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/filefetcher.go#L39-L61 | train |
rkt/rkt | rkt/image/filefetcher.go | getVerifiedFile | func (f *fileFetcher) getVerifiedFile(aciPath string, a *asc) (*os.File, error) {
var aciFile *os.File // closed on error
var errClose error // error signaling to close aciFile
f.maybeOverrideAsc(aciPath, a)
ascFile, err := a.Get()
if err != nil {
return nil, errwrap.Wrap(errors.New("error opening signature f... | go | func (f *fileFetcher) getVerifiedFile(aciPath string, a *asc) (*os.File, error) {
var aciFile *os.File // closed on error
var errClose error // error signaling to close aciFile
f.maybeOverrideAsc(aciPath, a)
ascFile, err := a.Get()
if err != nil {
return nil, errwrap.Wrap(errors.New("error opening signature f... | [
"func",
"(",
"f",
"*",
"fileFetcher",
")",
"getVerifiedFile",
"(",
"aciPath",
"string",
",",
"a",
"*",
"asc",
")",
"(",
"*",
"os",
".",
"File",
",",
"error",
")",
"{",
"var",
"aciFile",
"*",
"os",
".",
"File",
"// closed on error",
"\n",
"var",
"errC... | // fetch opens and verifies the ACI. | [
"fetch",
"opens",
"and",
"verifies",
"the",
"ACI",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/filefetcher.go#L82-L116 | train |
rkt/rkt | pkg/fs/mount.go | NewLoggingMounter | func NewLoggingMounter(m Mounter, um Unmounter, logf func(string, ...interface{})) MountUnmounter {
return &loggingMounter{m, um, logf}
} | go | func NewLoggingMounter(m Mounter, um Unmounter, logf func(string, ...interface{})) MountUnmounter {
return &loggingMounter{m, um, logf}
} | [
"func",
"NewLoggingMounter",
"(",
"m",
"Mounter",
",",
"um",
"Unmounter",
",",
"logf",
"func",
"(",
"string",
",",
"...",
"interface",
"{",
"}",
")",
")",
"MountUnmounter",
"{",
"return",
"&",
"loggingMounter",
"{",
"m",
",",
"um",
",",
"logf",
"}",
"\... | // NewLoggingMounter returns a MountUnmounter that logs mount events using the given logger func. | [
"NewLoggingMounter",
"returns",
"a",
"MountUnmounter",
"that",
"logs",
"mount",
"events",
"using",
"the",
"given",
"logger",
"func",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/fs/mount.go#L56-L58 | train |
rkt/rkt | pkg/tpm/tpm.go | Extend | func Extend(description string) error {
connection := tpmclient.New("localhost:12041", timeout)
err := connection.Extend(15, 0x1000, nil, description)
return err
} | go | func Extend(description string) error {
connection := tpmclient.New("localhost:12041", timeout)
err := connection.Extend(15, 0x1000, nil, description)
return err
} | [
"func",
"Extend",
"(",
"description",
"string",
")",
"error",
"{",
"connection",
":=",
"tpmclient",
".",
"New",
"(",
"\"",
"\"",
",",
"timeout",
")",
"\n",
"err",
":=",
"connection",
".",
"Extend",
"(",
"15",
",",
"0x1000",
",",
"nil",
",",
"descriptio... | // Extend extends the TPM log with the provided string. Returns any error. | [
"Extend",
"extends",
"the",
"TPM",
"log",
"with",
"the",
"provided",
"string",
".",
"Returns",
"any",
"error",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/tpm/tpm.go#L29-L33 | train |
rkt/rkt | common/common.go | Stage1RootfsPath | func Stage1RootfsPath(root string) string {
return filepath.Join(Stage1ImagePath(root), aci.RootfsDir)
} | go | func Stage1RootfsPath(root string) string {
return filepath.Join(Stage1ImagePath(root), aci.RootfsDir)
} | [
"func",
"Stage1RootfsPath",
"(",
"root",
"string",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"Stage1ImagePath",
"(",
"root",
")",
",",
"aci",
".",
"RootfsDir",
")",
"\n",
"}"
] | // Stage1RootfsPath returns the path to the stage1 rootfs | [
"Stage1RootfsPath",
"returns",
"the",
"path",
"to",
"the",
"stage1",
"rootfs"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L101-L103 | train |
rkt/rkt | common/common.go | Stage1ManifestPath | func Stage1ManifestPath(root string) string {
return filepath.Join(Stage1ImagePath(root), aci.ManifestFile)
} | go | func Stage1ManifestPath(root string) string {
return filepath.Join(Stage1ImagePath(root), aci.ManifestFile)
} | [
"func",
"Stage1ManifestPath",
"(",
"root",
"string",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"Stage1ImagePath",
"(",
"root",
")",
",",
"aci",
".",
"ManifestFile",
")",
"\n",
"}"
] | // Stage1ManifestPath returns the path to the stage1's manifest file inside the expanded ACI. | [
"Stage1ManifestPath",
"returns",
"the",
"path",
"to",
"the",
"stage1",
"s",
"manifest",
"file",
"inside",
"the",
"expanded",
"ACI",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L106-L108 | train |
rkt/rkt | common/common.go | AppStatusPath | func AppStatusPath(root, appName string) string {
return filepath.Join(AppsStatusesPath(root), appName)
} | go | func AppStatusPath(root, appName string) string {
return filepath.Join(AppsStatusesPath(root), appName)
} | [
"func",
"AppStatusPath",
"(",
"root",
",",
"appName",
"string",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"AppsStatusesPath",
"(",
"root",
")",
",",
"appName",
")",
"\n",
"}"
] | // AppStatusPath returns the path of the status file of an app. | [
"AppStatusPath",
"returns",
"the",
"path",
"of",
"the",
"status",
"file",
"of",
"an",
"app",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L140-L142 | train |
rkt/rkt | common/common.go | AppStatusPathFromStage1Rootfs | func AppStatusPathFromStage1Rootfs(rootfs, appName string) string {
return filepath.Join(AppsStatusesPathFromStage1Rootfs(rootfs), appName)
} | go | func AppStatusPathFromStage1Rootfs(rootfs, appName string) string {
return filepath.Join(AppsStatusesPathFromStage1Rootfs(rootfs), appName)
} | [
"func",
"AppStatusPathFromStage1Rootfs",
"(",
"rootfs",
",",
"appName",
"string",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"AppsStatusesPathFromStage1Rootfs",
"(",
"rootfs",
")",
",",
"appName",
")",
"\n",
"}"
] | // AppStatusPathFromStage1Rootfs returns the path of the status file of an app.
// It receives the stage1 rootfs as parameter instead of the pod root. | [
"AppStatusPathFromStage1Rootfs",
"returns",
"the",
"path",
"of",
"the",
"status",
"file",
"of",
"an",
"app",
".",
"It",
"receives",
"the",
"stage1",
"rootfs",
"as",
"parameter",
"instead",
"of",
"the",
"pod",
"root",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L146-L148 | train |
rkt/rkt | common/common.go | AppPath | func AppPath(root string, appName types.ACName) string {
return filepath.Join(AppsPath(root), appName.String())
} | go | func AppPath(root string, appName types.ACName) string {
return filepath.Join(AppsPath(root), appName.String())
} | [
"func",
"AppPath",
"(",
"root",
"string",
",",
"appName",
"types",
".",
"ACName",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"AppsPath",
"(",
"root",
")",
",",
"appName",
".",
"String",
"(",
")",
")",
"\n",
"}"
] | // AppPath returns the path to an app's rootfs. | [
"AppPath",
"returns",
"the",
"path",
"to",
"an",
"app",
"s",
"rootfs",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L182-L184 | train |
rkt/rkt | common/common.go | AppRootfsPath | func AppRootfsPath(root string, appName types.ACName) string {
return filepath.Join(AppPath(root, appName), aci.RootfsDir)
} | go | func AppRootfsPath(root string, appName types.ACName) string {
return filepath.Join(AppPath(root, appName), aci.RootfsDir)
} | [
"func",
"AppRootfsPath",
"(",
"root",
"string",
",",
"appName",
"types",
".",
"ACName",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"AppPath",
"(",
"root",
",",
"appName",
")",
",",
"aci",
".",
"RootfsDir",
")",
"\n",
"}"
] | // AppRootfsPath returns the path to an app's rootfs. | [
"AppRootfsPath",
"returns",
"the",
"path",
"to",
"an",
"app",
"s",
"rootfs",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L187-L189 | train |
rkt/rkt | common/common.go | RelAppPath | func RelAppPath(appName types.ACName) string {
return filepath.Join(stage2Dir, appName.String())
} | go | func RelAppPath(appName types.ACName) string {
return filepath.Join(stage2Dir, appName.String())
} | [
"func",
"RelAppPath",
"(",
"appName",
"types",
".",
"ACName",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"stage2Dir",
",",
"appName",
".",
"String",
"(",
")",
")",
"\n",
"}"
] | // RelAppPath returns the path of an app relative to the stage1 chroot. | [
"RelAppPath",
"returns",
"the",
"path",
"of",
"an",
"app",
"relative",
"to",
"the",
"stage1",
"chroot",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L192-L194 | train |
rkt/rkt | common/common.go | RelAppRootfsPath | func RelAppRootfsPath(appName types.ACName) string {
return filepath.Join(RelAppPath(appName), aci.RootfsDir)
} | go | func RelAppRootfsPath(appName types.ACName) string {
return filepath.Join(RelAppPath(appName), aci.RootfsDir)
} | [
"func",
"RelAppRootfsPath",
"(",
"appName",
"types",
".",
"ACName",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"RelAppPath",
"(",
"appName",
")",
",",
"aci",
".",
"RootfsDir",
")",
"\n",
"}"
] | // RelAppRootfsPath returns the path of an app's rootfs relative to the stage1 chroot. | [
"RelAppRootfsPath",
"returns",
"the",
"path",
"of",
"an",
"app",
"s",
"rootfs",
"relative",
"to",
"the",
"stage1",
"chroot",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L197-L199 | train |
rkt/rkt | common/common.go | ImageManifestPath | func ImageManifestPath(root string, appName types.ACName) string {
return filepath.Join(AppPath(root, appName), aci.ManifestFile)
} | go | func ImageManifestPath(root string, appName types.ACName) string {
return filepath.Join(AppPath(root, appName), aci.ManifestFile)
} | [
"func",
"ImageManifestPath",
"(",
"root",
"string",
",",
"appName",
"types",
".",
"ACName",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"AppPath",
"(",
"root",
",",
"appName",
")",
",",
"aci",
".",
"ManifestFile",
")",
"\n",
"}"
] | // ImageManifestPath returns the path to the app's manifest file of a pod. | [
"ImageManifestPath",
"returns",
"the",
"path",
"to",
"the",
"app",
"s",
"manifest",
"file",
"of",
"a",
"pod",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L202-L204 | train |
rkt/rkt | common/common.go | AppInfoPath | func AppInfoPath(root string, appName types.ACName) string {
return filepath.Join(AppsInfoPath(root), appName.String())
} | go | func AppInfoPath(root string, appName types.ACName) string {
return filepath.Join(AppsInfoPath(root), appName.String())
} | [
"func",
"AppInfoPath",
"(",
"root",
"string",
",",
"appName",
"types",
".",
"ACName",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"AppsInfoPath",
"(",
"root",
")",
",",
"appName",
".",
"String",
"(",
")",
")",
"\n",
"}"
] | // AppInfoPath returns the path to the app's appsinfo directory of a pod. | [
"AppInfoPath",
"returns",
"the",
"path",
"to",
"the",
"app",
"s",
"appsinfo",
"directory",
"of",
"a",
"pod",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L212-L214 | train |
rkt/rkt | common/common.go | AppTreeStoreIDPath | func AppTreeStoreIDPath(root string, appName types.ACName) string {
return filepath.Join(AppInfoPath(root, appName), AppTreeStoreIDFilename)
} | go | func AppTreeStoreIDPath(root string, appName types.ACName) string {
return filepath.Join(AppInfoPath(root, appName), AppTreeStoreIDFilename)
} | [
"func",
"AppTreeStoreIDPath",
"(",
"root",
"string",
",",
"appName",
"types",
".",
"ACName",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"AppInfoPath",
"(",
"root",
",",
"appName",
")",
",",
"AppTreeStoreIDFilename",
")",
"\n",
"}"
] | // AppTreeStoreIDPath returns the path to the app's treeStoreID file of a pod. | [
"AppTreeStoreIDPath",
"returns",
"the",
"path",
"to",
"the",
"app",
"s",
"treeStoreID",
"file",
"of",
"a",
"pod",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L217-L219 | train |
rkt/rkt | common/common.go | AppImageManifestPath | func AppImageManifestPath(root string, appName types.ACName) string {
return filepath.Join(AppInfoPath(root, appName), aci.ManifestFile)
} | go | func AppImageManifestPath(root string, appName types.ACName) string {
return filepath.Join(AppInfoPath(root, appName), aci.ManifestFile)
} | [
"func",
"AppImageManifestPath",
"(",
"root",
"string",
",",
"appName",
"types",
".",
"ACName",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"AppInfoPath",
"(",
"root",
",",
"appName",
")",
",",
"aci",
".",
"ManifestFile",
")",
"\n",
"}"
] | // AppImageManifestPath returns the path to the app's ImageManifest file | [
"AppImageManifestPath",
"returns",
"the",
"path",
"to",
"the",
"app",
"s",
"ImageManifest",
"file"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L222-L224 | train |
rkt/rkt | common/common.go | CreateSharedVolumesPath | func CreateSharedVolumesPath(root string) (string, error) {
sharedVolPath := SharedVolumesPath(root)
if err := os.MkdirAll(sharedVolPath, SharedVolumePerm); err != nil {
return "", errwrap.Wrap(errors.New("could not create shared volumes directory"), err)
}
// In case it already existed and we didn't make it, en... | go | func CreateSharedVolumesPath(root string) (string, error) {
sharedVolPath := SharedVolumesPath(root)
if err := os.MkdirAll(sharedVolPath, SharedVolumePerm); err != nil {
return "", errwrap.Wrap(errors.New("could not create shared volumes directory"), err)
}
// In case it already existed and we didn't make it, en... | [
"func",
"CreateSharedVolumesPath",
"(",
"root",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"sharedVolPath",
":=",
"SharedVolumesPath",
"(",
"root",
")",
"\n\n",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"sharedVolPath",
",",
"SharedVolumePerm",... | // CreateSharedVolumesPath ensures the sharedVolumePath for the pod root passed
// in exists. It returns the shared volume path or an error. | [
"CreateSharedVolumesPath",
"ensures",
"the",
"sharedVolumePath",
"for",
"the",
"pod",
"root",
"passed",
"in",
"exists",
".",
"It",
"returns",
"the",
"shared",
"volume",
"path",
"or",
"an",
"error",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L233-L246 | train |
rkt/rkt | common/common.go | MetadataServicePublicURL | func MetadataServicePublicURL(ip net.IP, token string) string {
return fmt.Sprintf("http://%v:%v/%v", ip, MetadataServicePort, token)
} | go | func MetadataServicePublicURL(ip net.IP, token string) string {
return fmt.Sprintf("http://%v:%v/%v", ip, MetadataServicePort, token)
} | [
"func",
"MetadataServicePublicURL",
"(",
"ip",
"net",
".",
"IP",
",",
"token",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ip",
",",
"MetadataServicePort",
",",
"token",
")",
"\n",
"}"
] | // MetadataServicePublicURL returns the public URL used to host the metadata service | [
"MetadataServicePublicURL",
"returns",
"the",
"public",
"URL",
"used",
"to",
"host",
"the",
"metadata",
"service"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L249-L251 | train |
rkt/rkt | common/common.go | LookupPath | func LookupPath(bin string, paths string) (string, error) {
pathsArr := filepath.SplitList(paths)
for _, path := range pathsArr {
binPath := filepath.Join(path, bin)
binAbsPath, err := filepath.Abs(binPath)
if err != nil {
return "", fmt.Errorf("unable to find absolute path for %s", binPath)
}
if fileuti... | go | func LookupPath(bin string, paths string) (string, error) {
pathsArr := filepath.SplitList(paths)
for _, path := range pathsArr {
binPath := filepath.Join(path, bin)
binAbsPath, err := filepath.Abs(binPath)
if err != nil {
return "", fmt.Errorf("unable to find absolute path for %s", binPath)
}
if fileuti... | [
"func",
"LookupPath",
"(",
"bin",
"string",
",",
"paths",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"pathsArr",
":=",
"filepath",
".",
"SplitList",
"(",
"paths",
")",
"\n",
"for",
"_",
",",
"path",
":=",
"range",
"pathsArr",
"{",
"binPath",... | // LookupPath search for bin in paths. If found, it returns its absolute path,
// if not, an error | [
"LookupPath",
"search",
"for",
"bin",
"in",
"paths",
".",
"If",
"found",
"it",
"returns",
"its",
"absolute",
"path",
"if",
"not",
"an",
"error"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L375-L388 | train |
rkt/rkt | common/common.go | SystemdVersion | func SystemdVersion(systemdBinaryPath string) (int, error) {
versionBytes, err := exec.Command(systemdBinaryPath, "--version").CombinedOutput()
if err != nil {
return -1, errwrap.Wrap(fmt.Errorf("unable to probe %s version", systemdBinaryPath), err)
}
versionStr := strings.SplitN(string(versionBytes), "\n", 2)[0]... | go | func SystemdVersion(systemdBinaryPath string) (int, error) {
versionBytes, err := exec.Command(systemdBinaryPath, "--version").CombinedOutput()
if err != nil {
return -1, errwrap.Wrap(fmt.Errorf("unable to probe %s version", systemdBinaryPath), err)
}
versionStr := strings.SplitN(string(versionBytes), "\n", 2)[0]... | [
"func",
"SystemdVersion",
"(",
"systemdBinaryPath",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"versionBytes",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"systemdBinaryPath",
",",
"\"",
"\"",
")",
".",
"CombinedOutput",
"(",
")",
"\n",
"if",
... | // SystemdVersion parses and returns the version of a given systemd binary | [
"SystemdVersion",
"parses",
"and",
"returns",
"the",
"version",
"of",
"a",
"given",
"systemd",
"binary"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L391-L404 | train |
rkt/rkt | common/common.go | SupportsOverlay | func SupportsOverlay() error {
// ignore exec.Command error, modprobe may not be present on the system,
// or the kernel module will fail to load.
// we'll find out by reading the side effect in /proc/filesystems
_ = exec.Command("modprobe", "overlay").Run()
f, err := os.Open("/proc/filesystems")
if err != nil {... | go | func SupportsOverlay() error {
// ignore exec.Command error, modprobe may not be present on the system,
// or the kernel module will fail to load.
// we'll find out by reading the side effect in /proc/filesystems
_ = exec.Command("modprobe", "overlay").Run()
f, err := os.Open("/proc/filesystems")
if err != nil {... | [
"func",
"SupportsOverlay",
"(",
")",
"error",
"{",
"// ignore exec.Command error, modprobe may not be present on the system,",
"// or the kernel module will fail to load.",
"// we'll find out by reading the side effect in /proc/filesystems",
"_",
"=",
"exec",
".",
"Command",
"(",
"\"",... | // SupportsOverlay returns whether the operating system generally supports OverlayFS,
// returning an instance of ErrOverlayUnsupported which encodes the reason.
// It is sufficient to check for nil if the reason is not of interest. | [
"SupportsOverlay",
"returns",
"whether",
"the",
"operating",
"system",
"generally",
"supports",
"OverlayFS",
"returning",
"an",
"instance",
"of",
"ErrOverlayUnsupported",
"which",
"encodes",
"the",
"reason",
".",
"It",
"is",
"sufficient",
"to",
"check",
"for",
"nil"... | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L409-L430 | train |
rkt/rkt | common/common.go | RemoveEmptyLines | func RemoveEmptyLines(str string) []string {
lines := make([]string, 0)
for _, v := range strings.Split(str, "\n") {
if len(v) > 0 {
lines = append(lines, v)
}
}
return lines
} | go | func RemoveEmptyLines(str string) []string {
lines := make([]string, 0)
for _, v := range strings.Split(str, "\n") {
if len(v) > 0 {
lines = append(lines, v)
}
}
return lines
} | [
"func",
"RemoveEmptyLines",
"(",
"str",
"string",
")",
"[",
"]",
"string",
"{",
"lines",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"strings",
".",
"Split",
"(",
"str",
",",
"\"",
"\\n",
"\"... | // RemoveEmptyLines removes empty lines from the given string
// and breaks it up into a list of strings at newline characters | [
"RemoveEmptyLines",
"removes",
"empty",
"lines",
"from",
"the",
"given",
"string",
"and",
"breaks",
"it",
"up",
"into",
"a",
"list",
"of",
"strings",
"at",
"newline",
"characters"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L490-L500 | train |
rkt/rkt | common/common.go | GetExitStatus | func GetExitStatus(err error) (int, error) {
if err == nil {
return 0, nil
}
if exiterr, ok := err.(*exec.ExitError); ok {
// the program has exited with an exit code != 0
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
return status.ExitStatus(), nil
}
}
return -1, err
} | go | func GetExitStatus(err error) (int, error) {
if err == nil {
return 0, nil
}
if exiterr, ok := err.(*exec.ExitError); ok {
// the program has exited with an exit code != 0
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
return status.ExitStatus(), nil
}
}
return -1, err
} | [
"func",
"GetExitStatus",
"(",
"err",
"error",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"0",
",",
"nil",
"\n",
"}",
"\n",
"if",
"exiterr",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"exec",
".",
"ExitError",
... | // GetExitStatus converts an error to an exit status. If it wasn't an exit
// status != 0 it returns the same error that it was called with | [
"GetExitStatus",
"converts",
"an",
"error",
"to",
"an",
"exit",
"status",
".",
"If",
"it",
"wasn",
"t",
"an",
"exit",
"status",
"!",
"=",
"0",
"it",
"returns",
"the",
"same",
"error",
"that",
"it",
"was",
"called",
"with"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L504-L515 | train |
rkt/rkt | common/common.go | ImageNameToAppName | func ImageNameToAppName(name types.ACIdentifier) (*types.ACName, error) {
parts := strings.Split(name.String(), "/")
last := parts[len(parts)-1]
sn, err := types.SanitizeACName(last)
if err != nil {
return nil, err
}
return types.MustACName(sn), nil
} | go | func ImageNameToAppName(name types.ACIdentifier) (*types.ACName, error) {
parts := strings.Split(name.String(), "/")
last := parts[len(parts)-1]
sn, err := types.SanitizeACName(last)
if err != nil {
return nil, err
}
return types.MustACName(sn), nil
} | [
"func",
"ImageNameToAppName",
"(",
"name",
"types",
".",
"ACIdentifier",
")",
"(",
"*",
"types",
".",
"ACName",
",",
"error",
")",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"name",
".",
"String",
"(",
")",
",",
"\"",
"\"",
")",
"\n",
"last",
... | // ImageNameToAppName converts the full name of image to an app name without special
// characters - we use it as a default app name when specyfing it is optional | [
"ImageNameToAppName",
"converts",
"the",
"full",
"name",
"of",
"image",
"to",
"an",
"app",
"name",
"without",
"special",
"characters",
"-",
"we",
"use",
"it",
"as",
"a",
"default",
"app",
"name",
"when",
"specyfing",
"it",
"is",
"optional"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L545-L555 | train |
rkt/rkt | stage1/init/kvm/network.go | GetNetworkDescriptions | func GetNetworkDescriptions(n *networking.Networking) []NetDescriber {
var nds []NetDescriber
for _, an := range n.GetActiveNetworks() {
nds = append(nds, an)
}
return nds
} | go | func GetNetworkDescriptions(n *networking.Networking) []NetDescriber {
var nds []NetDescriber
for _, an := range n.GetActiveNetworks() {
nds = append(nds, an)
}
return nds
} | [
"func",
"GetNetworkDescriptions",
"(",
"n",
"*",
"networking",
".",
"Networking",
")",
"[",
"]",
"NetDescriber",
"{",
"var",
"nds",
"[",
"]",
"NetDescriber",
"\n",
"for",
"_",
",",
"an",
":=",
"range",
"n",
".",
"GetActiveNetworks",
"(",
")",
"{",
"nds",... | // GetNetworkDescriptions converts activeNets to netDescribers | [
"GetNetworkDescriptions",
"converts",
"activeNets",
"to",
"netDescribers"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/network.go#L32-L38 | train |
rkt/rkt | stage1/init/kvm/network.go | GetKVMNetArgs | func GetKVMNetArgs(nds []NetDescriber) ([]string, error) {
var lkvmArgs []string
for _, nd := range nds {
lkvmArgs = append(lkvmArgs, "--network")
lkvmArg := fmt.Sprintf("mode=tap,tapif=%s,host_ip=%s,guest_ip=%s", nd.IfName(), nd.Gateway(), nd.GuestIP())
lkvmArgs = append(lkvmArgs, lkvmArg)
}
return lkvmAr... | go | func GetKVMNetArgs(nds []NetDescriber) ([]string, error) {
var lkvmArgs []string
for _, nd := range nds {
lkvmArgs = append(lkvmArgs, "--network")
lkvmArg := fmt.Sprintf("mode=tap,tapif=%s,host_ip=%s,guest_ip=%s", nd.IfName(), nd.Gateway(), nd.GuestIP())
lkvmArgs = append(lkvmArgs, lkvmArg)
}
return lkvmAr... | [
"func",
"GetKVMNetArgs",
"(",
"nds",
"[",
"]",
"NetDescriber",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"lkvmArgs",
"[",
"]",
"string",
"\n\n",
"for",
"_",
",",
"nd",
":=",
"range",
"nds",
"{",
"lkvmArgs",
"=",
"append",
"(",
"l... | // GetKVMNetArgs returns additional arguments that need to be passed
// to lkvm tool to configure networks properly.
// Logic is based on Network configuration extracted from Networking struct
// and essentially from activeNets that expose netDescriber behavior | [
"GetKVMNetArgs",
"returns",
"additional",
"arguments",
"that",
"need",
"to",
"be",
"passed",
"to",
"lkvm",
"tool",
"to",
"configure",
"networks",
"properly",
".",
"Logic",
"is",
"based",
"on",
"Network",
"configuration",
"extracted",
"from",
"Networking",
"struct"... | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/network.go#L55-L66 | train |
rkt/rkt | stage1/init/kvm/network.go | generateMacAddress | func generateMacAddress() (net.HardwareAddr, error) {
mac := []byte{
2, // locally administered unicast
0x65, 0x02, // OUI (randomly chosen by jell)
0, 0, 0, // bytes to randomly overwrite
}
_, err := rand.Read(mac[3:6])
if err != nil {
return nil, errwrap.Wrap(errors.New("cannot generate random m... | go | func generateMacAddress() (net.HardwareAddr, error) {
mac := []byte{
2, // locally administered unicast
0x65, 0x02, // OUI (randomly chosen by jell)
0, 0, 0, // bytes to randomly overwrite
}
_, err := rand.Read(mac[3:6])
if err != nil {
return nil, errwrap.Wrap(errors.New("cannot generate random m... | [
"func",
"generateMacAddress",
"(",
")",
"(",
"net",
".",
"HardwareAddr",
",",
"error",
")",
"{",
"mac",
":=",
"[",
"]",
"byte",
"{",
"2",
",",
"// locally administered unicast",
"0x65",
",",
"0x02",
",",
"// OUI (randomly chosen by jell)",
"0",
",",
"0",
","... | // generateMacAddress returns net.HardwareAddr filled with fixed 3 byte prefix
// complemented by 3 random bytes. | [
"generateMacAddress",
"returns",
"net",
".",
"HardwareAddr",
"filled",
"with",
"fixed",
"3",
"byte",
"prefix",
"complemented",
"by",
"3",
"random",
"bytes",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/network.go#L70-L83 | train |
rkt/rkt | tools/depsgen/util.go | replacePlaceholders | func replacePlaceholders(str string, kv ...string) string {
for ph, value := range toMap(kv...) {
str = strings.Replace(str, "!!!"+ph+"!!!", value, -1)
}
return str
} | go | func replacePlaceholders(str string, kv ...string) string {
for ph, value := range toMap(kv...) {
str = strings.Replace(str, "!!!"+ph+"!!!", value, -1)
}
return str
} | [
"func",
"replacePlaceholders",
"(",
"str",
"string",
",",
"kv",
"...",
"string",
")",
"string",
"{",
"for",
"ph",
",",
"value",
":=",
"range",
"toMap",
"(",
"kv",
"...",
")",
"{",
"str",
"=",
"strings",
".",
"Replace",
"(",
"str",
",",
"\"",
"\"",
... | // replacePlaceholders replaces placeholders with values in kv in
// initial str. Placeholders are in form of !!!FOO!!!, but those
// passed here should be without exclamation marks. | [
"replacePlaceholders",
"replaces",
"placeholders",
"with",
"values",
"in",
"kv",
"in",
"initial",
"str",
".",
"Placeholders",
"are",
"in",
"form",
"of",
"!!!FOO!!!",
"but",
"those",
"passed",
"here",
"should",
"be",
"without",
"exclamation",
"marks",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/tools/depsgen/util.go#L54-L59 | train |
rkt/rkt | tools/depsgen/util.go | standardFlags | func standardFlags(cmd string) (*flag.FlagSet, *string) {
f := flag.NewFlagSet(appName()+" "+cmd, flag.ExitOnError)
target := f.String("target", "", "Make target (example: $(FOO_BINARY))")
return f, target
} | go | func standardFlags(cmd string) (*flag.FlagSet, *string) {
f := flag.NewFlagSet(appName()+" "+cmd, flag.ExitOnError)
target := f.String("target", "", "Make target (example: $(FOO_BINARY))")
return f, target
} | [
"func",
"standardFlags",
"(",
"cmd",
"string",
")",
"(",
"*",
"flag",
".",
"FlagSet",
",",
"*",
"string",
")",
"{",
"f",
":=",
"flag",
".",
"NewFlagSet",
"(",
"appName",
"(",
")",
"+",
"\"",
"\"",
"+",
"cmd",
",",
"flag",
".",
"ExitOnError",
")",
... | // standardFlags returns a new flag set with target flag already set up | [
"standardFlags",
"returns",
"a",
"new",
"flag",
"set",
"with",
"target",
"flag",
"already",
"set",
"up"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/tools/depsgen/util.go#L62-L66 | train |
rkt/rkt | networking/net_plugin.go | netPluginAdd | func (e *podEnv) netPluginAdd(n *activeNet, netns string) error {
output, err := e.execNetPlugin("ADD", n, netns)
if err != nil {
return pluginErr(err, output)
}
pr := cnitypes.Result{}
if err = json.Unmarshal(output, &pr); err != nil {
err = errwrap.Wrap(fmt.Errorf("parsing %q", string(output)), err)
retur... | go | func (e *podEnv) netPluginAdd(n *activeNet, netns string) error {
output, err := e.execNetPlugin("ADD", n, netns)
if err != nil {
return pluginErr(err, output)
}
pr := cnitypes.Result{}
if err = json.Unmarshal(output, &pr); err != nil {
err = errwrap.Wrap(fmt.Errorf("parsing %q", string(output)), err)
retur... | [
"func",
"(",
"e",
"*",
"podEnv",
")",
"netPluginAdd",
"(",
"n",
"*",
"activeNet",
",",
"netns",
"string",
")",
"error",
"{",
"output",
",",
"err",
":=",
"e",
".",
"execNetPlugin",
"(",
"\"",
"\"",
",",
"n",
",",
"netns",
")",
"\n",
"if",
"err",
"... | // Executes a given network plugin. If successful, mutates n.runtime with
// the runtime information | [
"Executes",
"a",
"given",
"network",
"plugin",
".",
"If",
"successful",
"mutates",
"n",
".",
"runtime",
"with",
"the",
"runtime",
"information"
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/net_plugin.go#L54-L73 | train |
rkt/rkt | rkt/api_service.go | copyPod | func copyPod(pod *v1alpha.Pod) *v1alpha.Pod {
p := &v1alpha.Pod{
Id: pod.Id,
Manifest: pod.Manifest,
Annotations: pod.Annotations,
}
for _, app := range pod.Apps {
p.Apps = append(p.Apps, &v1alpha.App{
Name: app.Name,
Image: app.Image,
Annotations: app.Annotations,
})
}
... | go | func copyPod(pod *v1alpha.Pod) *v1alpha.Pod {
p := &v1alpha.Pod{
Id: pod.Id,
Manifest: pod.Manifest,
Annotations: pod.Annotations,
}
for _, app := range pod.Apps {
p.Apps = append(p.Apps, &v1alpha.App{
Name: app.Name,
Image: app.Image,
Annotations: app.Annotations,
})
}
... | [
"func",
"copyPod",
"(",
"pod",
"*",
"v1alpha",
".",
"Pod",
")",
"*",
"v1alpha",
".",
"Pod",
"{",
"p",
":=",
"&",
"v1alpha",
".",
"Pod",
"{",
"Id",
":",
"pod",
".",
"Id",
",",
"Manifest",
":",
"pod",
".",
"Manifest",
",",
"Annotations",
":",
"pod"... | // copyPod copies the immutable information of the pod into the new pod. | [
"copyPod",
"copies",
"the",
"immutable",
"information",
"of",
"the",
"pod",
"into",
"the",
"new",
"pod",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L89-L104 | train |
rkt/rkt | rkt/api_service.go | copyImage | func copyImage(img *v1alpha.Image) *v1alpha.Image {
return &v1alpha.Image{
BaseFormat: img.BaseFormat,
Id: img.Id,
Name: img.Name,
Version: img.Version,
ImportTimestamp: img.ImportTimestamp,
Manifest: img.Manifest,
Size: img.Size,
Annotations: ... | go | func copyImage(img *v1alpha.Image) *v1alpha.Image {
return &v1alpha.Image{
BaseFormat: img.BaseFormat,
Id: img.Id,
Name: img.Name,
Version: img.Version,
ImportTimestamp: img.ImportTimestamp,
Manifest: img.Manifest,
Size: img.Size,
Annotations: ... | [
"func",
"copyImage",
"(",
"img",
"*",
"v1alpha",
".",
"Image",
")",
"*",
"v1alpha",
".",
"Image",
"{",
"return",
"&",
"v1alpha",
".",
"Image",
"{",
"BaseFormat",
":",
"img",
".",
"BaseFormat",
",",
"Id",
":",
"img",
".",
"Id",
",",
"Name",
":",
"im... | // copyImage copies the image object to avoid modification on the original one. | [
"copyImage",
"copies",
"the",
"image",
"object",
"to",
"avoid",
"modification",
"on",
"the",
"original",
"one",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L107-L119 | train |
rkt/rkt | rkt/api_service.go | GetInfo | func (s *v1AlphaAPIServer) GetInfo(context.Context, *v1alpha.GetInfoRequest) (*v1alpha.GetInfoResponse, error) {
return &v1alpha.GetInfoResponse{
Info: &v1alpha.Info{
RktVersion: version.Version,
AppcVersion: schema.AppContainerVersion.String(),
ApiVersion: supportedAPIVersion,
GlobalFlags: &v1alpha.Gl... | go | func (s *v1AlphaAPIServer) GetInfo(context.Context, *v1alpha.GetInfoRequest) (*v1alpha.GetInfoResponse, error) {
return &v1alpha.GetInfoResponse{
Info: &v1alpha.Info{
RktVersion: version.Version,
AppcVersion: schema.AppContainerVersion.String(),
ApiVersion: supportedAPIVersion,
GlobalFlags: &v1alpha.Gl... | [
"func",
"(",
"s",
"*",
"v1AlphaAPIServer",
")",
"GetInfo",
"(",
"context",
".",
"Context",
",",
"*",
"v1alpha",
".",
"GetInfoRequest",
")",
"(",
"*",
"v1alpha",
".",
"GetInfoResponse",
",",
"error",
")",
"{",
"return",
"&",
"v1alpha",
".",
"GetInfoResponse... | // GetInfo returns the information about the rkt, appc, api server version. | [
"GetInfo",
"returns",
"the",
"information",
"about",
"the",
"rkt",
"appc",
"api",
"server",
"version",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L154-L170 | train |
rkt/rkt | rkt/api_service.go | containsAllKeyValues | func containsAllKeyValues(actualKVs []*v1alpha.KeyValue, requiredKVs []*v1alpha.KeyValue) bool {
for _, requiredKV := range requiredKVs {
actualValue, ok := findInKeyValues(actualKVs, requiredKV.Key)
if !ok || actualValue != requiredKV.Value {
return false
}
}
return true
} | go | func containsAllKeyValues(actualKVs []*v1alpha.KeyValue, requiredKVs []*v1alpha.KeyValue) bool {
for _, requiredKV := range requiredKVs {
actualValue, ok := findInKeyValues(actualKVs, requiredKV.Key)
if !ok || actualValue != requiredKV.Value {
return false
}
}
return true
} | [
"func",
"containsAllKeyValues",
"(",
"actualKVs",
"[",
"]",
"*",
"v1alpha",
".",
"KeyValue",
",",
"requiredKVs",
"[",
"]",
"*",
"v1alpha",
".",
"KeyValue",
")",
"bool",
"{",
"for",
"_",
",",
"requiredKV",
":=",
"range",
"requiredKVs",
"{",
"actualValue",
"... | // containsAllKeyValues returns true if the actualKVs contains all of the key-value
// pairs listed in requiredKVs, otherwise it returns false. | [
"containsAllKeyValues",
"returns",
"true",
"if",
"the",
"actualKVs",
"contains",
"all",
"of",
"the",
"key",
"-",
"value",
"pairs",
"listed",
"in",
"requiredKVs",
"otherwise",
"it",
"returns",
"false",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L183-L191 | train |
rkt/rkt | rkt/api_service.go | satisfiesPodFilter | func satisfiesPodFilter(pod v1alpha.Pod, filter v1alpha.PodFilter) bool {
// Filter according to the ID.
if len(filter.Ids) > 0 {
s := set.NewString(filter.Ids...)
if !s.Has(pod.Id) {
return false
}
}
// Filter according to the state.
if len(filter.States) > 0 {
foundState := false
for _, state := ra... | go | func satisfiesPodFilter(pod v1alpha.Pod, filter v1alpha.PodFilter) bool {
// Filter according to the ID.
if len(filter.Ids) > 0 {
s := set.NewString(filter.Ids...)
if !s.Has(pod.Id) {
return false
}
}
// Filter according to the state.
if len(filter.States) > 0 {
foundState := false
for _, state := ra... | [
"func",
"satisfiesPodFilter",
"(",
"pod",
"v1alpha",
".",
"Pod",
",",
"filter",
"v1alpha",
".",
"PodFilter",
")",
"bool",
"{",
"// Filter according to the ID.",
"if",
"len",
"(",
"filter",
".",
"Ids",
")",
">",
"0",
"{",
"s",
":=",
"set",
".",
"NewString",... | // satisfiesPodFilter returns true if the pod satisfies the filter.
// The pod, filter must not be nil. | [
"satisfiesPodFilter",
"returns",
"true",
"if",
"the",
"pod",
"satisfies",
"the",
"filter",
".",
"The",
"pod",
"filter",
"must",
"not",
"be",
"nil",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L210-L299 | train |
rkt/rkt | rkt/api_service.go | satisfiesAnyPodFilters | func satisfiesAnyPodFilters(pod *v1alpha.Pod, filters []*v1alpha.PodFilter) bool {
// No filters, return true directly.
if len(filters) == 0 {
return true
}
for _, filter := range filters {
if satisfiesPodFilter(*pod, *filter) {
return true
}
}
return false
} | go | func satisfiesAnyPodFilters(pod *v1alpha.Pod, filters []*v1alpha.PodFilter) bool {
// No filters, return true directly.
if len(filters) == 0 {
return true
}
for _, filter := range filters {
if satisfiesPodFilter(*pod, *filter) {
return true
}
}
return false
} | [
"func",
"satisfiesAnyPodFilters",
"(",
"pod",
"*",
"v1alpha",
".",
"Pod",
",",
"filters",
"[",
"]",
"*",
"v1alpha",
".",
"PodFilter",
")",
"bool",
"{",
"// No filters, return true directly.",
"if",
"len",
"(",
"filters",
")",
"==",
"0",
"{",
"return",
"true"... | // satisfiesAnyPodFilters returns true if any of the filter conditions is satisfied
// by the pod, or there's no filters. | [
"satisfiesAnyPodFilters",
"returns",
"true",
"if",
"any",
"of",
"the",
"filter",
"conditions",
"is",
"satisfied",
"by",
"the",
"pod",
"or",
"there",
"s",
"no",
"filters",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L303-L315 | train |
rkt/rkt | rkt/api_service.go | getApplist | func getApplist(manifest *schema.PodManifest) []*v1alpha.App {
var apps []*v1alpha.App
for _, app := range manifest.Apps {
img := &v1alpha.Image{
BaseFormat: &v1alpha.ImageFormat{
// Only support appc image now. If it's a docker image, then it
// will be transformed to appc before storing in the disk sto... | go | func getApplist(manifest *schema.PodManifest) []*v1alpha.App {
var apps []*v1alpha.App
for _, app := range manifest.Apps {
img := &v1alpha.Image{
BaseFormat: &v1alpha.ImageFormat{
// Only support appc image now. If it's a docker image, then it
// will be transformed to appc before storing in the disk sto... | [
"func",
"getApplist",
"(",
"manifest",
"*",
"schema",
".",
"PodManifest",
")",
"[",
"]",
"*",
"v1alpha",
".",
"App",
"{",
"var",
"apps",
"[",
"]",
"*",
"v1alpha",
".",
"App",
"\n",
"for",
"_",
",",
"app",
":=",
"range",
"manifest",
".",
"Apps",
"{"... | // getApplist returns a list of apps in the pod. | [
"getApplist",
"returns",
"a",
"list",
"of",
"apps",
"in",
"the",
"pod",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L370-L393 | train |
rkt/rkt | rkt/api_service.go | getNetworks | func getNetworks(p *pkgPod.Pod) []*v1alpha.Network {
var networks []*v1alpha.Network
for _, n := range p.Nets {
networks = append(networks, &v1alpha.Network{
Name: n.NetName,
// There will be IPv6 support soon so distinguish between v4 and v6
Ipv4: n.IP.String(),
})
}
return networks
} | go | func getNetworks(p *pkgPod.Pod) []*v1alpha.Network {
var networks []*v1alpha.Network
for _, n := range p.Nets {
networks = append(networks, &v1alpha.Network{
Name: n.NetName,
// There will be IPv6 support soon so distinguish between v4 and v6
Ipv4: n.IP.String(),
})
}
return networks
} | [
"func",
"getNetworks",
"(",
"p",
"*",
"pkgPod",
".",
"Pod",
")",
"[",
"]",
"*",
"v1alpha",
".",
"Network",
"{",
"var",
"networks",
"[",
"]",
"*",
"v1alpha",
".",
"Network",
"\n",
"for",
"_",
",",
"n",
":=",
"range",
"p",
".",
"Nets",
"{",
"networ... | // getNetworks returns the list of the info of the network that the pod belongs to. | [
"getNetworks",
"returns",
"the",
"list",
"of",
"the",
"info",
"of",
"the",
"network",
"that",
"the",
"pod",
"belongs",
"to",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L396-L406 | train |
rkt/rkt | rkt/api_service.go | fillStaticAppInfo | func fillStaticAppInfo(store *imagestore.Store, pod *pkgPod.Pod, v1pod *v1alpha.Pod) error {
var errlist []error
// Fill static app image info.
for _, app := range v1pod.Apps {
// Fill app's image info.
app.Image = &v1alpha.Image{
BaseFormat: &v1alpha.ImageFormat{
// Only support appc image now. If it's ... | go | func fillStaticAppInfo(store *imagestore.Store, pod *pkgPod.Pod, v1pod *v1alpha.Pod) error {
var errlist []error
// Fill static app image info.
for _, app := range v1pod.Apps {
// Fill app's image info.
app.Image = &v1alpha.Image{
BaseFormat: &v1alpha.ImageFormat{
// Only support appc image now. If it's ... | [
"func",
"fillStaticAppInfo",
"(",
"store",
"*",
"imagestore",
".",
"Store",
",",
"pod",
"*",
"pkgPod",
".",
"Pod",
",",
"v1pod",
"*",
"v1alpha",
".",
"Pod",
")",
"error",
"{",
"var",
"errlist",
"[",
"]",
"error",
"\n\n",
"// Fill static app image info.",
"... | // fillStaticAppInfo will modify the 'v1pod' in place with the information retrieved with 'pod'.
// Today, these information are static and will not change during the pod's lifecycle. | [
"fillStaticAppInfo",
"will",
"modify",
"the",
"v1pod",
"in",
"place",
"with",
"the",
"information",
"retrieved",
"with",
"pod",
".",
"Today",
"these",
"information",
"are",
"static",
"and",
"will",
"not",
"change",
"during",
"the",
"pod",
"s",
"lifecycle",
"."... | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L419-L456 | train |
rkt/rkt | rkt/api_service.go | getBasicPod | func (s *v1AlphaAPIServer) getBasicPod(p *pkgPod.Pod) *v1alpha.Pod {
mtime, mtimeErr := getPodManifestModTime(p)
if mtimeErr != nil {
stderr.PrintE(fmt.Sprintf("failed to read the pod manifest's mtime for pod %q", p.UUID), mtimeErr)
}
// Couldn't use pod.uuid directly as it's a pointer.
itemValue, found := s.po... | go | func (s *v1AlphaAPIServer) getBasicPod(p *pkgPod.Pod) *v1alpha.Pod {
mtime, mtimeErr := getPodManifestModTime(p)
if mtimeErr != nil {
stderr.PrintE(fmt.Sprintf("failed to read the pod manifest's mtime for pod %q", p.UUID), mtimeErr)
}
// Couldn't use pod.uuid directly as it's a pointer.
itemValue, found := s.po... | [
"func",
"(",
"s",
"*",
"v1AlphaAPIServer",
")",
"getBasicPod",
"(",
"p",
"*",
"pkgPod",
".",
"Pod",
")",
"*",
"v1alpha",
".",
"Pod",
"{",
"mtime",
",",
"mtimeErr",
":=",
"getPodManifestModTime",
"(",
"p",
")",
"\n",
"if",
"mtimeErr",
"!=",
"nil",
"{",
... | // getBasicPod returns v1alpha.Pod with basic pod information. | [
"getBasicPod",
"returns",
"v1alpha",
".",
"Pod",
"with",
"basic",
"pod",
"information",
"."
] | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L484-L513 | train |
Dataset is imported from CodeXGLUE and pre-processed using their script.
Where to find in Semeru:
The dataset can be found at /nfs/semeru/semeru_datasets/code_xglue/code-to-text/go in Semeru
CodeXGLUE -- Code-To-Text
Task Definition
The task is to generate natural language comments for a code, and evaluted by smoothed bleu-4 score.
Dataset
The dataset we use comes from CodeSearchNet and we filter the dataset as the following:
- Remove examples that codes cannot be parsed into an abstract syntax tree.
- Remove examples that #tokens of documents is < 3 or >256
- Remove examples that documents contain special tokens (e.g. <img ...> or https:...)
- Remove examples that documents are not English.
Data Format
After preprocessing dataset, you can obtain three .jsonl files, i.e. train.jsonl, valid.jsonl, test.jsonl
For each file, each line in the uncompressed file represents one function. One row is illustrated below.
repo: the owner/repo
path: the full path to the original file
func_name: the function or method name
original_string: the raw string before tokenization or parsing
language: the programming language
code/function: the part of the
original_stringthat is codecode_tokens/function_tokens: tokenized version of
codedocstring: the top-level comment or docstring, if it exists in the original string
docstring_tokens: tokenized version of
docstring
Data Statistic
| Programming Language | Training | Dev | Test |
|---|---|---|---|
| Go | 167,288 | 7,325 | 8,122 |
Reference
@article{husain2019codesearchnet,
title={Codesearchnet challenge: Evaluating the state of semantic code search},
author={Husain, Hamel and Wu, Ho-Hsiang and Gazit, Tiferet and Allamanis, Miltiadis and Brockschmidt, Marc},
journal={arXiv preprint arXiv:1909.09436},
year={2019}
}
- Downloads last month
- 409