repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
rkt/rkt
pkg/log/log.go
Errorf
func (l *Logger) Errorf(format string, a ...interface{}) { l.Print(l.formatErr(fmt.Errorf(format, a...), "")) }
go
func (l *Logger) Errorf(format string, a ...interface{}) { l.Print(l.formatErr(fmt.Errorf(format, a...), "")) }
[ "func", "(", "l", "*", "Logger", ")", "Errorf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "l", ".", "Print", "(", "l", ".", "formatErr", "(", "fmt", ".", "Errorf", "(", "format", ",", "a", "...", ")", ",", "\"",...
// Errorf is a convenience function for formatting and printing errors.
[ "Errorf", "is", "a", "convenience", "function", "for", "formatting", "and", "printing", "errors", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/log/log.go#L115-L117
train
rkt/rkt
pkg/log/log.go
PanicE
func (l *Logger) PanicE(msg string, e error) { l.Panic(l.formatErr(e, msg)) }
go
func (l *Logger) PanicE(msg string, e error) { l.Panic(l.formatErr(e, msg)) }
[ "func", "(", "l", "*", "Logger", ")", "PanicE", "(", "msg", "string", ",", "e", "error", ")", "{", "l", ".", "Panic", "(", "l", ".", "formatErr", "(", "e", ",", "msg", ")", ")", "\n", "}" ]
// PanicE prints a string and error then calls panic.
[ "PanicE", "prints", "a", "string", "and", "error", "then", "calls", "panic", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/log/log.go#L132-L134
train
rkt/rkt
tools/common/util.go
Warn
func Warn(format string, values ...interface{}) { fmt.Fprintf(os.Stderr, fmt.Sprintf("%s%c", format, '\n'), values...) }
go
func Warn(format string, values ...interface{}) { fmt.Fprintf(os.Stderr, fmt.Sprintf("%s%c", format, '\n'), values...) }
[ "func", "Warn", "(", "format", "string", ",", "values", "...", "interface", "{", "}", ")", "{", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "format", ",", "'\\n'", ")", ",", "values", "...", ...
// Warn is just a shorter version of a formatted printing to // stderr. It appends a newline for you.
[ "Warn", "is", "just", "a", "shorter", "version", "of", "a", "formatted", "printing", "to", "stderr", ".", "It", "appends", "a", "newline", "for", "you", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/tools/common/util.go#L45-L47
train
rkt/rkt
tools/common/util.go
MustAbs
func MustAbs(dir string) string { absDir, err := filepath.Abs(dir) if err != nil { panic(fmt.Sprintf("Failed to get absolute path of a directory %q: %v\n", dir, err)) } return filepath.Clean(absDir) }
go
func MustAbs(dir string) string { absDir, err := filepath.Abs(dir) if err != nil { panic(fmt.Sprintf("Failed to get absolute path of a directory %q: %v\n", dir, err)) } return filepath.Clean(absDir) }
[ "func", "MustAbs", "(", "dir", "string", ")", "string", "{", "absDir", ",", "err", ":=", "filepath", ".", "Abs", "(", "dir", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "dir", ",", ...
// MustAbs returns an absolute path. It works like filepath.Abs, but // panics if it fails.
[ "MustAbs", "returns", "an", "absolute", "path", ".", "It", "works", "like", "filepath", ".", "Abs", "but", "panics", "if", "it", "fails", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/tools/common/util.go#L75-L81
train
rkt/rkt
rkt/status.go
parseDuration
func parseDuration(s string) (time.Duration, error) { if s == "" { return time.Duration(-1), nil } b, err := strconv.ParseBool(s) switch { case err != nil: return time.ParseDuration(s) case b: return time.Duration(-1), nil } return time.Duration(0), nil }
go
func parseDuration(s string) (time.Duration, error) { if s == "" { return time.Duration(-1), nil } b, err := strconv.ParseBool(s) switch { case err != nil: return time.ParseDuration(s) case b: return time.Duration(-1), nil } return time.Duration(0), nil }
[ "func", "parseDuration", "(", "s", "string", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "if", "s", "==", "\"", "\"", "{", "return", "time", ".", "Duration", "(", "-", "1", ")", ",", "nil", "\n", "}", "\n\n", "b", ",", "err", ":=...
// parseDuration converts the given string s to a duration value. // If it is empty string or a true boolean value according to strconv.ParseBool, a negative duration is returned. // If the boolean value is false, a 0 duration is returned. // If the string s is a duration value, then it is returned. // It returns an er...
[ "parseDuration", "converts", "the", "given", "string", "s", "to", "a", "duration", "value", ".", "If", "it", "is", "empty", "string", "or", "a", "true", "boolean", "value", "according", "to", "strconv", ".", "ParseBool", "a", "negative", "duration", "is", ...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/status.go#L126-L141
train
rkt/rkt
rkt/status.go
newContext
func newContext(t time.Duration) context.Context { ctx := context.Background() if t > 0 { ctx, _ = context.WithTimeout(ctx, t) } return ctx }
go
func newContext(t time.Duration) context.Context { ctx := context.Background() if t > 0 { ctx, _ = context.WithTimeout(ctx, t) } return ctx }
[ "func", "newContext", "(", "t", "time", ".", "Duration", ")", "context", ".", "Context", "{", "ctx", ":=", "context", ".", "Background", "(", ")", "\n", "if", "t", ">", "0", "{", "ctx", ",", "_", "=", "context", ".", "WithTimeout", "(", "ctx", ",",...
// newContext returns a new context with timeout t if t > 0.
[ "newContext", "returns", "a", "new", "context", "with", "timeout", "t", "if", "t", ">", "0", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/status.go#L144-L150
train
rkt/rkt
rkt/status.go
getExitStatuses
func getExitStatuses(p *pkgPod.Pod) (map[string]int, error) { _, manifest, err := p.PodManifest() if err != nil { return nil, err } stats := make(map[string]int) for _, app := range manifest.Apps { exitCode, err := p.AppExitCode(app.Name.String()) if err != nil { continue } stats[app.Name.String()] =...
go
func getExitStatuses(p *pkgPod.Pod) (map[string]int, error) { _, manifest, err := p.PodManifest() if err != nil { return nil, err } stats := make(map[string]int) for _, app := range manifest.Apps { exitCode, err := p.AppExitCode(app.Name.String()) if err != nil { continue } stats[app.Name.String()] =...
[ "func", "getExitStatuses", "(", "p", "*", "pkgPod", ".", "Pod", ")", "(", "map", "[", "string", "]", "int", ",", "error", ")", "{", "_", ",", "manifest", ",", "err", ":=", "p", ".", "PodManifest", "(", ")", "\n", "if", "err", "!=", "nil", "{", ...
// getExitStatuses returns a map of the statuses of the pod.
[ "getExitStatuses", "returns", "a", "map", "of", "the", "statuses", "of", "the", "pod", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/status.go#L153-L168
train
rkt/rkt
rkt/status.go
printStatus
func printStatus(p *pkgPod.Pod) error { if flagFormat != outputFormatTabbed { pod, err := lib.NewPodFromInternalPod(p) if err != nil { return fmt.Errorf("error converting pod: %v", err) } switch flagFormat { case outputFormatJSON: result, err := json.Marshal(pod) if err != nil { return fmt.Error...
go
func printStatus(p *pkgPod.Pod) error { if flagFormat != outputFormatTabbed { pod, err := lib.NewPodFromInternalPod(p) if err != nil { return fmt.Errorf("error converting pod: %v", err) } switch flagFormat { case outputFormatJSON: result, err := json.Marshal(pod) if err != nil { return fmt.Error...
[ "func", "printStatus", "(", "p", "*", "pkgPod", ".", "Pod", ")", "error", "{", "if", "flagFormat", "!=", "outputFormatTabbed", "{", "pod", ",", "err", ":=", "lib", ".", "NewPodFromInternalPod", "(", "p", ")", "\n", "if", "err", "!=", "nil", "{", "retur...
// printStatus prints the pod's pid and per-app status codes
[ "printStatus", "prints", "the", "pod", "s", "pid", "and", "per", "-", "app", "status", "codes" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/status.go#L171-L240
train
rkt/rkt
rkt/image/common.go
ascURLFromImgURL
func ascURLFromImgURL(u *url.URL) *url.URL { copy := *u copy.Path = ascPathFromImgPath(copy.Path) return &copy }
go
func ascURLFromImgURL(u *url.URL) *url.URL { copy := *u copy.Path = ascPathFromImgPath(copy.Path) return &copy }
[ "func", "ascURLFromImgURL", "(", "u", "*", "url", ".", "URL", ")", "*", "url", ".", "URL", "{", "copy", ":=", "*", "u", "\n", "copy", ".", "Path", "=", "ascPathFromImgPath", "(", "copy", ".", "Path", ")", "\n", "return", "&", "copy", "\n", "}" ]
// ascURLFromImgURL creates a URL to a signature file from passed URL // to an image.
[ "ascURLFromImgURL", "creates", "a", "URL", "to", "a", "signature", "file", "from", "passed", "URL", "to", "an", "image", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/common.go#L113-L117
train
rkt/rkt
rkt/image/common.go
printIdentities
func printIdentities(entity *openpgp.Entity) { lines := []string{"signature verified:"} for _, v := range entity.Identities { lines = append(lines, fmt.Sprintf(" %s", v.Name)) } log.Print(strings.Join(lines, "\n")) }
go
func printIdentities(entity *openpgp.Entity) { lines := []string{"signature verified:"} for _, v := range entity.Identities { lines = append(lines, fmt.Sprintf(" %s", v.Name)) } log.Print(strings.Join(lines, "\n")) }
[ "func", "printIdentities", "(", "entity", "*", "openpgp", ".", "Entity", ")", "{", "lines", ":=", "[", "]", "string", "{", "\"", "\"", "}", "\n", "for", "_", ",", "v", ":=", "range", "entity", ".", "Identities", "{", "lines", "=", "append", "(", "l...
// printIdentities prints a message that signature was verified.
[ "printIdentities", "prints", "a", "message", "that", "signature", "was", "verified", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/common.go#L126-L132
train
rkt/rkt
rkt/image/common.go
DistFromImageString
func DistFromImageString(is string) (dist.Distribution, error) { u, err := url.Parse(is) if err != nil { return nil, errwrap.Wrap(fmt.Errorf("failed to parse image url %q", is), err) } // Convert user friendly image string names to internal distribution URIs // file:///full/path/to/aci/file.aci -> archive:aci:f...
go
func DistFromImageString(is string) (dist.Distribution, error) { u, err := url.Parse(is) if err != nil { return nil, errwrap.Wrap(fmt.Errorf("failed to parse image url %q", is), err) } // Convert user friendly image string names to internal distribution URIs // file:///full/path/to/aci/file.aci -> archive:aci:f...
[ "func", "DistFromImageString", "(", "is", "string", ")", "(", "dist", ".", "Distribution", ",", "error", ")", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "is", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errwrap", "."...
// DistFromImageString return the distribution for the given input image string
[ "DistFromImageString", "return", "the", "distribution", "for", "the", "given", "input", "image", "string" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/common.go#L135-L203
train
rkt/rkt
pkg/distribution/cimd.go
parseCIMD
func parseCIMD(u *url.URL) (*cimd, error) { if u.Scheme != Scheme { return nil, fmt.Errorf("unsupported scheme: %q", u.Scheme) } parts := strings.SplitN(u.Opaque, ":", 3) if len(parts) < 3 { return nil, fmt.Errorf("malformed distribution uri: %q", u.String()) } version, err := strconv.ParseUint(strings.TrimPr...
go
func parseCIMD(u *url.URL) (*cimd, error) { if u.Scheme != Scheme { return nil, fmt.Errorf("unsupported scheme: %q", u.Scheme) } parts := strings.SplitN(u.Opaque, ":", 3) if len(parts) < 3 { return nil, fmt.Errorf("malformed distribution uri: %q", u.String()) } version, err := strconv.ParseUint(strings.TrimPr...
[ "func", "parseCIMD", "(", "u", "*", "url", ".", "URL", ")", "(", "*", "cimd", ",", "error", ")", "{", "if", "u", ".", "Scheme", "!=", "Scheme", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "u", ".", "Scheme", ")", "\...
// parseCIMD parses the given url and returns a cimd.
[ "parseCIMD", "parses", "the", "given", "url", "and", "returns", "a", "cimd", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/distribution/cimd.go#L34-L51
train
rkt/rkt
pkg/distribution/cimd.go
NewCIMDString
func NewCIMDString(typ Type, version uint32, data string) string { return fmt.Sprintf("%s:%s:v=%d:%s", Scheme, typ, version, data) }
go
func NewCIMDString(typ Type, version uint32, data string) string { return fmt.Sprintf("%s:%s:v=%d:%s", Scheme, typ, version, data) }
[ "func", "NewCIMDString", "(", "typ", "Type", ",", "version", "uint32", ",", "data", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "Scheme", ",", "typ", ",", "version", ",", "data", ")", "\n", "}" ]
// NewCIMDString creates a new cimd URL string.
[ "NewCIMDString", "creates", "a", "new", "cimd", "URL", "string", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/distribution/cimd.go#L54-L56
train
rkt/rkt
rkt/export.go
getApp
func getApp(p *pkgPod.Pod) (*schema.RuntimeApp, error) { _, manifest, err := p.PodManifest() if err != nil { return nil, errwrap.Wrap(errors.New("problem getting the pod's manifest"), err) } apps := manifest.Apps if flagExportAppName != "" { exportAppName, err := types.NewACName(flagExportAppName) if err !...
go
func getApp(p *pkgPod.Pod) (*schema.RuntimeApp, error) { _, manifest, err := p.PodManifest() if err != nil { return nil, errwrap.Wrap(errors.New("problem getting the pod's manifest"), err) } apps := manifest.Apps if flagExportAppName != "" { exportAppName, err := types.NewACName(flagExportAppName) if err !...
[ "func", "getApp", "(", "p", "*", "pkgPod", ".", "Pod", ")", "(", "*", "schema", ".", "RuntimeApp", ",", "error", ")", "{", "_", ",", "manifest", ",", "err", ":=", "p", ".", "PodManifest", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// getApp returns the app to export // If one was supplied in the flags then it's returned if present // If the PM contains a single app, that app is returned // If the PM has multiple apps, the names are printed and an error is returned
[ "getApp", "returns", "the", "app", "to", "export", "If", "one", "was", "supplied", "in", "the", "flags", "then", "it", "s", "returned", "if", "present", "If", "the", "PM", "contains", "a", "single", "app", "that", "app", "is", "returned", "If", "the", ...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/export.go#L164-L199
train
rkt/rkt
rkt/export.go
mountOverlay
func mountOverlay(pod *pkgPod.Pod, app *schema.RuntimeApp, dest string) error { if _, err := os.Stat(dest); err != nil { return err } s, err := imagestore.NewStore(getDataDir()) if err != nil { return errwrap.Wrap(errors.New("cannot open store"), err) } ts, err := treestore.NewStore(treeStoreDir(), s) if e...
go
func mountOverlay(pod *pkgPod.Pod, app *schema.RuntimeApp, dest string) error { if _, err := os.Stat(dest); err != nil { return err } s, err := imagestore.NewStore(getDataDir()) if err != nil { return errwrap.Wrap(errors.New("cannot open store"), err) } ts, err := treestore.NewStore(treeStoreDir(), s) if e...
[ "func", "mountOverlay", "(", "pod", "*", "pkgPod", ".", "Pod", ",", "app", "*", "schema", ".", "RuntimeApp", ",", "dest", "string", ")", "error", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "dest", ")", ";", "err", "!=", "nil", "{",...
// mountOverlay mounts the app from the overlay-rendered pod to the destination directory.
[ "mountOverlay", "mounts", "the", "app", "from", "the", "overlay", "-", "rendered", "pod", "to", "the", "destination", "directory", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/export.go#L202-L240
train
rkt/rkt
rkt/export.go
buildAci
func buildAci(root, manifestPath, target string, uidRange *user.UidRange) (e error) { mode := os.O_CREATE | os.O_WRONLY if flagOverwriteACI { mode |= os.O_TRUNC } else { mode |= os.O_EXCL } aciFile, err := os.OpenFile(target, mode, 0644) if err != nil { if os.IsExist(err) { return errors.New("target file...
go
func buildAci(root, manifestPath, target string, uidRange *user.UidRange) (e error) { mode := os.O_CREATE | os.O_WRONLY if flagOverwriteACI { mode |= os.O_TRUNC } else { mode |= os.O_EXCL } aciFile, err := os.OpenFile(target, mode, 0644) if err != nil { if os.IsExist(err) { return errors.New("target file...
[ "func", "buildAci", "(", "root", ",", "manifestPath", ",", "target", "string", ",", "uidRange", "*", "user", ".", "UidRange", ")", "(", "e", "error", ")", "{", "mode", ":=", "os", ".", "O_CREATE", "|", "os", ".", "O_WRONLY", "\n", "if", "flagOverwriteA...
// buildAci builds a target aci from the root directory using any uid shift // information from uidRange.
[ "buildAci", "builds", "a", "target", "aci", "from", "the", "root", "directory", "using", "any", "uid", "shift", "information", "from", "uidRange", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/export.go#L244-L306
train
rkt/rkt
rkt/rkt.go
ensureSuperuser
func ensureSuperuser(cf func(cmd *cobra.Command, args []string)) func(cmd *cobra.Command, args []string) { return func(cmd *cobra.Command, args []string) { if os.Geteuid() != 0 { stderr.Print("cannot run as unprivileged user") cmdExitCode = 254 return } cf(cmd, args) } }
go
func ensureSuperuser(cf func(cmd *cobra.Command, args []string)) func(cmd *cobra.Command, args []string) { return func(cmd *cobra.Command, args []string) { if os.Geteuid() != 0 { stderr.Print("cannot run as unprivileged user") cmdExitCode = 254 return } cf(cmd, args) } }
[ "func", "ensureSuperuser", "(", "cf", "func", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", ")", "func", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "{", "return", "func", "(", ...
// ensureSuperuser will error out if the effective UID of the current process // is not zero. Otherwise, it will invoke the supplied cobra command.
[ "ensureSuperuser", "will", "error", "out", "if", "the", "effective", "UID", "of", "the", "current", "process", "is", "not", "zero", ".", "Otherwise", "it", "will", "invoke", "the", "supplied", "cobra", "command", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/rkt.go#L192-L202
train
rkt/rkt
stage1/init/common/seccomp.go
generateSeccompFilter
func generateSeccompFilter(p *stage1commontypes.Pod, pa *preparedApp) (*seccompFilter, error) { sf := seccompFilter{} seenIsolators := 0 for _, i := range pa.app.App.Isolators { var flag string var err error if seccomp, ok := i.Value().(types.LinuxSeccompSet); ok { seenIsolators++ // By appc spec, only o...
go
func generateSeccompFilter(p *stage1commontypes.Pod, pa *preparedApp) (*seccompFilter, error) { sf := seccompFilter{} seenIsolators := 0 for _, i := range pa.app.App.Isolators { var flag string var err error if seccomp, ok := i.Value().(types.LinuxSeccompSet); ok { seenIsolators++ // By appc spec, only o...
[ "func", "generateSeccompFilter", "(", "p", "*", "stage1commontypes", ".", "Pod", ",", "pa", "*", "preparedApp", ")", "(", "*", "seccompFilter", ",", "error", ")", "{", "sf", ":=", "seccompFilter", "{", "}", "\n", "seenIsolators", ":=", "0", "\n", "for", ...
// generateSeccompFilter computes the concrete seccomp filter from the isolators
[ "generateSeccompFilter", "computes", "the", "concrete", "seccomp", "filter", "from", "the", "isolators" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/common/seccomp.go#L58-L107
train
rkt/rkt
stage1/init/common/seccomp.go
seccompUnitOptions
func seccompUnitOptions(opts []*unit.UnitOption, sf *seccompFilter) ([]*unit.UnitOption, error) { if sf == nil { return opts, nil } if sf.errno != "" { opts = append(opts, unit.NewUnitOption("Service", "SystemCallErrorNumber", sf.errno)) } var filterPrefix string switch sf.mode { case ModeWhitelist: filte...
go
func seccompUnitOptions(opts []*unit.UnitOption, sf *seccompFilter) ([]*unit.UnitOption, error) { if sf == nil { return opts, nil } if sf.errno != "" { opts = append(opts, unit.NewUnitOption("Service", "SystemCallErrorNumber", sf.errno)) } var filterPrefix string switch sf.mode { case ModeWhitelist: filte...
[ "func", "seccompUnitOptions", "(", "opts", "[", "]", "*", "unit", ".", "UnitOption", ",", "sf", "*", "seccompFilter", ")", "(", "[", "]", "*", "unit", ".", "UnitOption", ",", "error", ")", "{", "if", "sf", "==", "nil", "{", "return", "opts", ",", "...
// seccompUnitOptions converts a concrete seccomp filter to systemd unit options
[ "seccompUnitOptions", "converts", "a", "concrete", "seccomp", "filter", "to", "systemd", "unit", "options" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/common/seccomp.go#L110-L132
train
rkt/rkt
stage1/init/common/seccomp.go
parseLinuxSeccompSet
func parseLinuxSeccompSet(p *stage1commontypes.Pod, s types.LinuxSeccompSet) (syscallFilter []string, flag string, err error) { for _, item := range s.Set() { if item[0] == '@' { // Wildcards wildcard := strings.SplitN(string(item), "/", 2) if len(wildcard) != 2 { continue } scope := wildcard[0] ...
go
func parseLinuxSeccompSet(p *stage1commontypes.Pod, s types.LinuxSeccompSet) (syscallFilter []string, flag string, err error) { for _, item := range s.Set() { if item[0] == '@' { // Wildcards wildcard := strings.SplitN(string(item), "/", 2) if len(wildcard) != 2 { continue } scope := wildcard[0] ...
[ "func", "parseLinuxSeccompSet", "(", "p", "*", "stage1commontypes", ".", "Pod", ",", "s", "types", ".", "LinuxSeccompSet", ")", "(", "syscallFilter", "[", "]", "string", ",", "flag", "string", ",", "err", "error", ")", "{", "for", "_", ",", "item", ":=",...
// parseLinuxSeccompSet gets an appc LinuxSeccompSet and returns an array // of values suitable for systemd SystemCallFilter.
[ "parseLinuxSeccompSet", "gets", "an", "appc", "LinuxSeccompSet", "and", "returns", "an", "array", "of", "values", "suitable", "for", "systemd", "SystemCallFilter", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/common/seccomp.go#L136-L202
train
rkt/rkt
stage1/app_rm/app_rm.go
main
func main() { flag.Parse() stage1initcommon.InitDebug(debug) log, diag, _ = rktlog.NewLogSet("app-rm", debug) if !debug { diag.SetOutput(ioutil.Discard) } appName, err := types.NewACName(flagApp) if err != nil { log.FatalE("invalid app name", err) } enterCmd := stage1common.PrepareEnterCmd(false) swit...
go
func main() { flag.Parse() stage1initcommon.InitDebug(debug) log, diag, _ = rktlog.NewLogSet("app-rm", debug) if !debug { diag.SetOutput(ioutil.Discard) } appName, err := types.NewACName(flagApp) if err != nil { log.FatalE("invalid app name", err) } enterCmd := stage1common.PrepareEnterCmd(false) swit...
[ "func", "main", "(", ")", "{", "flag", ".", "Parse", "(", ")", "\n\n", "stage1initcommon", ".", "InitDebug", "(", "debug", ")", "\n\n", "log", ",", "diag", ",", "_", "=", "rktlog", ".", "NewLogSet", "(", "\"", "\"", ",", "debug", ")", "\n", "if", ...
// This is a multi-step entrypoint. It starts in stage0 context then invokes // itself again in stage1 context to perform further cleanup at pod level.
[ "This", "is", "a", "multi", "-", "step", "entrypoint", ".", "It", "starts", "in", "stage0", "context", "then", "invokes", "itself", "again", "in", "stage1", "context", "to", "perform", "further", "cleanup", "at", "pod", "level", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/app_rm/app_rm.go#L56-L88
train
rkt/rkt
stage1/app_rm/app_rm.go
cleanupStage1
func cleanupStage1(appName *types.ACName, enterCmd []string) error { // TODO(lucab): re-evaluate once/if we support systemd as non-pid1 (eg. host pid-ns inheriting) mnts, err := mountinfo.ParseMounts(1) if err != nil { return err } appRootFs := filepath.Join("/opt/stage2", appName.String(), "rootfs") mnts = mnt...
go
func cleanupStage1(appName *types.ACName, enterCmd []string) error { // TODO(lucab): re-evaluate once/if we support systemd as non-pid1 (eg. host pid-ns inheriting) mnts, err := mountinfo.ParseMounts(1) if err != nil { return err } appRootFs := filepath.Join("/opt/stage2", appName.String(), "rootfs") mnts = mnt...
[ "func", "cleanupStage1", "(", "appName", "*", "types", ".", "ACName", ",", "enterCmd", "[", "]", "string", ")", "error", "{", "// TODO(lucab): re-evaluate once/if we support systemd as non-pid1 (eg. host pid-ns inheriting)", "mnts", ",", "err", ":=", "mountinfo", ".", "...
// cleanupStage1 is meant to be executed in stage1 context. It inspects pod systemd-pid1 mountinfo to // find all remaining mountpoints for appName and proceed to clean them up.
[ "cleanupStage1", "is", "meant", "to", "be", "executed", "in", "stage1", "context", ".", "It", "inspects", "pod", "systemd", "-", "pid1", "mountinfo", "to", "find", "all", "remaining", "mountpoints", "for", "appName", "and", "proceed", "to", "clean", "them", ...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/app_rm/app_rm.go#L155-L176
train
rkt/rkt
rkt/gc.go
renameExited
func renameExited() error { if err := pkgPod.WalkPods(getDataDir(), pkgPod.IncludeRunDir, func(p *pkgPod.Pod) { if p.State() == pkgPod.Exited { stderr.Printf("moving pod %q to garbage", p.UUID) if err := p.ToExitedGarbage(); err != nil && err != os.ErrNotExist { stderr.PrintE("rename error", err) } } ...
go
func renameExited() error { if err := pkgPod.WalkPods(getDataDir(), pkgPod.IncludeRunDir, func(p *pkgPod.Pod) { if p.State() == pkgPod.Exited { stderr.Printf("moving pod %q to garbage", p.UUID) if err := p.ToExitedGarbage(); err != nil && err != os.ErrNotExist { stderr.PrintE("rename error", err) } } ...
[ "func", "renameExited", "(", ")", "error", "{", "if", "err", ":=", "pkgPod", ".", "WalkPods", "(", "getDataDir", "(", ")", ",", "pkgPod", ".", "IncludeRunDir", ",", "func", "(", "p", "*", "pkgPod", ".", "Pod", ")", "{", "if", "p", ".", "State", "("...
// renameExited renames exited pods to the exitedGarbage directory
[ "renameExited", "renames", "exited", "pods", "to", "the", "exitedGarbage", "directory" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/gc.go#L102-L115
train
rkt/rkt
rkt/gc.go
renameAborted
func renameAborted() error { if err := pkgPod.WalkPods(getDataDir(), pkgPod.IncludePrepareDir, func(p *pkgPod.Pod) { if p.State() == pkgPod.AbortedPrepare { stderr.Printf("moving failed prepare %q to garbage", p.UUID) if err := p.ToGarbage(); err != nil && err != os.ErrNotExist { stderr.PrintE("rename erro...
go
func renameAborted() error { if err := pkgPod.WalkPods(getDataDir(), pkgPod.IncludePrepareDir, func(p *pkgPod.Pod) { if p.State() == pkgPod.AbortedPrepare { stderr.Printf("moving failed prepare %q to garbage", p.UUID) if err := p.ToGarbage(); err != nil && err != os.ErrNotExist { stderr.PrintE("rename erro...
[ "func", "renameAborted", "(", ")", "error", "{", "if", "err", ":=", "pkgPod", ".", "WalkPods", "(", "getDataDir", "(", ")", ",", "pkgPod", ".", "IncludePrepareDir", ",", "func", "(", "p", "*", "pkgPod", ".", "Pod", ")", "{", "if", "p", ".", "State", ...
// renameAborted renames failed prepares to the garbage directory
[ "renameAborted", "renames", "failed", "prepares", "to", "the", "garbage", "directory" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/gc.go#L147-L159
train
rkt/rkt
rkt/gc.go
renameExpired
func renameExpired(preparedExpiration time.Duration) error { if err := pkgPod.WalkPods(getDataDir(), pkgPod.IncludePreparedDir, func(p *pkgPod.Pod) { st := &syscall.Stat_t{} pp := p.Path() if err := syscall.Lstat(pp, st); err != nil { if err != syscall.ENOENT { stderr.PrintE(fmt.Sprintf("unable to stat %q...
go
func renameExpired(preparedExpiration time.Duration) error { if err := pkgPod.WalkPods(getDataDir(), pkgPod.IncludePreparedDir, func(p *pkgPod.Pod) { st := &syscall.Stat_t{} pp := p.Path() if err := syscall.Lstat(pp, st); err != nil { if err != syscall.ENOENT { stderr.PrintE(fmt.Sprintf("unable to stat %q...
[ "func", "renameExpired", "(", "preparedExpiration", "time", ".", "Duration", ")", "error", "{", "if", "err", ":=", "pkgPod", ".", "WalkPods", "(", "getDataDir", "(", ")", ",", "pkgPod", ".", "IncludePreparedDir", ",", "func", "(", "p", "*", "pkgPod", ".", ...
// renameExpired renames expired prepared pods to the garbage directory
[ "renameExpired", "renames", "expired", "prepared", "pods", "to", "the", "garbage", "directory" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/gc.go#L162-L183
train
rkt/rkt
rkt/gc.go
deletePod
func deletePod(p *pkgPod.Pod) bool { podState := p.State() if podState != pkgPod.ExitedGarbage && podState != pkgPod.Garbage && podState != pkgPod.ExitedDeleting { stderr.Errorf("non-garbage pod %q (status %q), skipped", p.UUID, p.State()) return false } if podState == pkgPod.ExitedGarbage { s, err := images...
go
func deletePod(p *pkgPod.Pod) bool { podState := p.State() if podState != pkgPod.ExitedGarbage && podState != pkgPod.Garbage && podState != pkgPod.ExitedDeleting { stderr.Errorf("non-garbage pod %q (status %q), skipped", p.UUID, p.State()) return false } if podState == pkgPod.ExitedGarbage { s, err := images...
[ "func", "deletePod", "(", "p", "*", "pkgPod", ".", "Pod", ")", "bool", "{", "podState", ":=", "p", ".", "State", "(", ")", "\n", "if", "podState", "!=", "pkgPod", ".", "ExitedGarbage", "&&", "podState", "!=", "pkgPod", ".", "Garbage", "&&", "podState",...
// deletePod cleans up files and resource associated with the pod // pod must be under exclusive lock and be in either ExitedGarbage // or Garbage state
[ "deletePod", "cleans", "up", "files", "and", "resource", "associated", "with", "the", "pod", "pod", "must", "be", "under", "exclusive", "lock", "and", "be", "in", "either", "ExitedGarbage", "or", "Garbage", "state" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/gc.go#L251-L316
train
rkt/rkt
store/imagestore/store.go
backupDB
func (s *Store) backupDB() error { if os.Geteuid() != 0 { return ErrDBUpdateNeedsRoot } backupsDir := filepath.Join(s.dir, "db-backups") return backup.CreateBackup(s.dbDir(), backupsDir, backupsNumber) }
go
func (s *Store) backupDB() error { if os.Geteuid() != 0 { return ErrDBUpdateNeedsRoot } backupsDir := filepath.Join(s.dir, "db-backups") return backup.CreateBackup(s.dbDir(), backupsDir, backupsNumber) }
[ "func", "(", "s", "*", "Store", ")", "backupDB", "(", ")", "error", "{", "if", "os", ".", "Geteuid", "(", ")", "!=", "0", "{", "return", "ErrDBUpdateNeedsRoot", "\n", "}", "\n", "backupsDir", ":=", "filepath", ".", "Join", "(", "s", ".", "dir", ","...
// backupDB backs up current database.
[ "backupDB", "backs", "up", "current", "database", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/store.go#L283-L289
train
rkt/rkt
store/imagestore/store.go
ResolveName
func (s *Store) ResolveName(name string) ([]string, bool, error) { var ( aciInfos []*ACIInfo found bool ) err := s.db.Do(func(tx *sql.Tx) error { var err error aciInfos, found, err = GetACIInfosWithName(tx, name) return err }) if err != nil { return nil, found, errwrap.Wrap(errors.New("error retriev...
go
func (s *Store) ResolveName(name string) ([]string, bool, error) { var ( aciInfos []*ACIInfo found bool ) err := s.db.Do(func(tx *sql.Tx) error { var err error aciInfos, found, err = GetACIInfosWithName(tx, name) return err }) if err != nil { return nil, found, errwrap.Wrap(errors.New("error retriev...
[ "func", "(", "s", "*", "Store", ")", "ResolveName", "(", "name", "string", ")", "(", "[", "]", "string", ",", "bool", ",", "error", ")", "{", "var", "(", "aciInfos", "[", "]", "*", "ACIInfo", "\n", "found", "bool", "\n", ")", "\n", "err", ":=", ...
// ResolveName resolves an image name to a list of full keys and using the // store for resolution.
[ "ResolveName", "resolves", "an", "image", "name", "to", "a", "list", "of", "full", "keys", "and", "using", "the", "store", "for", "resolution", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/store.go#L374-L394
train
rkt/rkt
store/imagestore/store.go
RemoveACI
func (s *Store) RemoveACI(key string) error { imageKeyLock, err := lock.ExclusiveKeyLock(s.imageLockDir, key) if err != nil { return errwrap.Wrap(errors.New("error locking image"), err) } defer imageKeyLock.Close() // Firstly remove aciinfo and remote from the db in an unique transaction. // remote needs to be...
go
func (s *Store) RemoveACI(key string) error { imageKeyLock, err := lock.ExclusiveKeyLock(s.imageLockDir, key) if err != nil { return errwrap.Wrap(errors.New("error locking image"), err) } defer imageKeyLock.Close() // Firstly remove aciinfo and remote from the db in an unique transaction. // remote needs to be...
[ "func", "(", "s", "*", "Store", ")", "RemoveACI", "(", "key", "string", ")", "error", "{", "imageKeyLock", ",", "err", ":=", "lock", ".", "ExclusiveKeyLock", "(", "s", ".", "imageLockDir", ",", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return...
// RemoveACI removes the ACI with the given key. It firstly removes the aci // infos inside the db, then it tries to remove the non transactional data. // If some error occurs removing some non transactional data a // StoreRemovalError is returned.
[ "RemoveACI", "removes", "the", "ACI", "with", "the", "given", "key", ".", "It", "firstly", "removes", "the", "aci", "infos", "inside", "the", "db", "then", "it", "tries", "to", "remove", "the", "non", "transactional", "data", ".", "If", "some", "error", ...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/store.go#L506-L551
train
rkt/rkt
store/imagestore/store.go
GetRemote
func (s *Store) GetRemote(aciURL string) (*Remote, error) { var remote *Remote err := s.db.Do(func(tx *sql.Tx) error { var err error remote, err = GetRemote(tx, aciURL) return err }) if err != nil { return nil, err } return remote, nil }
go
func (s *Store) GetRemote(aciURL string) (*Remote, error) { var remote *Remote err := s.db.Do(func(tx *sql.Tx) error { var err error remote, err = GetRemote(tx, aciURL) return err }) if err != nil { return nil, err } return remote, nil }
[ "func", "(", "s", "*", "Store", ")", "GetRemote", "(", "aciURL", "string", ")", "(", "*", "Remote", ",", "error", ")", "{", "var", "remote", "*", "Remote", "\n\n", "err", ":=", "s", ".", "db", ".", "Do", "(", "func", "(", "tx", "*", "sql", ".",...
// GetRemote tries to retrieve a remote with the given ACIURL. // If remote doesn't exist, it returns ErrRemoteNotFound error.
[ "GetRemote", "tries", "to", "retrieve", "a", "remote", "with", "the", "given", "ACIURL", ".", "If", "remote", "doesn", "t", "exist", "it", "returns", "ErrRemoteNotFound", "error", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/store.go#L555-L570
train
rkt/rkt
store/imagestore/store.go
GetImageManifestJSON
func (s *Store) GetImageManifestJSON(key string) ([]byte, error) { key, err := s.ResolveKey(key) if err != nil { return nil, errwrap.Wrap(errors.New("error resolving image ID"), err) } keyLock, err := lock.SharedKeyLock(s.imageLockDir, key) if err != nil { return nil, errwrap.Wrap(errors.New("error locking ima...
go
func (s *Store) GetImageManifestJSON(key string) ([]byte, error) { key, err := s.ResolveKey(key) if err != nil { return nil, errwrap.Wrap(errors.New("error resolving image ID"), err) } keyLock, err := lock.SharedKeyLock(s.imageLockDir, key) if err != nil { return nil, errwrap.Wrap(errors.New("error locking ima...
[ "func", "(", "s", "*", "Store", ")", "GetImageManifestJSON", "(", "key", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "key", ",", "err", ":=", "s", ".", "ResolveKey", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// GetImageManifestJSON gets the ImageManifest JSON bytes with the // specified key.
[ "GetImageManifestJSON", "gets", "the", "ImageManifest", "JSON", "bytes", "with", "the", "specified", "key", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/store.go#L582-L598
train
rkt/rkt
store/imagestore/store.go
GetImageManifest
func (s *Store) GetImageManifest(key string) (*schema.ImageManifest, error) { imj, err := s.GetImageManifestJSON(key) if err != nil { return nil, err } var im *schema.ImageManifest if err = json.Unmarshal(imj, &im); err != nil { return nil, errwrap.Wrap(errors.New("error unmarshalling image manifest"), err) }...
go
func (s *Store) GetImageManifest(key string) (*schema.ImageManifest, error) { imj, err := s.GetImageManifestJSON(key) if err != nil { return nil, err } var im *schema.ImageManifest if err = json.Unmarshal(imj, &im); err != nil { return nil, errwrap.Wrap(errors.New("error unmarshalling image manifest"), err) }...
[ "func", "(", "s", "*", "Store", ")", "GetImageManifest", "(", "key", "string", ")", "(", "*", "schema", ".", "ImageManifest", ",", "error", ")", "{", "imj", ",", "err", ":=", "s", ".", "GetImageManifestJSON", "(", "key", ")", "\n", "if", "err", "!=",...
// GetImageManifest gets the ImageManifest with the specified key.
[ "GetImageManifest", "gets", "the", "ImageManifest", "with", "the", "specified", "key", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/store.go#L601-L611
train
rkt/rkt
store/imagestore/store.go
HasFullKey
func (s *Store) HasFullKey(key string) bool { return s.stores[imageManifestType].Has(key) }
go
func (s *Store) HasFullKey(key string) bool { return s.stores[imageManifestType].Has(key) }
[ "func", "(", "s", "*", "Store", ")", "HasFullKey", "(", "key", "string", ")", "bool", "{", "return", "s", ".", "stores", "[", "imageManifestType", "]", ".", "Has", "(", "key", ")", "\n", "}" ]
// HasFullKey returns whether the image with the given key exists on the disk by // checking if the image manifest kv store contains the key.
[ "HasFullKey", "returns", "whether", "the", "image", "with", "the", "given", "key", "exists", "on", "the", "disk", "by", "checking", "if", "the", "image", "manifest", "kv", "store", "contains", "the", "key", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/store.go#L756-L758
train
rkt/rkt
store/imagestore/store.go
keyToString
func keyToString(k []byte) string { if len(k) != lenHash { panic(fmt.Sprintf("bad hash passed to hashToKey: %x", k)) } return fmt.Sprintf("%s%x", hashPrefix, k)[0:lenKey] }
go
func keyToString(k []byte) string { if len(k) != lenHash { panic(fmt.Sprintf("bad hash passed to hashToKey: %x", k)) } return fmt.Sprintf("%s%x", hashPrefix, k)[0:lenKey] }
[ "func", "keyToString", "(", "k", "[", "]", "byte", ")", "string", "{", "if", "len", "(", "k", ")", "!=", "lenHash", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "k", ")", ")", "\n", "}", "\n", "return", "fmt", ".", "Sprintf",...
// keyToString takes a key and returns a shortened and prefixed hexadecimal string version
[ "keyToString", "takes", "a", "key", "and", "returns", "a", "shortened", "and", "prefixed", "hexadecimal", "string", "version" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/store.go#L766-L771
train
rkt/rkt
rkt/image/downloader.go
Download
func (d *downloader) Download(u *url.URL, out writeSyncer) error { client, err := d.Session.Client() if err != nil { return err } req, err := d.Session.Request(u) if err != nil { return err } res, err := client.Do(req) if err != nil { return err } defer res.Body.Close() if stopNow, err := d.Session.Ha...
go
func (d *downloader) Download(u *url.URL, out writeSyncer) error { client, err := d.Session.Client() if err != nil { return err } req, err := d.Session.Request(u) if err != nil { return err } res, err := client.Do(req) if err != nil { return err } defer res.Body.Close() if stopNow, err := d.Session.Ha...
[ "func", "(", "d", "*", "downloader", ")", "Download", "(", "u", "*", "url", ".", "URL", ",", "out", "writeSyncer", ")", "error", "{", "client", ",", "err", ":=", "d", ".", "Session", ".", "Client", "(", ")", "\n", "if", "err", "!=", "nil", "{", ...
// Download tries to fetch the passed URL and write the contents into // a given writeSyncer instance.
[ "Download", "tries", "to", "fetch", "the", "passed", "URL", "and", "write", "the", "contents", "into", "a", "given", "writeSyncer", "instance", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/downloader.go#L54-L86
train
rkt/rkt
rkt/enter.go
getAppName
func getAppName(p *pkgPod.Pod) (*types.ACName, error) { if flagAppName != "" { return types.NewACName(flagAppName) } // figure out the app name, or show a list if multiple are present _, m, err := p.PodManifest() if err != nil { return nil, errwrap.Wrap(errors.New("error reading pod manifest"), err) } swit...
go
func getAppName(p *pkgPod.Pod) (*types.ACName, error) { if flagAppName != "" { return types.NewACName(flagAppName) } // figure out the app name, or show a list if multiple are present _, m, err := p.PodManifest() if err != nil { return nil, errwrap.Wrap(errors.New("error reading pod manifest"), err) } swit...
[ "func", "getAppName", "(", "p", "*", "pkgPod", ".", "Pod", ")", "(", "*", "types", ".", "ACName", ",", "error", ")", "{", "if", "flagAppName", "!=", "\"", "\"", "{", "return", "types", ".", "NewACName", "(", "flagAppName", ")", "\n", "}", "\n\n", "...
// getAppName returns the app name to enter // If one was supplied in the flags then it's simply returned // If the PM contains a single app, that app's name is returned // If the PM has multiple apps, the names are printed and an error is returned
[ "getAppName", "returns", "the", "app", "name", "to", "enter", "If", "one", "was", "supplied", "in", "the", "flags", "then", "it", "s", "simply", "returned", "If", "the", "PM", "contains", "a", "single", "app", "that", "app", "s", "name", "is", "returned"...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/enter.go#L128-L153
train
rkt/rkt
rkt/enter.go
getEnterArgv
func getEnterArgv(p *pkgPod.Pod, cmdArgs []string) ([]string, error) { var argv []string if len(cmdArgs) < 2 { stderr.Printf("no command specified, assuming %q", defaultCmd) argv = []string{defaultCmd} } else { argv = cmdArgs[1:] } return argv, nil }
go
func getEnterArgv(p *pkgPod.Pod, cmdArgs []string) ([]string, error) { var argv []string if len(cmdArgs) < 2 { stderr.Printf("no command specified, assuming %q", defaultCmd) argv = []string{defaultCmd} } else { argv = cmdArgs[1:] } return argv, nil }
[ "func", "getEnterArgv", "(", "p", "*", "pkgPod", ".", "Pod", ",", "cmdArgs", "[", "]", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "argv", "[", "]", "string", "\n", "if", "len", "(", "cmdArgs", ")", "<", "2", "{", "st...
// getEnterArgv returns the argv to use for entering the pod
[ "getEnterArgv", "returns", "the", "argv", "to", "use", "for", "entering", "the", "pod" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/enter.go#L156-L166
train
rkt/rkt
common/cgroup/v1/cgroup.go
mountFsRO
func mountFsRO(m fs.Mounter, mountPoint string, flags uintptr) error { flags = flags | syscall.MS_BIND | syscall.MS_REMOUNT | syscall.MS_RDONLY if err := m.Mount(mountPoint, mountPoint, "", flags, ""); err != nil { return errwrap.Wrap(fmt.Errorf("error remounting read-only %q", mountPoint), err) } return ...
go
func mountFsRO(m fs.Mounter, mountPoint string, flags uintptr) error { flags = flags | syscall.MS_BIND | syscall.MS_REMOUNT | syscall.MS_RDONLY if err := m.Mount(mountPoint, mountPoint, "", flags, ""); err != nil { return errwrap.Wrap(fmt.Errorf("error remounting read-only %q", mountPoint), err) } return ...
[ "func", "mountFsRO", "(", "m", "fs", ".", "Mounter", ",", "mountPoint", "string", ",", "flags", "uintptr", ")", "error", "{", "flags", "=", "flags", "|", "syscall", ".", "MS_BIND", "|", "syscall", ".", "MS_REMOUNT", "|", "syscall", ".", "MS_RDONLY", "\n\...
// mountFsRO remounts the given mountPoint using the given flags read-only.
[ "mountFsRO", "remounts", "the", "given", "mountPoint", "using", "the", "given", "flags", "read", "-", "only", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/cgroup/v1/cgroup.go#L36-L47
train
rkt/rkt
common/cgroup/v1/cgroup.go
GetEnabledCgroups
func GetEnabledCgroups() (map[int][]string, error) { cgroupsFile, err := os.Open("/proc/cgroups") if err != nil { return nil, err } defer cgroupsFile.Close() cgroups, err := parseCgroups(cgroupsFile) if err != nil { return nil, errwrap.Wrap(errors.New("error parsing /proc/cgroups"), err) } return cgroups,...
go
func GetEnabledCgroups() (map[int][]string, error) { cgroupsFile, err := os.Open("/proc/cgroups") if err != nil { return nil, err } defer cgroupsFile.Close() cgroups, err := parseCgroups(cgroupsFile) if err != nil { return nil, errwrap.Wrap(errors.New("error parsing /proc/cgroups"), err) } return cgroups,...
[ "func", "GetEnabledCgroups", "(", ")", "(", "map", "[", "int", "]", "[", "]", "string", ",", "error", ")", "{", "cgroupsFile", ",", "err", ":=", "os", ".", "Open", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// GetEnabledCgroups returns a map with the enabled cgroup controllers grouped by // hierarchy
[ "GetEnabledCgroups", "returns", "a", "map", "with", "the", "enabled", "cgroup", "controllers", "grouped", "by", "hierarchy" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/cgroup/v1/cgroup.go#L81-L94
train
rkt/rkt
common/cgroup/v1/cgroup.go
GetOwnCgroupPath
func GetOwnCgroupPath(controller string) (string, error) { parts, err := parseCgroupController("/proc/self/cgroup", controller) if err != nil { return "", err } return parts[2], nil }
go
func GetOwnCgroupPath(controller string) (string, error) { parts, err := parseCgroupController("/proc/self/cgroup", controller) if err != nil { return "", err } return parts[2], nil }
[ "func", "GetOwnCgroupPath", "(", "controller", "string", ")", "(", "string", ",", "error", ")", "{", "parts", ",", "err", ":=", "parseCgroupController", "(", "\"", "\"", ",", "controller", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ...
// GetOwnCgroupPath returns the cgroup path of this process in controller // hierarchy
[ "GetOwnCgroupPath", "returns", "the", "cgroup", "path", "of", "this", "process", "in", "controller", "hierarchy" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/cgroup/v1/cgroup.go#L149-L155
train
rkt/rkt
common/cgroup/v1/cgroup.go
GetCgroupPathByPid
func GetCgroupPathByPid(pid int, controller string) (string, error) { parts, err := parseCgroupController(fmt.Sprintf("/proc/%d/cgroup", pid), controller) if err != nil { return "", err } return parts[2], nil }
go
func GetCgroupPathByPid(pid int, controller string) (string, error) { parts, err := parseCgroupController(fmt.Sprintf("/proc/%d/cgroup", pid), controller) if err != nil { return "", err } return parts[2], nil }
[ "func", "GetCgroupPathByPid", "(", "pid", "int", ",", "controller", "string", ")", "(", "string", ",", "error", ")", "{", "parts", ",", "err", ":=", "parseCgroupController", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "pid", ")", ",", "controller",...
// GetCgroupPathByPid returns the cgroup path of the process with the given pid // and given controller.
[ "GetCgroupPathByPid", "returns", "the", "cgroup", "path", "of", "the", "process", "with", "the", "given", "pid", "and", "given", "controller", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/cgroup/v1/cgroup.go#L159-L165
train
rkt/rkt
common/cgroup/v1/cgroup.go
JoinSubcgroup
func JoinSubcgroup(controller string, subcgroup string) error { subcgroupPath := filepath.Join("/sys/fs/cgroup", controller, subcgroup) if err := os.MkdirAll(subcgroupPath, 0600); err != nil { return errwrap.Wrap(fmt.Errorf("error creating %q subcgroup", subcgroup), err) } pidBytes := []byte(strconv.Itoa(os.Getpi...
go
func JoinSubcgroup(controller string, subcgroup string) error { subcgroupPath := filepath.Join("/sys/fs/cgroup", controller, subcgroup) if err := os.MkdirAll(subcgroupPath, 0600); err != nil { return errwrap.Wrap(fmt.Errorf("error creating %q subcgroup", subcgroup), err) } pidBytes := []byte(strconv.Itoa(os.Getpi...
[ "func", "JoinSubcgroup", "(", "controller", "string", ",", "subcgroup", "string", ")", "error", "{", "subcgroupPath", ":=", "filepath", ".", "Join", "(", "\"", "\"", ",", "controller", ",", "subcgroup", ")", "\n", "if", "err", ":=", "os", ".", "MkdirAll", ...
// JoinSubcgroup makes the calling process join the subcgroup hierarchy on a // particular controller
[ "JoinSubcgroup", "makes", "the", "calling", "process", "join", "the", "subcgroup", "hierarchy", "on", "a", "particular", "controller" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/cgroup/v1/cgroup.go#L169-L180
train
rkt/rkt
common/cgroup/v1/cgroup.go
IsControllerMounted
func IsControllerMounted(c string) (bool, error) { cgroupProcsPath := filepath.Join("/sys/fs/cgroup", c, "cgroup.procs") if _, err := os.Stat(cgroupProcsPath); err != nil { if !os.IsNotExist(err) { return false, err } return false, nil } return true, nil }
go
func IsControllerMounted(c string) (bool, error) { cgroupProcsPath := filepath.Join("/sys/fs/cgroup", c, "cgroup.procs") if _, err := os.Stat(cgroupProcsPath); err != nil { if !os.IsNotExist(err) { return false, err } return false, nil } return true, nil }
[ "func", "IsControllerMounted", "(", "c", "string", ")", "(", "bool", ",", "error", ")", "{", "cgroupProcsPath", ":=", "filepath", ".", "Join", "(", "\"", "\"", ",", "c", ",", "\"", "\"", ")", "\n", "if", "_", ",", "err", ":=", "os", ".", "Stat", ...
// IsControllerMounted returns whether a controller is mounted by checking that // cgroup.procs is accessible
[ "IsControllerMounted", "returns", "whether", "a", "controller", "is", "mounted", "by", "checking", "that", "cgroup", ".", "procs", "is", "accessible" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/cgroup/v1/cgroup.go#L238-L248
train
rkt/rkt
pkg/fileutil/fileutil_linux.go
Lgetxattr
func Lgetxattr(path string, attr string) ([]byte, error) { pathBytes, err := syscall.BytePtrFromString(path) if err != nil { return nil, err } attrBytes, err := syscall.BytePtrFromString(attr) if err != nil { return nil, err } dest := make([]byte, 128) destBytes := unsafe.Pointer(&dest[0]) sz, _, errno :=...
go
func Lgetxattr(path string, attr string) ([]byte, error) { pathBytes, err := syscall.BytePtrFromString(path) if err != nil { return nil, err } attrBytes, err := syscall.BytePtrFromString(attr) if err != nil { return nil, err } dest := make([]byte, 128) destBytes := unsafe.Pointer(&dest[0]) sz, _, errno :=...
[ "func", "Lgetxattr", "(", "path", "string", ",", "attr", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "pathBytes", ",", "err", ":=", "syscall", ".", "BytePtrFromString", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// Returns a nil slice and nil error if the xattr is not set
[ "Returns", "a", "nil", "slice", "and", "nil", "error", "if", "the", "xattr", "is", "not", "set" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/fileutil/fileutil_linux.go#L58-L84
train
rkt/rkt
pkg/fileutil/fileutil_linux.go
GetDeviceInfo
func GetDeviceInfo(path string) (kind rune, major uint64, minor uint64, err error) { d, err := os.Lstat(path) if err != nil { return } mode := d.Mode() if mode&os.ModeDevice == 0 { err = fmt.Errorf("not a device: %s", path) return } stat_t, ok := d.Sys().(*syscall.Stat_t) if !ok { err = fmt.Errorf("can...
go
func GetDeviceInfo(path string) (kind rune, major uint64, minor uint64, err error) { d, err := os.Lstat(path) if err != nil { return } mode := d.Mode() if mode&os.ModeDevice == 0 { err = fmt.Errorf("not a device: %s", path) return } stat_t, ok := d.Sys().(*syscall.Stat_t) if !ok { err = fmt.Errorf("can...
[ "func", "GetDeviceInfo", "(", "path", "string", ")", "(", "kind", "rune", ",", "major", "uint64", ",", "minor", "uint64", ",", "err", "error", ")", "{", "d", ",", "err", ":=", "os", ".", "Lstat", "(", "path", ")", "\n", "if", "err", "!=", "nil", ...
// GetDeviceInfo returns the type, major, and minor numbers of a device. // Kind is 'b' or 'c' for block and character devices, respectively. // This does not follow symlinks.
[ "GetDeviceInfo", "returns", "the", "type", "major", "and", "minor", "numbers", "of", "a", "device", ".", "Kind", "is", "b", "or", "c", "for", "block", "and", "character", "devices", "respectively", ".", "This", "does", "not", "follow", "symlinks", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/fileutil/fileutil_linux.go#L113-L130
train
rkt/rkt
pkg/fileutil/fileutil_linux.go
getDeviceInfo
func getDeviceInfo(mode os.FileMode, rdev uint64) (kind rune, major uint64, minor uint64, err error) { kind = 'b' if mode&os.ModeCharDevice != 0 { kind = 'c' } major = (rdev >> 8) & 0xfff minor = (rdev & 0xff) | ((rdev >> 12) & 0xfff00) return }
go
func getDeviceInfo(mode os.FileMode, rdev uint64) (kind rune, major uint64, minor uint64, err error) { kind = 'b' if mode&os.ModeCharDevice != 0 { kind = 'c' } major = (rdev >> 8) & 0xfff minor = (rdev & 0xff) | ((rdev >> 12) & 0xfff00) return }
[ "func", "getDeviceInfo", "(", "mode", "os", ".", "FileMode", ",", "rdev", "uint64", ")", "(", "kind", "rune", ",", "major", "uint64", ",", "minor", "uint64", ",", "err", "error", ")", "{", "kind", "=", "'b'", "\n\n", "if", "mode", "&", "os", ".", "...
// Parse the device info out of the mode bits. Separate for testability.
[ "Parse", "the", "device", "info", "out", "of", "the", "mode", "bits", ".", "Separate", "for", "testability", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/fileutil/fileutil_linux.go#L133-L144
train
rkt/rkt
common/cgroup/cgroup.go
IsIsolatorSupported
func IsIsolatorSupported(isolator string) (bool, error) { isUnified, err := IsCgroupUnified("/") if err != nil { return false, errwrap.Wrap(errors.New("error determining cgroup version"), err) } if isUnified { controllers, err := v2.GetEnabledControllers() if err != nil { return false, errwrap.Wrap(errors...
go
func IsIsolatorSupported(isolator string) (bool, error) { isUnified, err := IsCgroupUnified("/") if err != nil { return false, errwrap.Wrap(errors.New("error determining cgroup version"), err) } if isUnified { controllers, err := v2.GetEnabledControllers() if err != nil { return false, errwrap.Wrap(errors...
[ "func", "IsIsolatorSupported", "(", "isolator", "string", ")", "(", "bool", ",", "error", ")", "{", "isUnified", ",", "err", ":=", "IsCgroupUnified", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "errwrap", ".", "Wr...
// IsIsolatorSupported returns whether an isolator is supported in the kernel
[ "IsIsolatorSupported", "returns", "whether", "an", "isolator", "is", "supported", "in", "the", "kernel" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/cgroup/cgroup.go#L37-L56
train
rkt/rkt
pkg/backup/backup.go
CreateBackup
func CreateBackup(dir, backupsDir string, limit int) error { tmpBackupDir := filepath.Join(backupsDir, "tmp") if err := os.MkdirAll(backupsDir, 0750); err != nil { return err } if err := fileutil.CopyTree(dir, tmpBackupDir, user.NewBlankUidRange()); err != nil { return err } defer os.RemoveAll(tmpBackupDir) ...
go
func CreateBackup(dir, backupsDir string, limit int) error { tmpBackupDir := filepath.Join(backupsDir, "tmp") if err := os.MkdirAll(backupsDir, 0750); err != nil { return err } if err := fileutil.CopyTree(dir, tmpBackupDir, user.NewBlankUidRange()); err != nil { return err } defer os.RemoveAll(tmpBackupDir) ...
[ "func", "CreateBackup", "(", "dir", ",", "backupsDir", "string", ",", "limit", "int", ")", "error", "{", "tmpBackupDir", ":=", "filepath", ".", "Join", "(", "backupsDir", ",", "\"", "\"", ")", "\n", "if", "err", ":=", "os", ".", "MkdirAll", "(", "backu...
// CreateBackup backs a directory up in a given directory. It basically // copies this directory into a given backups directory. The backups // directory has a simple structure - a directory inside named "0" is // the most recent backup. A directory name for oldest backup is // deduced from a given limit. For instance,...
[ "CreateBackup", "backs", "a", "directory", "up", "in", "a", "given", "directory", ".", "It", "basically", "copies", "this", "directory", "into", "a", "given", "backups", "directory", ".", "The", "backups", "directory", "has", "a", "simple", "structure", "-", ...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/backup/backup.go#L35-L55
train
rkt/rkt
pkg/backup/backup.go
pruneOldBackups
func pruneOldBackups(dir string, limit int) error { if list, err := ioutil.ReadDir(dir); err != nil { return err } else { for _, fi := range list { if num, err := strconv.Atoi(fi.Name()); err != nil { // directory name is not a number, // leave it alone continue } else if num < limit { // di...
go
func pruneOldBackups(dir string, limit int) error { if list, err := ioutil.ReadDir(dir); err != nil { return err } else { for _, fi := range list { if num, err := strconv.Atoi(fi.Name()); err != nil { // directory name is not a number, // leave it alone continue } else if num < limit { // di...
[ "func", "pruneOldBackups", "(", "dir", "string", ",", "limit", "int", ")", "error", "{", "if", "list", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "dir", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "else", "{", "for", "_", ...
// pruneOldBackups removes old backups, that is - directories with // names greater or equal than given limit.
[ "pruneOldBackups", "removes", "old", "backups", "that", "is", "-", "directories", "with", "names", "greater", "or", "equal", "than", "given", "limit", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/backup/backup.go#L59-L80
train
rkt/rkt
pkg/backup/backup.go
shiftBackups
func shiftBackups(dir string, oldest int) error { if oldest < 0 { return nil } for i := oldest; i >= 0; i-- { current := filepath.Join(dir, strconv.Itoa(i)) inc := filepath.Join(dir, strconv.Itoa(i+1)) if err := os.Rename(current, inc); err != nil && !os.IsNotExist(err) { return err } } return nil }
go
func shiftBackups(dir string, oldest int) error { if oldest < 0 { return nil } for i := oldest; i >= 0; i-- { current := filepath.Join(dir, strconv.Itoa(i)) inc := filepath.Join(dir, strconv.Itoa(i+1)) if err := os.Rename(current, inc); err != nil && !os.IsNotExist(err) { return err } } return nil }
[ "func", "shiftBackups", "(", "dir", "string", ",", "oldest", "int", ")", "error", "{", "if", "oldest", "<", "0", "{", "return", "nil", "\n", "}", "\n", "for", "i", ":=", "oldest", ";", "i", ">=", "0", ";", "i", "--", "{", "current", ":=", "filepa...
// shiftBackups renames all directories with names being numbers up to // oldest to names with numbers greater by one.
[ "shiftBackups", "renames", "all", "directories", "with", "names", "being", "numbers", "up", "to", "oldest", "to", "names", "with", "numbers", "greater", "by", "one", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/backup/backup.go#L84-L96
train
rkt/rkt
pkg/aci/aci.go
NewBasicACI
func NewBasicACI(dir string, name string) (*os.File, error) { manifest := schema.ImageManifest{ ACKind: schema.ImageManifestKind, ACVersion: schema.AppContainerVersion, Name: types.ACIdentifier(name), } b, err := manifest.MarshalJSON() if err != nil { return nil, err } return NewACI(dir, string(...
go
func NewBasicACI(dir string, name string) (*os.File, error) { manifest := schema.ImageManifest{ ACKind: schema.ImageManifestKind, ACVersion: schema.AppContainerVersion, Name: types.ACIdentifier(name), } b, err := manifest.MarshalJSON() if err != nil { return nil, err } return NewACI(dir, string(...
[ "func", "NewBasicACI", "(", "dir", "string", ",", "name", "string", ")", "(", "*", "os", ".", "File", ",", "error", ")", "{", "manifest", ":=", "schema", ".", "ImageManifest", "{", "ACKind", ":", "schema", ".", "ImageManifestKind", ",", "ACVersion", ":",...
// NewBasicACI creates a new ACI in the given directory with the given name. // Used for testing.
[ "NewBasicACI", "creates", "a", "new", "ACI", "in", "the", "given", "directory", "with", "the", "given", "name", ".", "Used", "for", "testing", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/aci/aci.go#L109-L122
train
rkt/rkt
pkg/aci/aci.go
NewACI
func NewACI(dir string, manifest string, entries []*ACIEntry) (*os.File, error) { var im schema.ImageManifest if err := im.UnmarshalJSON([]byte(manifest)); err != nil { return nil, errwrap.Wrap(errors.New("invalid image manifest"), err) } tf, err := ioutil.TempFile(dir, "") if err != nil { return nil, err } ...
go
func NewACI(dir string, manifest string, entries []*ACIEntry) (*os.File, error) { var im schema.ImageManifest if err := im.UnmarshalJSON([]byte(manifest)); err != nil { return nil, errwrap.Wrap(errors.New("invalid image manifest"), err) } tf, err := ioutil.TempFile(dir, "") if err != nil { return nil, err } ...
[ "func", "NewACI", "(", "dir", "string", ",", "manifest", "string", ",", "entries", "[", "]", "*", "ACIEntry", ")", "(", "*", "os", ".", "File", ",", "error", ")", "{", "var", "im", "schema", ".", "ImageManifest", "\n", "if", "err", ":=", "im", ".",...
// NewACI creates a new ACI in the given directory with the given image // manifest and entries. // Used for testing.
[ "NewACI", "creates", "a", "new", "ACI", "in", "the", "given", "directory", "with", "the", "given", "image", "manifest", "and", "entries", ".", "Used", "for", "testing", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/aci/aci.go#L127-L164
train
rkt/rkt
pkg/aci/aci.go
NewDetachedSignature
func NewDetachedSignature(armoredPrivateKey string, aci io.Reader) (io.Reader, error) { entityList, err := openpgp.ReadArmoredKeyRing(bytes.NewBufferString(armoredPrivateKey)) if err != nil { return nil, err } if len(entityList) < 1 { return nil, errors.New("empty entity list") } signature := &bytes.Buffer{} ...
go
func NewDetachedSignature(armoredPrivateKey string, aci io.Reader) (io.Reader, error) { entityList, err := openpgp.ReadArmoredKeyRing(bytes.NewBufferString(armoredPrivateKey)) if err != nil { return nil, err } if len(entityList) < 1 { return nil, errors.New("empty entity list") } signature := &bytes.Buffer{} ...
[ "func", "NewDetachedSignature", "(", "armoredPrivateKey", "string", ",", "aci", "io", ".", "Reader", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "entityList", ",", "err", ":=", "openpgp", ".", "ReadArmoredKeyRing", "(", "bytes", ".", "NewBufferStr...
// NewDetachedSignature creates a new openpgp armored detached signature for the given ACI // signed with armoredPrivateKey.
[ "NewDetachedSignature", "creates", "a", "new", "openpgp", "armored", "detached", "signature", "for", "the", "given", "ACI", "signed", "with", "armoredPrivateKey", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/aci/aci.go#L168-L181
train
rkt/rkt
pkg/pod/sandbox.go
SandboxManifest
func (p *Pod) SandboxManifest() (*schema.PodManifest, error) { _, pm, err := p.PodManifest() // this takes the lock fd to load the manifest, hence path is not needed here if err != nil { return nil, errwrap.Wrap(errors.New("error loading pod manifest"), err) } ms, ok := pm.Annotations.Get("coreos.com/rkt/stage1/...
go
func (p *Pod) SandboxManifest() (*schema.PodManifest, error) { _, pm, err := p.PodManifest() // this takes the lock fd to load the manifest, hence path is not needed here if err != nil { return nil, errwrap.Wrap(errors.New("error loading pod manifest"), err) } ms, ok := pm.Annotations.Get("coreos.com/rkt/stage1/...
[ "func", "(", "p", "*", "Pod", ")", "SandboxManifest", "(", ")", "(", "*", "schema", ".", "PodManifest", ",", "error", ")", "{", "_", ",", "pm", ",", "err", ":=", "p", ".", "PodManifest", "(", ")", "// this takes the lock fd to load the manifest, hence path i...
// SandboxManifest loads the underlying pod manifest and checks whether mutable operations are allowed. // It returns ErrImmutable if the pod does not allow mutable operations or any other error if the operation failed. // Upon success a reference to the pod manifest is returned and mutable operations are possible.
[ "SandboxManifest", "loads", "the", "underlying", "pod", "manifest", "and", "checks", "whether", "mutable", "operations", "are", "allowed", ".", "It", "returns", "ErrImmutable", "if", "the", "pod", "does", "not", "allow", "mutable", "operations", "or", "any", "ot...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/pod/sandbox.go#L37-L56
train
rkt/rkt
pkg/pod/sandbox.go
UpdateManifest
func (p *Pod) UpdateManifest(m *schema.PodManifest, path string) error { if !p.mutable { return ErrImmutable } mpath := common.PodManifestPath(path) mstat, err := os.Stat(mpath) if err != nil { return err } tmpf, err := ioutil.TempFile(path, "") if err != nil { return err } defer func() { tmpf.Clos...
go
func (p *Pod) UpdateManifest(m *schema.PodManifest, path string) error { if !p.mutable { return ErrImmutable } mpath := common.PodManifestPath(path) mstat, err := os.Stat(mpath) if err != nil { return err } tmpf, err := ioutil.TempFile(path, "") if err != nil { return err } defer func() { tmpf.Clos...
[ "func", "(", "p", "*", "Pod", ")", "UpdateManifest", "(", "m", "*", "schema", ".", "PodManifest", ",", "path", "string", ")", "error", "{", "if", "!", "p", ".", "mutable", "{", "return", "ErrImmutable", "\n", "}", "\n\n", "mpath", ":=", "common", "."...
// UpdateManifest updates the given pod manifest in the given path atomically on the file system. // The pod manifest has to be locked using LockManifest first to avoid races in case of concurrent writes.
[ "UpdateManifest", "updates", "the", "given", "pod", "manifest", "in", "the", "given", "path", "atomically", "on", "the", "file", "system", ".", "The", "pod", "manifest", "has", "to", "be", "locked", "using", "LockManifest", "first", "to", "avoid", "races", "...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/pod/sandbox.go#L60-L94
train
rkt/rkt
pkg/pod/sandbox.go
ExclusiveLockManifest
func (p *Pod) ExclusiveLockManifest() error { if p.manifestLock != nil { return p.manifestLock.ExclusiveLock() // This is idempotent } l, err := lock.ExclusiveLock(common.PodManifestLockPath(p.Path()), lock.RegFile) if err != nil { return err } p.manifestLock = l return nil }
go
func (p *Pod) ExclusiveLockManifest() error { if p.manifestLock != nil { return p.manifestLock.ExclusiveLock() // This is idempotent } l, err := lock.ExclusiveLock(common.PodManifestLockPath(p.Path()), lock.RegFile) if err != nil { return err } p.manifestLock = l return nil }
[ "func", "(", "p", "*", "Pod", ")", "ExclusiveLockManifest", "(", ")", "error", "{", "if", "p", ".", "manifestLock", "!=", "nil", "{", "return", "p", ".", "manifestLock", ".", "ExclusiveLock", "(", ")", "// This is idempotent", "\n", "}", "\n\n", "l", ","...
// ExclusiveLockManifest gets an exclusive lock on only the pod manifest in the app sandbox. // Since the pod might already be running, we can't just get an exclusive lock on the pod itself.
[ "ExclusiveLockManifest", "gets", "an", "exclusive", "lock", "on", "only", "the", "pod", "manifest", "in", "the", "app", "sandbox", ".", "Since", "the", "pod", "might", "already", "be", "running", "we", "can", "t", "just", "get", "an", "exclusive", "lock", ...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/pod/sandbox.go#L98-L110
train
rkt/rkt
pkg/pod/sandbox.go
UnlockManifest
func (p *Pod) UnlockManifest() error { if p.manifestLock == nil { return nil } if err := p.manifestLock.Close(); err != nil { return err } p.manifestLock = nil return nil }
go
func (p *Pod) UnlockManifest() error { if p.manifestLock == nil { return nil } if err := p.manifestLock.Close(); err != nil { return err } p.manifestLock = nil return nil }
[ "func", "(", "p", "*", "Pod", ")", "UnlockManifest", "(", ")", "error", "{", "if", "p", ".", "manifestLock", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "err", ":=", "p", ".", "manifestLock", ".", "Close", "(", ")", ";", "err", "!...
// UnlockManifest unlocks the pod manifest lock.
[ "UnlockManifest", "unlocks", "the", "pod", "manifest", "lock", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/pod/sandbox.go#L113-L123
train
rkt/rkt
store/imagestore/schema.go
getDBVersion
func getDBVersion(tx *sql.Tx) (int, error) { var version int rows, err := tx.Query("SELECT version FROM version") if err != nil { return -1, err } defer rows.Close() found := false for rows.Next() { if err := rows.Scan(&version); err != nil { return -1, err } found = true break } if err := rows.Er...
go
func getDBVersion(tx *sql.Tx) (int, error) { var version int rows, err := tx.Query("SELECT version FROM version") if err != nil { return -1, err } defer rows.Close() found := false for rows.Next() { if err := rows.Scan(&version); err != nil { return -1, err } found = true break } if err := rows.Er...
[ "func", "getDBVersion", "(", "tx", "*", "sql", ".", "Tx", ")", "(", "int", ",", "error", ")", "{", "var", "version", "int", "\n", "rows", ",", "err", ":=", "tx", ".", "Query", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return",...
// getDBVersion retrieves the current db version
[ "getDBVersion", "retrieves", "the", "current", "db", "version" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/schema.go#L66-L88
train
rkt/rkt
store/imagestore/schema.go
updateDBVersion
func updateDBVersion(tx *sql.Tx, version int) 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 version") if err != nil { return err } _, err = tx.Exec("INSERT INTO version VALUES ($1)", version) if err != nil { return err ...
go
func updateDBVersion(tx *sql.Tx, version int) 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 version") if err != nil { return err } _, err = tx.Exec("INSERT INTO version VALUES ($1)", version) if err != nil { return err ...
[ "func", "updateDBVersion", "(", "tx", "*", "sql", ".", "Tx", ",", "version", "int", ")", "error", "{", "// ql doesn't have an INSERT OR UPDATE function so", "// it's faster to remove and reinsert the row", "_", ",", "err", ":=", "tx", ".", "Exec", "(", "\"", "\"", ...
// updateDBVersion updates the db version
[ "updateDBVersion", "updates", "the", "db", "version" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/schema.go#L91-L103
train
rkt/rkt
pkg/acl/acl.go
InitACL
func InitACL() (*ACL, error) { h, err := getHandle() if err != nil { return nil, err } return &ACL{lib: h}, nil }
go
func InitACL() (*ACL, error) { h, err := getHandle() if err != nil { return nil, err } return &ACL{lib: h}, nil }
[ "func", "InitACL", "(", ")", "(", "*", "ACL", ",", "error", ")", "{", "h", ",", "err", ":=", "getHandle", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "return", "&", "ACL", "{", "lib", ":", "h...
// InitACL dlopens libacl and returns an ACL object if successful.
[ "InitACL", "dlopens", "libacl", "and", "returns", "an", "ACL", "object", "if", "successful", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/acl/acl.go#L220-L227
train
rkt/rkt
pkg/acl/acl.go
ParseACL
func (a *ACL) ParseACL(acl string) error { acl_from_text, err := getSymbolPointer(a.lib.handle, "acl_from_text") if err != nil { return err } cacl := C.CString(acl) defer C.free(unsafe.Pointer(cacl)) retACL, err := C.my_acl_from_text(acl_from_text, cacl) if retACL == nil { return errwrap.Wrap(errors.New("er...
go
func (a *ACL) ParseACL(acl string) error { acl_from_text, err := getSymbolPointer(a.lib.handle, "acl_from_text") if err != nil { return err } cacl := C.CString(acl) defer C.free(unsafe.Pointer(cacl)) retACL, err := C.my_acl_from_text(acl_from_text, cacl) if retACL == nil { return errwrap.Wrap(errors.New("er...
[ "func", "(", "a", "*", "ACL", ")", "ParseACL", "(", "acl", "string", ")", "error", "{", "acl_from_text", ",", "err", ":=", "getSymbolPointer", "(", "a", ".", "lib", ".", "handle", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return",...
// ParseACL parses a string representation of an ACL.
[ "ParseACL", "parses", "a", "string", "representation", "of", "an", "ACL", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/acl/acl.go#L230-L246
train
rkt/rkt
pkg/acl/acl.go
Free
func (a *ACL) Free() error { acl_free, err := getSymbolPointer(a.lib.handle, "acl_free") if err != nil { return err } ret, err := C.my_acl_free(acl_free, a.a) if ret < 0 { return errwrap.Wrap(errors.New("error calling acl_free"), err) } return a.lib.close() }
go
func (a *ACL) Free() error { acl_free, err := getSymbolPointer(a.lib.handle, "acl_free") if err != nil { return err } ret, err := C.my_acl_free(acl_free, a.a) if ret < 0 { return errwrap.Wrap(errors.New("error calling acl_free"), err) } return a.lib.close() }
[ "func", "(", "a", "*", "ACL", ")", "Free", "(", ")", "error", "{", "acl_free", ",", "err", ":=", "getSymbolPointer", "(", "a", ".", "lib", ".", "handle", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n...
// Free frees libacl's internal structures and closes libacl.
[ "Free", "frees", "libacl", "s", "internal", "structures", "and", "closes", "libacl", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/acl/acl.go#L249-L261
train
rkt/rkt
pkg/acl/acl.go
SetFileACLDefault
func (a *ACL) SetFileACLDefault(path string) error { acl_set_file, err := getSymbolPointer(a.lib.handle, "acl_set_file") if err != nil { return err } cpath := C.CString(path) defer C.free(unsafe.Pointer(cpath)) ret, err := C.my_acl_set_file(acl_set_file, cpath, C.ACL_TYPE_DEFAULT, a.a) if ret < 0 { return ...
go
func (a *ACL) SetFileACLDefault(path string) error { acl_set_file, err := getSymbolPointer(a.lib.handle, "acl_set_file") if err != nil { return err } cpath := C.CString(path) defer C.free(unsafe.Pointer(cpath)) ret, err := C.my_acl_set_file(acl_set_file, cpath, C.ACL_TYPE_DEFAULT, a.a) if ret < 0 { return ...
[ "func", "(", "a", "*", "ACL", ")", "SetFileACLDefault", "(", "path", "string", ")", "error", "{", "acl_set_file", ",", "err", ":=", "getSymbolPointer", "(", "a", ".", "lib", ".", "handle", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", ...
// SetFileACLDefault sets the "default" ACL for path.
[ "SetFileACLDefault", "sets", "the", "default", "ACL", "for", "path", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/acl/acl.go#L264-L279
train
rkt/rkt
pkg/acl/acl.go
Valid
func (a *ACL) Valid() error { acl_valid, err := getSymbolPointer(a.lib.handle, "acl_valid") if err != nil { return err } ret, err := C.my_acl_valid(acl_valid, a.a) if ret < 0 { return errwrap.Wrap(errors.New("invalid acl"), err) } return nil }
go
func (a *ACL) Valid() error { acl_valid, err := getSymbolPointer(a.lib.handle, "acl_valid") if err != nil { return err } ret, err := C.my_acl_valid(acl_valid, a.a) if ret < 0 { return errwrap.Wrap(errors.New("invalid acl"), err) } return nil }
[ "func", "(", "a", "*", "ACL", ")", "Valid", "(", ")", "error", "{", "acl_valid", ",", "err", ":=", "getSymbolPointer", "(", "a", ".", "lib", ".", "handle", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "...
// Valid checks whether the ACL is valid.
[ "Valid", "checks", "whether", "the", "ACL", "is", "valid", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/acl/acl.go#L282-L293
train
rkt/rkt
pkg/acl/acl.go
AddBaseEntries
func (a *ACL) AddBaseEntries(path string) error { fi, err := os.Lstat(path) if err != nil { return err } mode := fi.Mode().Perm() var r, w, x bool // set USER_OBJ entry r = mode&userRead == userRead w = mode&userWrite == userWrite x = mode&userExec == userExec if err := a.addBaseEntryFromMode(TagUserObj, r...
go
func (a *ACL) AddBaseEntries(path string) error { fi, err := os.Lstat(path) if err != nil { return err } mode := fi.Mode().Perm() var r, w, x bool // set USER_OBJ entry r = mode&userRead == userRead w = mode&userWrite == userWrite x = mode&userExec == userExec if err := a.addBaseEntryFromMode(TagUserObj, r...
[ "func", "(", "a", "*", "ACL", ")", "AddBaseEntries", "(", "path", "string", ")", "error", "{", "fi", ",", "err", ":=", "os", ".", "Lstat", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "mode", ":=", "f...
// AddBaseEntries adds the base ACL entries from the file permissions.
[ "AddBaseEntries", "adds", "the", "base", "ACL", "entries", "from", "the", "file", "permissions", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/acl/acl.go#L296-L329
train
rkt/rkt
pkg/distribution/appc.go
NewAppc
func NewAppc(u *url.URL) (Distribution, error) { c, err := parseCIMD(u) if err != nil { return nil, fmt.Errorf("cannot parse URI: %q: %v", u.String(), err) } if c.Type != TypeAppc { return nil, fmt.Errorf("wrong distribution type: %q", c.Type) } appcStr := c.Data for n, v := range u.Query() { appcStr += f...
go
func NewAppc(u *url.URL) (Distribution, error) { c, err := parseCIMD(u) if err != nil { return nil, fmt.Errorf("cannot parse URI: %q: %v", u.String(), err) } if c.Type != TypeAppc { return nil, fmt.Errorf("wrong distribution type: %q", c.Type) } appcStr := c.Data for n, v := range u.Query() { appcStr += f...
[ "func", "NewAppc", "(", "u", "*", "url", ".", "URL", ")", "(", "Distribution", ",", "error", ")", "{", "c", ",", "err", ":=", "parseCIMD", "(", "u", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\""...
// NewAppc returns an Appc distribution from an Appc distribution URI
[ "NewAppc", "returns", "an", "Appc", "distribution", "from", "an", "Appc", "distribution", "URI" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/distribution/appc.go#L52-L71
train
rkt/rkt
pkg/distribution/appc.go
NewAppcFromApp
func NewAppcFromApp(app *discovery.App) Distribution { rawuri := NewCIMDString(TypeAppc, distAppcVersion, url.QueryEscape(app.Name.String())) var version string labels := types.Labels{} for n, v := range app.Labels { if n == "version" { version = v } labels = append(labels, types.Label{Name: n, Value: v}...
go
func NewAppcFromApp(app *discovery.App) Distribution { rawuri := NewCIMDString(TypeAppc, distAppcVersion, url.QueryEscape(app.Name.String())) var version string labels := types.Labels{} for n, v := range app.Labels { if n == "version" { version = v } labels = append(labels, types.Label{Name: n, Value: v}...
[ "func", "NewAppcFromApp", "(", "app", "*", "discovery", ".", "App", ")", "Distribution", "{", "rawuri", ":=", "NewCIMDString", "(", "TypeAppc", ",", "distAppcVersion", ",", "url", ".", "QueryEscape", "(", "app", ".", "Name", ".", "String", "(", ")", ")", ...
// NewAppcFromApp returns an Appc distribution from an appc App discovery string
[ "NewAppcFromApp", "returns", "an", "Appc", "distribution", "from", "an", "appc", "App", "discovery", "string" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/distribution/appc.go#L74-L121
train
rkt/rkt
pkg/sys/sys.go
CloseOnExec
func CloseOnExec(fd int, set bool) error { flag := uintptr(0) if set { flag = syscall.FD_CLOEXEC } _, _, err := syscall.RawSyscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_SETFD, flag) if err != 0 { return syscall.Errno(err) } return nil }
go
func CloseOnExec(fd int, set bool) error { flag := uintptr(0) if set { flag = syscall.FD_CLOEXEC } _, _, err := syscall.RawSyscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_SETFD, flag) if err != 0 { return syscall.Errno(err) } return nil }
[ "func", "CloseOnExec", "(", "fd", "int", ",", "set", "bool", ")", "error", "{", "flag", ":=", "uintptr", "(", "0", ")", "\n", "if", "set", "{", "flag", "=", "syscall", ".", "FD_CLOEXEC", "\n", "}", "\n", "_", ",", "_", ",", "err", ":=", "syscall"...
// CloseOnExec sets or clears FD_CLOEXEC flag on a file descriptor
[ "CloseOnExec", "sets", "or", "clears", "FD_CLOEXEC", "flag", "on", "a", "file", "descriptor" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/sys/sys.go#L22-L32
train
rkt/rkt
common/cgroup/v2/cgroup.go
GetEnabledControllers
func GetEnabledControllers() ([]string, error) { controllersFile, err := os.Open("/sys/fs/cgroup/cgroup.controllers") if err != nil { return nil, err } defer controllersFile.Close() sc := bufio.NewScanner(controllersFile) sc.Scan() if err := sc.Err(); err != nil { return nil, err } return strings.Split(...
go
func GetEnabledControllers() ([]string, error) { controllersFile, err := os.Open("/sys/fs/cgroup/cgroup.controllers") if err != nil { return nil, err } defer controllersFile.Close() sc := bufio.NewScanner(controllersFile) sc.Scan() if err := sc.Err(); err != nil { return nil, err } return strings.Split(...
[ "func", "GetEnabledControllers", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "controllersFile", ",", "err", ":=", "os", ".", "Open", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", ...
// GetEnabledControllers returns a list of enabled cgroup controllers
[ "GetEnabledControllers", "returns", "a", "list", "of", "enabled", "cgroup", "controllers" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/cgroup/v2/cgroup.go#L30-L45
train
rkt/rkt
tools/depsgen/globcmd.go
globGetArgs
func globGetArgs(args []string) globArgs { f, target := standardFlags(globCmd) suffix := f.String("suffix", "", "File suffix (example: .go)") globbingMode := f.String("glob-mode", "all", "Which files to glob (normal, dot-files, all [default])") filelist := f.String("filelist", "", "Read all the files from this file...
go
func globGetArgs(args []string) globArgs { f, target := standardFlags(globCmd) suffix := f.String("suffix", "", "File suffix (example: .go)") globbingMode := f.String("glob-mode", "all", "Which files to glob (normal, dot-files, all [default])") filelist := f.String("filelist", "", "Read all the files from this file...
[ "func", "globGetArgs", "(", "args", "[", "]", "string", ")", "globArgs", "{", "f", ",", "target", ":=", "standardFlags", "(", "globCmd", ")", "\n", "suffix", ":=", "f", ".", "String", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", ...
// globGetArgs parses given parameters and returns a target, a suffix // and a list of files.
[ "globGetArgs", "parses", "given", "parameters", "and", "returns", "a", "target", "a", "suffix", "and", "a", "list", "of", "files", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/tools/depsgen/globcmd.go#L76-L103
train
rkt/rkt
tools/depsgen/globcmd.go
globGetMakeFunction
func globGetMakeFunction(files []string, suffix string, mode globMode) string { dirs := map[string]struct{}{} for _, file := range files { dirs[filepath.Dir(file)] = struct{}{} } makeWildcards := make([]string, 0, len(dirs)) wildcard := globGetMakeSnippet(mode) for dir := range dirs { str := replacePlaceholde...
go
func globGetMakeFunction(files []string, suffix string, mode globMode) string { dirs := map[string]struct{}{} for _, file := range files { dirs[filepath.Dir(file)] = struct{}{} } makeWildcards := make([]string, 0, len(dirs)) wildcard := globGetMakeSnippet(mode) for dir := range dirs { str := replacePlaceholde...
[ "func", "globGetMakeFunction", "(", "files", "[", "]", "string", ",", "suffix", "string", ",", "mode", "globMode", ")", "string", "{", "dirs", ":=", "map", "[", "string", "]", "struct", "{", "}", "{", "}", "\n", "for", "_", ",", "file", ":=", "range"...
// globGetMakeFunction returns a make snippet which calls wildcard // function in all directories where given files are and with a given // suffix.
[ "globGetMakeFunction", "returns", "a", "make", "snippet", "which", "calls", "wildcard", "function", "in", "all", "directories", "where", "given", "files", "are", "and", "with", "a", "given", "suffix", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/tools/depsgen/globcmd.go#L143-L155
train
rkt/rkt
pkg/pod/wait.go
WaitFinished
func (p *Pod) WaitFinished(ctx context.Context) error { f := func() bool { switch err := p.TrySharedLock(); err { case nil: // the pod is now locked successfully, hence one of the running phases passed. // continue with unlocking the pod immediately below. case lock.ErrLocked: // pod is still locked, he...
go
func (p *Pod) WaitFinished(ctx context.Context) error { f := func() bool { switch err := p.TrySharedLock(); err { case nil: // the pod is now locked successfully, hence one of the running phases passed. // continue with unlocking the pod immediately below. case lock.ErrLocked: // pod is still locked, he...
[ "func", "(", "p", "*", "Pod", ")", "WaitFinished", "(", "ctx", "context", ".", "Context", ")", "error", "{", "f", ":=", "func", "(", ")", "bool", "{", "switch", "err", ":=", "p", ".", "TrySharedLock", "(", ")", ";", "err", "{", "case", "nil", ":"...
// WaitFinished waits for a pod to finish by polling every 100 milliseconds // or until the given context is cancelled. This method refreshes the pod state. // It is the caller's responsibility to determine the actual terminal state.
[ "WaitFinished", "waits", "for", "a", "pod", "to", "finish", "by", "polling", "every", "100", "milliseconds", "or", "until", "the", "given", "context", "is", "cancelled", ".", "This", "method", "refreshes", "the", "pod", "state", ".", "It", "is", "the", "ca...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/pod/wait.go#L28-L61
train
rkt/rkt
pkg/pod/wait.go
WaitReady
func (p *Pod) WaitReady(ctx context.Context) error { f := func() bool { if err := p.refreshState(); err != nil { return false } return p.IsSupervisorReady() } return retry(ctx, f, 100*time.Millisecond) }
go
func (p *Pod) WaitReady(ctx context.Context) error { f := func() bool { if err := p.refreshState(); err != nil { return false } return p.IsSupervisorReady() } return retry(ctx, f, 100*time.Millisecond) }
[ "func", "(", "p", "*", "Pod", ")", "WaitReady", "(", "ctx", "context", ".", "Context", ")", "error", "{", "f", ":=", "func", "(", ")", "bool", "{", "if", "err", ":=", "p", ".", "refreshState", "(", ")", ";", "err", "!=", "nil", "{", "return", "...
// WaitReady blocks until the pod is ready by polling the readiness state every 100 milliseconds // or until the given context is cancelled. This method refreshes the pod state.
[ "WaitReady", "blocks", "until", "the", "pod", "is", "ready", "by", "polling", "the", "readiness", "state", "every", "100", "milliseconds", "or", "until", "the", "given", "context", "is", "cancelled", ".", "This", "method", "refreshes", "the", "pod", "state", ...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/pod/wait.go#L65-L75
train
rkt/rkt
pkg/pod/wait.go
retry
func retry(ctx context.Context, f func() bool, delay time.Duration) error { if f() { return nil } ticker := time.NewTicker(delay) errChan := make(chan error) go func() { defer close(errChan) for { select { case <-ctx.Done(): errChan <- ctx.Err() return case <-ticker.C: if f() { r...
go
func retry(ctx context.Context, f func() bool, delay time.Duration) error { if f() { return nil } ticker := time.NewTicker(delay) errChan := make(chan error) go func() { defer close(errChan) for { select { case <-ctx.Done(): errChan <- ctx.Err() return case <-ticker.C: if f() { r...
[ "func", "retry", "(", "ctx", "context", ".", "Context", ",", "f", "func", "(", ")", "bool", ",", "delay", "time", ".", "Duration", ")", "error", "{", "if", "f", "(", ")", "{", "return", "nil", "\n", "}", "\n\n", "ticker", ":=", "time", ".", "NewT...
// retry calls function f indefinitely with the given delay between invocations // until f returns true or the given context is cancelled. // It returns immediately without delay in case function f immediately returns true.
[ "retry", "calls", "function", "f", "indefinitely", "with", "the", "given", "delay", "between", "invocations", "until", "f", "returns", "true", "or", "the", "given", "context", "is", "cancelled", ".", "It", "returns", "immediately", "without", "delay", "in", "c...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/pod/wait.go#L80-L105
train
rkt/rkt
pkg/fileutil/fileutil.go
DirSize
func DirSize(path string) (int64, error) { seenInode := make(map[uint64]struct{}) if _, err := os.Stat(path); err == nil { var sz int64 err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error { if hasHardLinks(info) { ino := getInode(info) if _, ok := seenInode[ino]; !ok { ...
go
func DirSize(path string) (int64, error) { seenInode := make(map[uint64]struct{}) if _, err := os.Stat(path); err == nil { var sz int64 err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error { if hasHardLinks(info) { ino := getInode(info) if _, ok := seenInode[ino]; !ok { ...
[ "func", "DirSize", "(", "path", "string", ")", "(", "int64", ",", "error", ")", "{", "seenInode", ":=", "make", "(", "map", "[", "uint64", "]", "struct", "{", "}", ")", "\n\n", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", "...
// DirSize takes a path and returns its size in bytes
[ "DirSize", "takes", "a", "path", "and", "returns", "its", "size", "in", "bytes" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/fileutil/fileutil.go#L208-L229
train
rkt/rkt
pkg/fileutil/fileutil.go
IsDeviceNode
func IsDeviceNode(path string) bool { d, err := os.Lstat(path) if err == nil { m := d.Mode() return m&os.ModeDevice == os.ModeDevice } return false }
go
func IsDeviceNode(path string) bool { d, err := os.Lstat(path) if err == nil { m := d.Mode() return m&os.ModeDevice == os.ModeDevice } return false }
[ "func", "IsDeviceNode", "(", "path", "string", ")", "bool", "{", "d", ",", "err", ":=", "os", ".", "Lstat", "(", "path", ")", "\n", "if", "err", "==", "nil", "{", "m", ":=", "d", ".", "Mode", "(", ")", "\n", "return", "m", "&", "os", ".", "Mo...
// IsDeviceNode checks if the given path points to a block or char device. // It doesn't follow symlinks.
[ "IsDeviceNode", "checks", "if", "the", "given", "path", "points", "to", "a", "block", "or", "char", "device", ".", "It", "doesn", "t", "follow", "symlinks", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/fileutil/fileutil.go#L244-L251
train
rkt/rkt
stage1/init/kvm/hypervisor/hvlkvm/lkvm_driver.go
StartCmd
func StartCmd(wdPath, uuid, kernelPath string, nds []kvm.NetDescriber, cpu, mem int64, debug bool) []string { machineID := strings.Replace(uuid, "-", "", -1) driverConfiguration := hypervisor.KvmHypervisor{ Bin: "./lkvm", KernelParams: []string{ "systemd.default_standard_error=journal+console", "systemd.def...
go
func StartCmd(wdPath, uuid, kernelPath string, nds []kvm.NetDescriber, cpu, mem int64, debug bool) []string { machineID := strings.Replace(uuid, "-", "", -1) driverConfiguration := hypervisor.KvmHypervisor{ Bin: "./lkvm", KernelParams: []string{ "systemd.default_standard_error=journal+console", "systemd.def...
[ "func", "StartCmd", "(", "wdPath", ",", "uuid", ",", "kernelPath", "string", ",", "nds", "[", "]", "kvm", ".", "NetDescriber", ",", "cpu", ",", "mem", "int64", ",", "debug", "bool", ")", "[", "]", "string", "{", "machineID", ":=", "strings", ".", "Re...
// StartCmd takes path to stage1, UUID of the pod, path to kernel, network // describers, memory in megabytes and quantity of cpus and prepares command // line to run LKVM process
[ "StartCmd", "takes", "path", "to", "stage1", "UUID", "of", "the", "pod", "path", "to", "kernel", "network", "describers", "memory", "in", "megabytes", "and", "quantity", "of", "cpus", "and", "prepares", "command", "line", "to", "run", "LKVM", "process" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/hypervisor/hvlkvm/lkvm_driver.go#L30-L56
train
rkt/rkt
stage1/init/kvm/hypervisor/hvlkvm/lkvm_driver.go
kvmNetArgs
func kvmNetArgs(nds []kvm.NetDescriber) []string { var lkvmArgs []string for _, nd := range nds { lkvmArgs = append(lkvmArgs, "--network") lkvmArgs = append( lkvmArgs, fmt.Sprintf("mode=tap,tapif=%s,host_ip=%s,guest_ip=%s", nd.IfName(), nd.Gateway(), nd.GuestIP()), ) } return lkvmArgs }
go
func kvmNetArgs(nds []kvm.NetDescriber) []string { var lkvmArgs []string for _, nd := range nds { lkvmArgs = append(lkvmArgs, "--network") lkvmArgs = append( lkvmArgs, fmt.Sprintf("mode=tap,tapif=%s,host_ip=%s,guest_ip=%s", nd.IfName(), nd.Gateway(), nd.GuestIP()), ) } return lkvmArgs }
[ "func", "kvmNetArgs", "(", "nds", "[", "]", "kvm", ".", "NetDescriber", ")", "[", "]", "string", "{", "var", "lkvmArgs", "[", "]", "string", "\n\n", "for", "_", ",", "nd", ":=", "range", "nds", "{", "lkvmArgs", "=", "append", "(", "lkvmArgs", ",", ...
// kvmNetArgs 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
[ "kvmNetArgs", "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/hypervisor/hvlkvm/lkvm_driver.go#L62-L74
train
rkt/rkt
pkg/flag/optionlist.go
NewOptionList
func NewOptionList(permissibleOptions []string, defaultOptions string) (*OptionList, error) { permissible := make(map[string]struct{}) ol := &OptionList{ allOptions: permissibleOptions, permissible: permissible, typeName: "OptionList", } for _, o := range permissibleOptions { ol.permissible[o] = struct...
go
func NewOptionList(permissibleOptions []string, defaultOptions string) (*OptionList, error) { permissible := make(map[string]struct{}) ol := &OptionList{ allOptions: permissibleOptions, permissible: permissible, typeName: "OptionList", } for _, o := range permissibleOptions { ol.permissible[o] = struct...
[ "func", "NewOptionList", "(", "permissibleOptions", "[", "]", "string", ",", "defaultOptions", "string", ")", "(", "*", "OptionList", ",", "error", ")", "{", "permissible", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ")", "\n", "ol"...
// NewOptionList initializes an OptionList. PermissibleOptions is the complete // set of allowable options. It will set all options specified in defaultOptions // as provided; they will all be cleared if this flag is passed in the CLI
[ "NewOptionList", "initializes", "an", "OptionList", ".", "PermissibleOptions", "is", "the", "complete", "set", "of", "allowable", "options", ".", "It", "will", "set", "all", "options", "specified", "in", "defaultOptions", "as", "provided", ";", "they", "will", "...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/flag/optionlist.go#L38-L55
train
rkt/rkt
rkt/image_gc.go
gcTreeStore
func gcTreeStore(ts *treestore.Store) error { // Take an exclusive lock to block other pods being created. // This is needed to avoid races between the below steps (getting the // list of referenced treeStoreIDs, getting the list of treeStoreIDs // from the store, removal of unreferenced treeStoreIDs) and new // p...
go
func gcTreeStore(ts *treestore.Store) error { // Take an exclusive lock to block other pods being created. // This is needed to avoid races between the below steps (getting the // list of referenced treeStoreIDs, getting the list of treeStoreIDs // from the store, removal of unreferenced treeStoreIDs) and new // p...
[ "func", "gcTreeStore", "(", "ts", "*", "treestore", ".", "Store", ")", "error", "{", "// Take an exclusive lock to block other pods being created.", "// This is needed to avoid races between the below steps (getting the", "// list of referenced treeStoreIDs, getting the list of treeStoreID...
// gcTreeStore removes all treeStoreIDs not referenced by any non garbage // collected pod from the store.
[ "gcTreeStore", "removes", "all", "treeStoreIDs", "not", "referenced", "by", "any", "non", "garbage", "collected", "pod", "from", "the", "store", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image_gc.go#L82-L111
train
rkt/rkt
rkt/image_gc.go
getRunningImages
func getRunningImages() ([]string, error) { var runningImages []string var errors []error err := pkgPod.WalkPods(getDataDir(), pkgPod.IncludeMostDirs, func(p *pkgPod.Pod) { var pm schema.PodManifest if p.State() != pkgPod.Running { return } if !p.PodManifestAvailable() { return } _, manifest, err :...
go
func getRunningImages() ([]string, error) { var runningImages []string var errors []error err := pkgPod.WalkPods(getDataDir(), pkgPod.IncludeMostDirs, func(p *pkgPod.Pod) { var pm schema.PodManifest if p.State() != pkgPod.Running { return } if !p.PodManifestAvailable() { return } _, manifest, err :...
[ "func", "getRunningImages", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "runningImages", "[", "]", "string", "\n", "var", "errors", "[", "]", "error", "\n", "err", ":=", "pkgPod", ".", "WalkPods", "(", "getDataDir", "(", ")", ",...
// getRunningImages will return the image IDs used to create any of the // currently running pods
[ "getRunningImages", "will", "return", "the", "image", "IDs", "used", "to", "create", "any", "of", "the", "currently", "running", "pods" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image_gc.go#L167-L195
train
rkt/rkt
stage0/run.go
deduplicateMPs
func deduplicateMPs(mounts []schema.Mount) []schema.Mount { var res []schema.Mount seen := make(map[string]struct{}) for _, m := range mounts { cleanPath := path.Clean(m.Path) if _, ok := seen[cleanPath]; !ok { res = append(res, m) seen[cleanPath] = struct{}{} } } return res }
go
func deduplicateMPs(mounts []schema.Mount) []schema.Mount { var res []schema.Mount seen := make(map[string]struct{}) for _, m := range mounts { cleanPath := path.Clean(m.Path) if _, ok := seen[cleanPath]; !ok { res = append(res, m) seen[cleanPath] = struct{}{} } } return res }
[ "func", "deduplicateMPs", "(", "mounts", "[", "]", "schema", ".", "Mount", ")", "[", "]", "schema", ".", "Mount", "{", "var", "res", "[", "]", "schema", ".", "Mount", "\n", "seen", ":=", "make", "(", "map", "[", "string", "]", "struct", "{", "}", ...
// deduplicateMPs removes Mounts with duplicated paths. If there's more than // one Mount with the same path, it keeps the first one encountered.
[ "deduplicateMPs", "removes", "Mounts", "with", "duplicated", "paths", ".", "If", "there", "s", "more", "than", "one", "Mount", "with", "the", "same", "path", "it", "keeps", "the", "first", "one", "encountered", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/run.go#L161-L172
train
rkt/rkt
stage0/run.go
MergeMounts
func MergeMounts(mounts []schema.Mount, appMounts []schema.Mount) []schema.Mount { ml := append(appMounts, mounts...) return deduplicateMPs(ml) }
go
func MergeMounts(mounts []schema.Mount, appMounts []schema.Mount) []schema.Mount { ml := append(appMounts, mounts...) return deduplicateMPs(ml) }
[ "func", "MergeMounts", "(", "mounts", "[", "]", "schema", ".", "Mount", ",", "appMounts", "[", "]", "schema", ".", "Mount", ")", "[", "]", "schema", ".", "Mount", "{", "ml", ":=", "append", "(", "appMounts", ",", "mounts", "...", ")", "\n", "return",...
// MergeMounts combines the global and per-app mount slices
[ "MergeMounts", "combines", "the", "global", "and", "per", "-", "app", "mount", "slices" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/run.go#L175-L178
train
rkt/rkt
stage0/run.go
Prepare
func Prepare(cfg PrepareConfig, dir string, uuid *types.UUID) error { if err := os.MkdirAll(common.AppsInfoPath(dir), common.DefaultRegularDirPerm); err != nil { return errwrap.Wrap(errors.New("error creating apps info directory"), err) } debug("Preparing stage1") if err := prepareStage1Image(cfg, dir); err != ni...
go
func Prepare(cfg PrepareConfig, dir string, uuid *types.UUID) error { if err := os.MkdirAll(common.AppsInfoPath(dir), common.DefaultRegularDirPerm); err != nil { return errwrap.Wrap(errors.New("error creating apps info directory"), err) } debug("Preparing stage1") if err := prepareStage1Image(cfg, dir); err != ni...
[ "func", "Prepare", "(", "cfg", "PrepareConfig", ",", "dir", "string", ",", "uuid", "*", "types", ".", "UUID", ")", "error", "{", "if", "err", ":=", "os", ".", "MkdirAll", "(", "common", ".", "AppsInfoPath", "(", "dir", ")", ",", "common", ".", "Defau...
// Prepare sets up a pod based on the given config.
[ "Prepare", "sets", "up", "a", "pod", "based", "on", "the", "given", "config", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/run.go#L408-L468
train
rkt/rkt
stage0/run.go
setupAppImage
func setupAppImage(cfg RunConfig, appName types.ACName, img types.Hash, cdir string, useOverlay bool) error { ad := common.AppPath(cdir, appName) if useOverlay { err := os.MkdirAll(ad, common.DefaultRegularDirPerm) if err != nil { return errwrap.Wrap(errors.New("error creating image directory"), err) } tre...
go
func setupAppImage(cfg RunConfig, appName types.ACName, img types.Hash, cdir string, useOverlay bool) error { ad := common.AppPath(cdir, appName) if useOverlay { err := os.MkdirAll(ad, common.DefaultRegularDirPerm) if err != nil { return errwrap.Wrap(errors.New("error creating image directory"), err) } tre...
[ "func", "setupAppImage", "(", "cfg", "RunConfig", ",", "appName", "types", ".", "ACName", ",", "img", "types", ".", "Hash", ",", "cdir", "string", ",", "useOverlay", "bool", ")", "error", "{", "ad", ":=", "common", ".", "AppPath", "(", "cdir", ",", "ap...
// setupAppImage mounts the overlay filesystem for the app image that // corresponds to the given hash if useOverlay is true. // It also creates an mtab file in the application's rootfs if one is not // present.
[ "setupAppImage", "mounts", "the", "overlay", "filesystem", "for", "the", "app", "image", "that", "corresponds", "to", "the", "given", "hash", "if", "useOverlay", "is", "true", ".", "It", "also", "creates", "an", "mtab", "file", "in", "the", "application", "s...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/run.go#L773-L792
train
rkt/rkt
stage0/run.go
prepareStage1Image
func prepareStage1Image(cfg PrepareConfig, cdir string) error { s1 := common.Stage1ImagePath(cdir) if err := os.MkdirAll(s1, common.DefaultRegularDirPerm); err != nil { return errwrap.Wrap(errors.New("error creating stage1 directory"), err) } treeStoreID, _, err := cfg.TreeStore.Render(cfg.Stage1Image.String(), ...
go
func prepareStage1Image(cfg PrepareConfig, cdir string) error { s1 := common.Stage1ImagePath(cdir) if err := os.MkdirAll(s1, common.DefaultRegularDirPerm); err != nil { return errwrap.Wrap(errors.New("error creating stage1 directory"), err) } treeStoreID, _, err := cfg.TreeStore.Render(cfg.Stage1Image.String(), ...
[ "func", "prepareStage1Image", "(", "cfg", "PrepareConfig", ",", "cdir", "string", ")", "error", "{", "s1", ":=", "common", ".", "Stage1ImagePath", "(", "cdir", ")", "\n", "if", "err", ":=", "os", ".", "MkdirAll", "(", "s1", ",", "common", ".", "DefaultRe...
// prepareStage1Image renders and verifies tree cache of the given hash // when using overlay. // When useOverlay is false, it attempts to render and expand the stage1.
[ "prepareStage1Image", "renders", "and", "verifies", "tree", "cache", "of", "the", "given", "hash", "when", "using", "overlay", ".", "When", "useOverlay", "is", "false", "it", "attempts", "to", "render", "and", "expand", "the", "stage1", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/run.go#L830-L858
train
rkt/rkt
stage0/run.go
setupStage1Image
func setupStage1Image(cfg RunConfig, cdir string, useOverlay bool) error { s1 := common.Stage1ImagePath(cdir) if useOverlay { treeStoreID, err := ioutil.ReadFile(filepath.Join(cdir, common.Stage1TreeStoreIDFilename)) if err != nil { return err } // pass an empty appName if err := overlayRender(cfg, stri...
go
func setupStage1Image(cfg RunConfig, cdir string, useOverlay bool) error { s1 := common.Stage1ImagePath(cdir) if useOverlay { treeStoreID, err := ioutil.ReadFile(filepath.Join(cdir, common.Stage1TreeStoreIDFilename)) if err != nil { return err } // pass an empty appName if err := overlayRender(cfg, stri...
[ "func", "setupStage1Image", "(", "cfg", "RunConfig", ",", "cdir", "string", ",", "useOverlay", "bool", ")", "error", "{", "s1", ":=", "common", ".", "Stage1ImagePath", "(", "cdir", ")", "\n", "if", "useOverlay", "{", "treeStoreID", ",", "err", ":=", "iouti...
// setupStage1Image mounts the overlay filesystem for stage1. // When useOverlay is false it is a noop
[ "setupStage1Image", "mounts", "the", "overlay", "filesystem", "for", "stage1", ".", "When", "useOverlay", "is", "false", "it", "is", "a", "noop" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/run.go#L862-L884
train
rkt/rkt
stage0/run.go
writeManifest
func writeManifest(cfg CommonConfig, img types.Hash, dest string) error { mb, err := cfg.Store.GetImageManifestJSON(img.String()) if err != nil { return err } debug("Writing image manifest") if err := ioutil.WriteFile(filepath.Join(dest, "manifest"), mb, common.DefaultRegularFilePerm); err != nil { return err...
go
func writeManifest(cfg CommonConfig, img types.Hash, dest string) error { mb, err := cfg.Store.GetImageManifestJSON(img.String()) if err != nil { return err } debug("Writing image manifest") if err := ioutil.WriteFile(filepath.Join(dest, "manifest"), mb, common.DefaultRegularFilePerm); err != nil { return err...
[ "func", "writeManifest", "(", "cfg", "CommonConfig", ",", "img", "types", ".", "Hash", ",", "dest", "string", ")", "error", "{", "mb", ",", "err", ":=", "cfg", ".", "Store", ".", "GetImageManifestJSON", "(", "img", ".", "String", "(", ")", ")", "\n", ...
// writeManifest takes an img ID and writes the corresponding manifest in dest
[ "writeManifest", "takes", "an", "img", "ID", "and", "writes", "the", "corresponding", "manifest", "in", "dest" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/run.go#L887-L899
train
rkt/rkt
stage0/run.go
copyAppManifest
func copyAppManifest(cdir string, appName types.ACName, dest string) error { appInfoDir := common.AppInfoPath(cdir, appName) sourceFn := filepath.Join(appInfoDir, "manifest") destFn := filepath.Join(dest, "manifest") if err := fileutil.CopyRegularFile(sourceFn, destFn); err != nil { return errwrap.Wrap(errors.New...
go
func copyAppManifest(cdir string, appName types.ACName, dest string) error { appInfoDir := common.AppInfoPath(cdir, appName) sourceFn := filepath.Join(appInfoDir, "manifest") destFn := filepath.Join(dest, "manifest") if err := fileutil.CopyRegularFile(sourceFn, destFn); err != nil { return errwrap.Wrap(errors.New...
[ "func", "copyAppManifest", "(", "cdir", "string", ",", "appName", "types", ".", "ACName", ",", "dest", "string", ")", "error", "{", "appInfoDir", ":=", "common", ".", "AppInfoPath", "(", "cdir", ",", "appName", ")", "\n", "sourceFn", ":=", "filepath", ".",...
// copyAppManifest copies to saved image manifest for the given appName and // writes it in the dest directory.
[ "copyAppManifest", "copies", "to", "saved", "image", "manifest", "for", "the", "given", "appName", "and", "writes", "it", "in", "the", "dest", "directory", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/run.go#L903-L911
train
rkt/rkt
stage0/run.go
overlayRender
func overlayRender(cfg RunConfig, treeStoreID string, cdir string, dest string, appName string) error { cachedTreePath := cfg.TreeStore.GetRootFS(treeStoreID) mc, err := prepareOverlay(cachedTreePath, treeStoreID, cdir, dest, appName, cfg.MountLabel, cfg.RktGid, common.DefaultRegularDirPerm) if err != nil { retu...
go
func overlayRender(cfg RunConfig, treeStoreID string, cdir string, dest string, appName string) error { cachedTreePath := cfg.TreeStore.GetRootFS(treeStoreID) mc, err := prepareOverlay(cachedTreePath, treeStoreID, cdir, dest, appName, cfg.MountLabel, cfg.RktGid, common.DefaultRegularDirPerm) if err != nil { retu...
[ "func", "overlayRender", "(", "cfg", "RunConfig", ",", "treeStoreID", "string", ",", "cdir", "string", ",", "dest", "string", ",", "appName", "string", ")", "error", "{", "cachedTreePath", ":=", "cfg", ".", "TreeStore", ".", "GetRootFS", "(", "treeStoreID", ...
// overlayRender renders the image that corresponds to the given hash using the // overlay filesystem. It mounts an overlay filesystem from the cached tree of // the image as rootfs.
[ "overlayRender", "renders", "the", "image", "that", "corresponds", "to", "the", "given", "hash", "using", "the", "overlay", "filesystem", ".", "It", "mounts", "an", "overlay", "filesystem", "from", "the", "cached", "tree", "of", "the", "image", "as", "rootfs",...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/run.go#L916-L928
train
rkt/rkt
stage0/run.go
prepareOverlay
func prepareOverlay(lower, treeStoreID, cdir, dest, appName, lbl string, gid int, fm os.FileMode) (*overlay.MountCfg, error) { fi, err := os.Stat(lower) if err != nil { return nil, err } imgMode := fi.Mode() dst := path.Join(dest, "rootfs") if err := os.MkdirAll(dst, imgMode); err != nil { return nil, err ...
go
func prepareOverlay(lower, treeStoreID, cdir, dest, appName, lbl string, gid int, fm os.FileMode) (*overlay.MountCfg, error) { fi, err := os.Stat(lower) if err != nil { return nil, err } imgMode := fi.Mode() dst := path.Join(dest, "rootfs") if err := os.MkdirAll(dst, imgMode); err != nil { return nil, err ...
[ "func", "prepareOverlay", "(", "lower", ",", "treeStoreID", ",", "cdir", ",", "dest", ",", "appName", ",", "lbl", "string", ",", "gid", "int", ",", "fm", "os", ".", "FileMode", ")", "(", "*", "overlay", ".", "MountCfg", ",", "error", ")", "{", "fi", ...
// prepateOverlay sets up the needed directories, files and permissions for the // overlay-rendered pods
[ "prepateOverlay", "sets", "up", "the", "needed", "directories", "files", "and", "permissions", "for", "the", "overlay", "-", "rendered", "pods" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/run.go#L932-L987
train
rkt/rkt
store/treestore/tree.go
NewStore
func NewStore(dir string, store *imagestore.Store) (*Store, error) { // TODO(sgotti) backward compatibility with the current tree store paths. Needs a migration path to better paths. ts := &Store{dir: filepath.Join(dir, "tree"), store: store} ts.lockDir = filepath.Join(dir, "treestorelocks") if err := os.MkdirAll(...
go
func NewStore(dir string, store *imagestore.Store) (*Store, error) { // TODO(sgotti) backward compatibility with the current tree store paths. Needs a migration path to better paths. ts := &Store{dir: filepath.Join(dir, "tree"), store: store} ts.lockDir = filepath.Join(dir, "treestorelocks") if err := os.MkdirAll(...
[ "func", "NewStore", "(", "dir", "string", ",", "store", "*", "imagestore", ".", "Store", ")", "(", "*", "Store", ",", "error", ")", "{", "// TODO(sgotti) backward compatibility with the current tree store paths. Needs a migration path to better paths.", "ts", ":=", "&", ...
// NewStore creates a Store for managing filesystem trees, including the dependency graph resolution of the underlying image layers.
[ "NewStore", "creates", "a", "Store", "for", "managing", "filesystem", "trees", "including", "the", "dependency", "graph", "resolution", "of", "the", "underlying", "image", "layers", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/treestore/tree.go#L73-L82
train
rkt/rkt
store/treestore/tree.go
GetID
func (ts *Store) GetID(key string) (string, error) { hash, err := types.NewHash(key) if err != nil { return "", err } images, err := acirenderer.CreateDepListFromImageID(*hash, ts.store) if err != nil { return "", err } var keys []string for _, image := range images { keys = append(keys, image.Key) } i...
go
func (ts *Store) GetID(key string) (string, error) { hash, err := types.NewHash(key) if err != nil { return "", err } images, err := acirenderer.CreateDepListFromImageID(*hash, ts.store) if err != nil { return "", err } var keys []string for _, image := range images { keys = append(keys, image.Key) } i...
[ "func", "(", "ts", "*", "Store", ")", "GetID", "(", "key", "string", ")", "(", "string", ",", "error", ")", "{", "hash", ",", "err", ":=", "types", ".", "NewHash", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",",...
// GetID calculates the treestore ID for the given image key. // The treeStoreID is computed as an hash of the flattened dependency tree // image keys. In this way the ID may change for the same key if the image's // dependencies change.
[ "GetID", "calculates", "the", "treestore", "ID", "for", "the", "given", "image", "key", ".", "The", "treeStoreID", "is", "computed", "as", "an", "hash", "of", "the", "flattened", "dependency", "tree", "image", "keys", ".", "In", "this", "way", "the", "ID",...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/treestore/tree.go#L88-L106
train
rkt/rkt
store/treestore/tree.go
Render
func (ts *Store) Render(key string, rebuild bool) (id string, hash string, err error) { id, err = ts.GetID(key) if err != nil { return "", "", errwrap.Wrap(errors.New("cannot calculate treestore id"), err) } // this lock references the treestore dir for the specified id. treeStoreKeyLock, err := lock.ExclusiveK...
go
func (ts *Store) Render(key string, rebuild bool) (id string, hash string, err error) { id, err = ts.GetID(key) if err != nil { return "", "", errwrap.Wrap(errors.New("cannot calculate treestore id"), err) } // this lock references the treestore dir for the specified id. treeStoreKeyLock, err := lock.ExclusiveK...
[ "func", "(", "ts", "*", "Store", ")", "Render", "(", "key", "string", ",", "rebuild", "bool", ")", "(", "id", "string", ",", "hash", "string", ",", "err", "error", ")", "{", "id", ",", "err", "=", "ts", ".", "GetID", "(", "key", ")", "\n", "if"...
// Render renders a treestore for the given image key if it's not // already fully rendered. // Users of treestore should call s.Render before using it to ensure // that the treestore is completely rendered. // Returns the id and hash of the rendered treestore if it is newly rendered, // and only the id if it is alread...
[ "Render", "renders", "a", "treestore", "for", "the", "given", "image", "key", "if", "it", "s", "not", "already", "fully", "rendered", ".", "Users", "of", "treestore", "should", "call", "s", ".", "Render", "before", "using", "it", "to", "ensure", "that", ...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/treestore/tree.go#L114-L147
train
rkt/rkt
store/treestore/tree.go
Check
func (ts *Store) Check(id string) (string, error) { treeStoreKeyLock, err := lock.SharedKeyLock(ts.lockDir, id) if err != nil { return "", errwrap.Wrap(errors.New("error locking tree store"), err) } defer treeStoreKeyLock.Close() return ts.check(id) }
go
func (ts *Store) Check(id string) (string, error) { treeStoreKeyLock, err := lock.SharedKeyLock(ts.lockDir, id) if err != nil { return "", errwrap.Wrap(errors.New("error locking tree store"), err) } defer treeStoreKeyLock.Close() return ts.check(id) }
[ "func", "(", "ts", "*", "Store", ")", "Check", "(", "id", "string", ")", "(", "string", ",", "error", ")", "{", "treeStoreKeyLock", ",", "err", ":=", "lock", ".", "SharedKeyLock", "(", "ts", ".", "lockDir", ",", "id", ")", "\n", "if", "err", "!=", ...
// Check verifies the treestore consistency for the specified id.
[ "Check", "verifies", "the", "treestore", "consistency", "for", "the", "specified", "id", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/treestore/tree.go#L150-L158
train
rkt/rkt
store/treestore/tree.go
Remove
func (ts *Store) Remove(id string) error { treeStoreKeyLock, err := lock.ExclusiveKeyLock(ts.lockDir, id) if err != nil { return errwrap.Wrap(errors.New("error locking tree store"), err) } defer treeStoreKeyLock.Close() if err := ts.remove(id); err != nil { return errwrap.Wrap(errors.New("error removing the t...
go
func (ts *Store) Remove(id string) error { treeStoreKeyLock, err := lock.ExclusiveKeyLock(ts.lockDir, id) if err != nil { return errwrap.Wrap(errors.New("error locking tree store"), err) } defer treeStoreKeyLock.Close() if err := ts.remove(id); err != nil { return errwrap.Wrap(errors.New("error removing the t...
[ "func", "(", "ts", "*", "Store", ")", "Remove", "(", "id", "string", ")", "error", "{", "treeStoreKeyLock", ",", "err", ":=", "lock", ".", "ExclusiveKeyLock", "(", "ts", ".", "lockDir", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// Remove removes the rendered image in tree store with the given id.
[ "Remove", "removes", "the", "rendered", "image", "in", "tree", "store", "with", "the", "given", "id", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/treestore/tree.go#L161-L173
train
rkt/rkt
store/treestore/tree.go
remove
func (ts *Store) remove(id string) error { treepath := ts.GetPath(id) // If tree path doesn't exist we're done _, err := os.Stat(treepath) if err != nil && os.IsNotExist(err) { return nil } if err != nil { return errwrap.Wrap(errors.New("failed to open tree store directory"), err) } renderedFilePath := fil...
go
func (ts *Store) remove(id string) error { treepath := ts.GetPath(id) // If tree path doesn't exist we're done _, err := os.Stat(treepath) if err != nil && os.IsNotExist(err) { return nil } if err != nil { return errwrap.Wrap(errors.New("failed to open tree store directory"), err) } renderedFilePath := fil...
[ "func", "(", "ts", "*", "Store", ")", "remove", "(", "id", "string", ")", "error", "{", "treepath", ":=", "ts", ".", "GetPath", "(", "id", ")", "\n", "// If tree path doesn't exist we're done", "_", ",", "err", ":=", "os", ".", "Stat", "(", "treepath", ...
// remove cleans the directory for the provided id
[ "remove", "cleans", "the", "directory", "for", "the", "provided", "id" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/treestore/tree.go#L270-L316
train
rkt/rkt
store/treestore/tree.go
IsRendered
func (ts *Store) IsRendered(id string) (bool, error) { // if the "rendered" flag file exists, assume that the store is already // fully rendered. treepath := ts.GetPath(id) _, err := os.Stat(filepath.Join(treepath, renderedfilename)) if os.IsNotExist(err) { return false, nil } if err != nil { return false, e...
go
func (ts *Store) IsRendered(id string) (bool, error) { // if the "rendered" flag file exists, assume that the store is already // fully rendered. treepath := ts.GetPath(id) _, err := os.Stat(filepath.Join(treepath, renderedfilename)) if os.IsNotExist(err) { return false, nil } if err != nil { return false, e...
[ "func", "(", "ts", "*", "Store", ")", "IsRendered", "(", "id", "string", ")", "(", "bool", ",", "error", ")", "{", "// if the \"rendered\" flag file exists, assume that the store is already", "// fully rendered.", "treepath", ":=", "ts", ".", "GetPath", "(", "id", ...
// IsRendered checks if the tree store with the provided id is fully rendered
[ "IsRendered", "checks", "if", "the", "tree", "store", "with", "the", "provided", "id", "is", "fully", "rendered" ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/treestore/tree.go#L319-L331
train
rkt/rkt
store/treestore/tree.go
Hash
func (ts *Store) Hash(id string) (string, error) { treepath := ts.GetPath(id) hash := sha512.New() iw := newHashWriter(hash) err := filepath.Walk(treepath, buildWalker(treepath, iw)) if err != nil { return "", errwrap.Wrap(errors.New("error walking rootfs"), err) } hashstring := hashToKey(hash) return hash...
go
func (ts *Store) Hash(id string) (string, error) { treepath := ts.GetPath(id) hash := sha512.New() iw := newHashWriter(hash) err := filepath.Walk(treepath, buildWalker(treepath, iw)) if err != nil { return "", errwrap.Wrap(errors.New("error walking rootfs"), err) } hashstring := hashToKey(hash) return hash...
[ "func", "(", "ts", "*", "Store", ")", "Hash", "(", "id", "string", ")", "(", "string", ",", "error", ")", "{", "treepath", ":=", "ts", ".", "GetPath", "(", "id", ")", "\n\n", "hash", ":=", "sha512", ".", "New", "(", ")", "\n", "iw", ":=", "newH...
// Hash calculates an hash of the rendered ACI. It uses the same functions // used to create a tar but instead of writing the full archive is just // computes the sha512 sum of the file infos and contents.
[ "Hash", "calculates", "an", "hash", "of", "the", "rendered", "ACI", ".", "It", "uses", "the", "same", "functions", "used", "to", "create", "a", "tar", "but", "instead", "of", "writing", "the", "full", "archive", "is", "just", "computes", "the", "sha512", ...
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/treestore/tree.go#L350-L363
train
rkt/rkt
store/treestore/tree.go
check
func (ts *Store) check(id string) (string, error) { treepath := ts.GetPath(id) hash, err := ioutil.ReadFile(filepath.Join(treepath, hashfilename)) if err != nil { return "", errwrap.Wrap(ErrReadHashfile, err) } curhash, err := ts.Hash(id) if err != nil { return "", errwrap.Wrap(errors.New("cannot calculate tr...
go
func (ts *Store) check(id string) (string, error) { treepath := ts.GetPath(id) hash, err := ioutil.ReadFile(filepath.Join(treepath, hashfilename)) if err != nil { return "", errwrap.Wrap(ErrReadHashfile, err) } curhash, err := ts.Hash(id) if err != nil { return "", errwrap.Wrap(errors.New("cannot calculate tr...
[ "func", "(", "ts", "*", "Store", ")", "check", "(", "id", "string", ")", "(", "string", ",", "error", ")", "{", "treepath", ":=", "ts", ".", "GetPath", "(", "id", ")", "\n", "hash", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filepath", "....
// check calculates the actual rendered ACI's hash and verifies that it matches // the saved value. Returns the calculated hash.
[ "check", "calculates", "the", "actual", "rendered", "ACI", "s", "hash", "and", "verifies", "that", "it", "matches", "the", "saved", "value", ".", "Returns", "the", "calculated", "hash", "." ]
0c8765619cae3391a9ffa12c8dbd12ba7a475eb8
https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/treestore/tree.go#L367-L381
train