repo stringlengths 5 67 | sha stringlengths 40 40 | path stringlengths 4 234 | url stringlengths 85 339 | language stringclasses 6
values | split stringclasses 3
values | doc stringlengths 3 51.2k | sign stringlengths 5 8.01k | problem stringlengths 13 51.2k | output stringlengths 0 3.87M |
|---|---|---|---|---|---|---|---|---|---|
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | tools/depsgen/main.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/tools/depsgen/main.go#L47-L54 | go | train | // getAllDepTypes returns a sorted list of names of all dep type
// commands. | func getAllDepTypes() []string | // getAllDepTypes returns a sorted list of names of all dep type
// commands.
func getAllDepTypes() []string | {
depTypes := make([]string, 0, len(cmds))
for depType := range cmds {
depTypes = append(depTypes, depType)
}
sort.Strings(depTypes)
return depTypes
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/image/io.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/io.go#L60-L87 | go | train | // getIoProgressReader returns a reader that wraps the HTTP response
// body, so it prints a pretty progress bar when reading data from it. | func getIoProgressReader(label string, res *http.Response) io.Reader | // getIoProgressReader returns a reader that wraps the HTTP response
// body, so it prints a pretty progress bar when reading data from it.
func getIoProgressReader(label string, res *http.Response) io.Reader | {
prefix := "Downloading " + label
fmtBytesSize := 18
barSize := int64(80 - len(prefix) - fmtBytesSize)
bar := ioprogress.DrawTextFormatBarForW(barSize, os.Stderr)
fmtfunc := func(progress, total int64) string {
// Content-Length is set to -1 when unknown.
if total == -1 {
return fmt.Sprintf(
"%s: %v o... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/image/io.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/io.go#L107-L119 | go | train | // Close closes the file and then removes it from disk. No error is
// returned if the file did not exist at the point of removal. | func (f *removeOnClose) Close() error | // Close closes the file and then removes it from disk. No error is
// returned if the file did not exist at the point of removal.
func (f *removeOnClose) Close() error | {
if f == nil || f.File == nil {
return nil
}
name := f.File.Name()
if err := f.File.Close(); err != nil {
return err
}
if err := os.Remove(name); err != nil && !os.IsNotExist(err) {
return err
}
return nil
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/image/io.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/io.go#L124-L149 | go | train | // getTmpROC returns a removeOnClose instance wrapping a temporary
// file provided by the passed store. The actual file name is based on
// a hash of the passed path. | func getTmpROC(s *imagestore.Store, path string) (*removeOnClose, error) | // getTmpROC returns a removeOnClose instance wrapping a temporary
// file provided by the passed store. The actual file name is based on
// a hash of the passed path.
func getTmpROC(s *imagestore.Store, path string) (*removeOnClose, error) | {
h := sha512.New()
h.Write([]byte(path))
pathHash := s.HashToKey(h)
tmp, err := s.TmpNamedFile(pathHash)
if err != nil {
return nil, errwrap.Wrap(errors.New("error setting up temporary file"), err)
}
// let's lock the file to avoid concurrent writes to the temporary file, it
// will go away when removing ... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage0/manifest.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/manifest.go#L50-L66 | go | train | // supportsMutableEnvironment returns whether the given stage1 image supports mutable pod operations.
// It introspects the stage1 manifest and checks the presence of app* entrypoints. | func supportsMutableEnvironment(cdir string) (bool, error) | // supportsMutableEnvironment returns whether the given stage1 image supports mutable pod operations.
// It introspects the stage1 manifest and checks the presence of app* entrypoints.
func supportsMutableEnvironment(cdir string) (bool, error) | {
b, err := ioutil.ReadFile(common.Stage1ManifestPath(cdir))
if err != nil {
return false, errwrap.Wrap(errors.New("error reading pod manifest"), err)
}
s1m := schema.ImageManifest{}
if err := json.Unmarshal(b, &s1m); err != nil {
return false, errwrap.Wrap(errors.New("error unmarshaling stage1 manifest"), e... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage0/manifest.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/manifest.go#L69-L85 | go | train | // getStage1Entrypoint retrieves the named entrypoint from the stage1 manifest for a given pod | func getStage1Entrypoint(cdir string, entrypoint string) (string, error) | // getStage1Entrypoint retrieves the named entrypoint from the stage1 manifest for a given pod
func getStage1Entrypoint(cdir string, entrypoint string) (string, error) | {
b, err := ioutil.ReadFile(common.Stage1ManifestPath(cdir))
if err != nil {
return "", errwrap.Wrap(errors.New("error reading pod manifest"), err)
}
s1m := schema.ImageManifest{}
if err := json.Unmarshal(b, &s1m); err != nil {
return "", errwrap.Wrap(errors.New("error unmarshaling stage1 manifest"), err)
}... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage0/manifest.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/manifest.go#L89-L110 | go | train | // getStage1InterfaceVersion retrieves the interface version from the stage1
// manifest for a given pod | func getStage1InterfaceVersion(cdir string) (int, error) | // getStage1InterfaceVersion retrieves the interface version from the stage1
// manifest for a given pod
func getStage1InterfaceVersion(cdir string) (int, error) | {
b, err := ioutil.ReadFile(common.Stage1ManifestPath(cdir))
if err != nil {
return -1, errwrap.Wrap(errors.New("error reading pod manifest"), err)
}
s1m := schema.ImageManifest{}
if err := json.Unmarshal(b, &s1m); err != nil {
return -1, errwrap.Wrap(errors.New("error unmarshaling stage1 manifest"), err)
}... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | networking/podenv.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/podenv.go#L75-L102 | go | train | // Loads nets specified by user, both from a configurable user location and builtin from stage1. User supplied network
// configs override what is built into stage1.
// The order in which networks are applied to pods will be defined by their filenames. | func (e *podEnv) loadNets() ([]activeNet, error) | // Loads nets specified by user, both from a configurable user location and builtin from stage1. User supplied network
// configs override what is built into stage1.
// The order in which networks are applied to pods will be defined by their filenames.
func (e *podEnv) loadNets() ([]activeNet, error) | {
if e.netsLoadList.None() {
stderr.Printf("networking namespace with loopback only")
return nil, nil
}
nets, err := e.newNetLoader().loadNets(e.netsLoadList)
if err != nil {
return nil, err
}
netSlice := make([]activeNet, 0, len(nets))
for _, net := range nets {
netSlice = append(netSlice, net)
}
so... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | networking/podenv.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/podenv.go#L109-L135 | go | train | // Ensure the netns directory is mounted before adding new netns like `ip netns add <netns>` command does.
// See https://github.com/kubernetes/kubernetes/issues/48427
// Make it possible for network namespace mounts to propagate between mount namespaces.
// This makes it likely that an unmounting a network namespace f... | func (e *podEnv) mountNetnsDirectory() error | // Ensure the netns directory is mounted before adding new netns like `ip netns add <netns>` command does.
// See https://github.com/kubernetes/kubernetes/issues/48427
// Make it possible for network namespace mounts to propagate between mount namespaces.
// This makes it likely that an unmounting a network namespace f... | {
err := os.MkdirAll(mountNetnsDirectory, 0755)
if err != nil {
return err
}
err = syscall.Mount("", mountNetnsDirectory, "none", syscall.MS_SHARED|syscall.MS_REC, "")
if err != nil {
// Fail unless we need to make the mount point
if err != syscall.EINVAL {
return fmt.Errorf("mount --make-rshared %s fai... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | networking/podenv.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/podenv.go#L140-L151 | go | train | // podNSCreate creates the network namespace and saves a reference to its path.
// NewNS will bind-mount the namespace in /run/netns, so we write that filename
// to disk. | func (e *podEnv) podNSCreate() error | // podNSCreate creates the network namespace and saves a reference to its path.
// NewNS will bind-mount the namespace in /run/netns, so we write that filename
// to disk.
func (e *podEnv) podNSCreate() error | {
podNS, err := ns.NewNS()
if err != nil {
return err
}
e.podNS = podNS
if err := e.podNSPathSave(); err != nil {
return err
}
return nil
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | networking/podenv.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/podenv.go#L331-L338 | go | train | // Build a Loader that looks first for custom (user provided) plugins, then builtin. | func (e *podEnv) newNetLoader() *netLoader | // Build a Loader that looks first for custom (user provided) plugins, then builtin.
func (e *podEnv) newNetLoader() *netLoader | {
return &netLoader{
parent: &netLoader{
configPath: path.Join(common.Stage1RootfsPath(e.podRoot), BuiltinNetPath),
},
configPath: filepath.Join(e.localConfig, UserNetPathSuffix),
}
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/run.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/run.go#L597-L684 | go | train | /*
* Parse out the --hosts-entries, --dns, --dns-search, and --dns-opt flags
* This includes decoding the "magic" values for hosts-entries and dns.
* Try to detect any obvious insanity, namely invalid IPs or more than one
* magic option
*/ | func parseDNSFlags(flagHostsEntries, flagDNS, flagDNSSearch, flagDNSOpt []string, flagDNSDomain string) (stage0.DNSConfMode, cnitypes.DNS, *stage0.HostsEntries, error) | /*
* Parse out the --hosts-entries, --dns, --dns-search, and --dns-opt flags
* This includes decoding the "magic" values for hosts-entries and dns.
* Try to detect any obvious insanity, namely invalid IPs or more than one
* magic option
*/
func parseDNSFlags(flagHostsEntries, flagDNS, flagDNSSearch, flagDNSOpt []s... | {
DNSConfMode := stage0.DNSConfMode{
Resolv: "default",
Hosts: "default",
}
DNSConfig := cnitypes.DNS{}
HostsEntries := make(stage0.HostsEntries)
// Loop through --dns and look for magic option
// Check for obvious insanity - only one magic option allowed
for _, d := range flagDNS {
// parse magic value... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage1/init/common/app.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/common/app.go#L98-L166 | go | train | // prepareApp sets up the internal runtime context for a specific app. | func prepareApp(p *stage1commontypes.Pod, ra *schema.RuntimeApp) (*preparedApp, error) | // prepareApp sets up the internal runtime context for a specific app.
func prepareApp(p *stage1commontypes.Pod, ra *schema.RuntimeApp) (*preparedApp, error) | {
pa := preparedApp{
app: ra,
env: ra.App.Environment,
noNewPrivileges: getAppNoNewPrivileges(ra.App.Isolators),
}
var err error
// Determine numeric uid and gid
u, g, err := ParseUserGroup(p, ra)
if err != nil {
return nil, errwrap.Wrap(errors.New("unable to determine app's uid ... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage1/init/common/app.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/common/app.go#L169-L229 | go | train | // computeAppResources processes any isolators that manipulate cgroups. | func computeAppResources(isolators types.Isolators) (appResources, error) | // computeAppResources processes any isolators that manipulate cgroups.
func computeAppResources(isolators types.Isolators) (appResources, error) | {
res := appResources{}
var err error
withIsolator := func(name string, f func() error) error {
ok, err := cgroup.IsIsolatorSupported(name)
if err != nil {
return errwrap.Wrapf("could not check for isolator "+name, err)
}
if !ok {
fmt.Fprintf(os.Stderr, "warning: resource/%s isolator set but support... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage1/init/common/app.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/common/app.go#L233-L239 | go | train | // relAppPaths prepends the relative app path (/opt/stage1/rootfs/) to a list
// of paths. Useful for systemd unit directives. | func (pa *preparedApp) relAppPaths(paths []string) []string | // relAppPaths prepends the relative app path (/opt/stage1/rootfs/) to a list
// of paths. Useful for systemd unit directives.
func (pa *preparedApp) relAppPaths(paths []string) []string | {
out := make([]string, 0, len(paths))
for _, p := range paths {
out = append(out, filepath.Join(common.RelAppRootfsPath(pa.app.Name), p))
}
return out
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | store/imagestore/aciinfo.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/aciinfo.go#L68-L86 | go | train | // GetAciInfosWithKeyPrefix returns all the ACIInfos with a blobkey starting with the given prefix. | func GetACIInfosWithKeyPrefix(tx *sql.Tx, prefix string) ([]*ACIInfo, error) | // GetAciInfosWithKeyPrefix returns all the ACIInfos with a blobkey starting with the given prefix.
func GetACIInfosWithKeyPrefix(tx *sql.Tx, prefix string) ([]*ACIInfo, error) | {
var aciinfos []*ACIInfo
rows, err := tx.Query("SELECT * from aciinfo WHERE hasPrefix(blobkey, $1)", prefix)
if err != nil {
return nil, err
}
defer rows.Close()
for rows.Next() {
aciinfo := &ACIInfo{}
if err := aciinfoRowScan(rows, aciinfo); err != nil {
return nil, err
}
aciinfos = append(aciinfo... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | store/imagestore/aciinfo.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/aciinfo.go#L90-L110 | go | train | // GetAciInfosWithName returns all the ACIInfos for a given name. found will be
// false if no aciinfo exists. | func GetACIInfosWithName(tx *sql.Tx, name string) ([]*ACIInfo, bool, error) | // GetAciInfosWithName returns all the ACIInfos for a given name. found will be
// false if no aciinfo exists.
func GetACIInfosWithName(tx *sql.Tx, name string) ([]*ACIInfo, bool, error) | {
var aciinfos []*ACIInfo
found := false
rows, err := tx.Query("SELECT * from aciinfo WHERE name == $1", name)
if err != nil {
return nil, false, err
}
defer rows.Close()
for rows.Next() {
found = true
aciinfo := &ACIInfo{}
if err := aciinfoRowScan(rows, aciinfo); err != nil {
return nil, false, err
... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | store/imagestore/aciinfo.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/aciinfo.go#L114-L134 | go | train | // GetAciInfosWithBlobKey returns the ACIInfo with the given blobKey. found will be
// false if no aciinfo exists. | func GetACIInfoWithBlobKey(tx *sql.Tx, blobKey string) (*ACIInfo, bool, error) | // GetAciInfosWithBlobKey returns the ACIInfo with the given blobKey. found will be
// false if no aciinfo exists.
func GetACIInfoWithBlobKey(tx *sql.Tx, blobKey string) (*ACIInfo, bool, error) | {
aciinfo := &ACIInfo{}
found := false
rows, err := tx.Query("SELECT * from aciinfo WHERE blobkey == $1", blobKey)
if err != nil {
return nil, false, err
}
defer rows.Close()
for rows.Next() {
found = true
if err := aciinfoRowScan(rows, aciinfo); err != nil {
return nil, false, err
}
// No more tha... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | store/imagestore/aciinfo.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/aciinfo.go#L138-L165 | go | train | // GetAllACIInfos returns all the ACIInfos sorted by optional sortfields and
// with ascending or descending order. | func GetAllACIInfos(tx *sql.Tx, sortfields []string, ascending bool) ([]*ACIInfo, error) | // GetAllACIInfos returns all the ACIInfos sorted by optional sortfields and
// with ascending or descending order.
func GetAllACIInfos(tx *sql.Tx, sortfields []string, ascending bool) ([]*ACIInfo, error) | {
var aciinfos []*ACIInfo
query := "SELECT * from aciinfo"
if len(sortfields) > 0 {
query += fmt.Sprintf(" ORDER BY %s ", strings.Join(sortfields, ", "))
if ascending {
query += "ASC"
} else {
query += "DESC"
}
}
rows, err := tx.Query(query)
if err != nil {
return nil, err
}
defer rows.Close()
... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | store/imagestore/aciinfo.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/imagestore/aciinfo.go#L168-L181 | go | train | // WriteACIInfo adds or updates the provided aciinfo. | func WriteACIInfo(tx *sql.Tx, aciinfo *ACIInfo) error | // WriteACIInfo adds or updates the provided aciinfo.
func WriteACIInfo(tx *sql.Tx, aciinfo *ACIInfo) error | {
// ql doesn't have an INSERT OR UPDATE function so
// it's faster to remove and reinsert the row
_, err := tx.Exec("DELETE from aciinfo where blobkey == $1", aciinfo.BlobKey)
if err != nil {
return err
}
_, err = tx.Exec("INSERT into aciinfo (blobkey, name, importtime, lastused, latest, size, treestoresize) ... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage1/init/kvm/hypervisor/hvqemu/qemu_driver.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/hypervisor/hvqemu/qemu_driver.go#L29-L63 | go | train | // StartCmd takes path to stage1, name of the machine, path to kernel, network describers, memory in megabytes
// and quantity of cpus and prepares command line to run QEMU process | func StartCmd(wdPath, name, kernelPath string, nds []kvm.NetDescriber, cpu, mem int64, debug bool) []string | // StartCmd takes path to stage1, name of the machine, path to kernel, network describers, memory in megabytes
// and quantity of cpus and prepares command line to run QEMU process
func StartCmd(wdPath, name, kernelPath string, nds []kvm.NetDescriber, cpu, mem int64, debug bool) []string | {
var (
driverConfiguration = hypervisor.KvmHypervisor{
Bin: "./qemu",
KernelParams: []string{
"root=/dev/root",
"rootfstype=9p",
"rootflags=trans=virtio,version=9p2000.L,cache=mmap",
"rw",
"systemd.default_standard_error=journal+console",
"systemd.default_standard_output=journal+conso... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage1/init/kvm/hypervisor/hvqemu/qemu_driver.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/hypervisor/hvqemu/qemu_driver.go#L69-L79 | go | train | // kvmNetArgs returns additional arguments that need to be passed
// to qemu to configure networks properly. Logic is based on
// network configuration extracted from Networking struct
// and essentially from activeNets that expose NetDescriber behavior | func kvmNetArgs(nds []kvm.NetDescriber) []string | // kvmNetArgs returns additional arguments that need to be passed
// to qemu to configure networks properly. Logic is based on
// network configuration extracted from Networking struct
// and essentially from activeNets that expose NetDescriber behavior
func kvmNetArgs(nds []kvm.NetDescriber) []string | {
var qemuArgs []string
for _, nd := range nds {
qemuArgs = append(qemuArgs, []string{"-net", "nic,model=virtio"}...)
qemuNic := fmt.Sprintf("tap,ifname=%s,script=no,downscript=no,vhost=on", nd.IfName())
qemuArgs = append(qemuArgs, []string{"-net", qemuNic}...)
}
return qemuArgs
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage1/init/kvm/hypervisor/hypervisor.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/hypervisor/hypervisor.go#L26-L54 | go | train | // InitKernelParams sets debug and common parameters passed to the kernel | func (hv *KvmHypervisor) InitKernelParams(isDebug bool) | // InitKernelParams sets debug and common parameters passed to the kernel
func (hv *KvmHypervisor) InitKernelParams(isDebug bool) | {
hv.KernelParams = append(hv.KernelParams, []string{
"console=hvc0",
"init=/usr/lib/systemd/systemd",
"no_timer_check",
"noreplace-smp",
"tsc=reliable"}...)
if isDebug {
hv.KernelParams = append(hv.KernelParams, []string{
"debug",
"systemd.log_level=debug",
"systemd.show_status=true",
}...)
... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/image/dockerfetcher.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/dockerfetcher.go#L51-L59 | go | train | // Hash uses docker2aci to download the image and convert it to
// ACI, then stores it in the store and returns the hash. | func (f *dockerFetcher) Hash(u *url.URL) (string, error) | // Hash uses docker2aci to download the image and convert it to
// ACI, then stores it in the store and returns the hash.
func (f *dockerFetcher) Hash(u *url.URL) (string, error) | {
ensureLogger(f.Debug)
dockerURL, err := d2acommon.ParseDockerURL(path.Join(u.Host, u.Path))
if err != nil {
return "", fmt.Errorf(`invalid docker URL %q; expected syntax is "docker://[REGISTRY_HOST[:REGISTRY_PORT]/]IMAGE_NAME[:TAG]"`, u)
}
latest := dockerURL.Tag == "latest"
return f.fetchImageFrom(u, latest... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage0/registration.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/registration.go#L54-L109 | go | train | // registerPod registers pod with metadata service.
// Returns authentication token to be passed in the URL | func registerPod(root string, uuid *types.UUID, apps schema.AppList) (token string, rerr error) | // registerPod registers pod with metadata service.
// Returns authentication token to be passed in the URL
func registerPod(root string, uuid *types.UUID, apps schema.AppList) (token string, rerr error) | {
u := uuid.String()
var err error
token, err = generateMDSToken()
if err != nil {
rerr = errwrap.Wrap(errors.New("failed to generate MDS token"), err)
return
}
pmfPath := common.PodManifestPath(root)
pmf, err := os.Open(pmfPath)
if err != nil {
rerr = errwrap.Wrap(fmt.Errorf("failed to open runtime ma... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage0/registration.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/registration.go#L112-L125 | go | train | // unregisterPod unregisters pod with the metadata service. | func unregisterPod(root string, uuid *types.UUID) error | // unregisterPod unregisters pod with the metadata service.
func unregisterPod(root string, uuid *types.UUID) error | {
_, err := os.Stat(filepath.Join(root, mdsRegisteredFile))
switch {
case err == nil:
pth := path.Join("/pods", uuid.String())
return httpRequest("DELETE", pth, nil)
case os.IsNotExist(err):
return nil
default:
return err
}
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage0/registration.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/registration.go#L196-L203 | go | train | // CheckMdsAvailability checks whether a local metadata service can be reached. | func CheckMdsAvailability() error | // CheckMdsAvailability checks whether a local metadata service can be reached.
func CheckMdsAvailability() error | {
if conn, err := net.Dial("unix", common.MetadataServiceRegSock); err != nil {
return errUnreachable
} else {
conn.Close()
return nil
}
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | networking/netinfo/netinfo.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/netinfo/netinfo.go#L74-L80 | go | train | // MergeCNIResult will incorporate the result of a CNI plugin's execution | func (ni *NetInfo) MergeCNIResult(result types.Result) | // MergeCNIResult will incorporate the result of a CNI plugin's execution
func (ni *NetInfo) MergeCNIResult(result types.Result) | {
ni.IP = result.IP4.IP.IP
ni.Mask = net.IP(result.IP4.IP.Mask)
ni.HostIP = result.IP4.Gateway
ni.IP4 = result.IP4
ni.DNS = result.DNS
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/multicall/multicall.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/multicall/multicall.go#L52-L58 | go | train | // Add adds a new multicall command. name is the command name and fn is the
// function that will be executed for the specified command. It returns the
// related Entrypoint.
// Packages adding new multicall commands should call Add in their init
// function. | func Add(name string, fn commandFn) Entrypoint | // Add adds a new multicall command. name is the command name and fn is the
// function that will be executed for the specified command. It returns the
// related Entrypoint.
// Packages adding new multicall commands should call Add in their init
// function.
func Add(name string, fn commandFn) Entrypoint | {
if _, ok := commands[name]; ok {
panic(fmt.Errorf("command with name %q already exists", name))
}
commands[name] = fn
return Entrypoint(name)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/multicall/multicall.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/multicall/multicall.go#L65-L74 | go | train | // MaybeExec should be called at the start of the program, if the process argv[0] is
// a name registered with multicall, the related function will be executed.
// If the functions returns an error, it will be printed to stderr and will
// exit with an exit status of 1, otherwise it will exit with a 0 exit
// status. | func MaybeExec() | // MaybeExec should be called at the start of the program, if the process argv[0] is
// a name registered with multicall, the related function will be executed.
// If the functions returns an error, it will be printed to stderr and will
// exit with an exit status of 1, otherwise it will exit with a 0 exit
// status.
f... | {
name := path.Base(os.Args[0])
if fn, ok := commands[name]; ok {
if err := fn(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(254)
}
os.Exit(0)
}
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/multicall/multicall.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/multicall/multicall.go#L78-L88 | go | train | // Cmd will prepare the *exec.Cmd for the given entrypoint, configured with the
// provided args. | func (e Entrypoint) Cmd(args ...string) *exec.Cmd | // Cmd will prepare the *exec.Cmd for the given entrypoint, configured with the
// provided args.
func (e Entrypoint) Cmd(args ...string) *exec.Cmd | {
// append the Entrypoint as argv[0]
args = append([]string{string(e)}, args...)
return &exec.Cmd{
Path: exePath,
Args: args,
SysProcAttr: &syscall.SysProcAttr{
Pdeathsig: syscall.SIGTERM,
},
}
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/group.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/group.go#L28-L30 | go | train | // LookupGid reads the group file and returns the gid of the group
// specified by groupName. | func LookupGid(groupName string) (gid int, err error) | // LookupGid reads the group file and returns the gid of the group
// specified by groupName.
func LookupGid(groupName string) (gid int, err error) | {
return group.LookupGid(groupName)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/stage1hash.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/stage1hash.go#L157-L165 | go | train | // addStage1ImageFlags adds flags for specifying custom stage1 image | func addStage1ImageFlags(flags *pflag.FlagSet) | // addStage1ImageFlags adds flags for specifying custom stage1 image
func addStage1ImageFlags(flags *pflag.FlagSet) | {
for _, data := range stage1FlagsData {
wrapper := &stage1ImageLocationFlag{
loc: &overriddenStage1Location,
kind: data.kind,
}
flags.Var(wrapper, data.flag, data.help)
}
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/stage1hash.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/stage1hash.go#L217-L226 | go | train | // getStage1Hash will try to get the hash of stage1 to use.
//
// Before getting inside this rats nest, let's try to write up the
// expected behaviour.
//
// If the user passed --stage1-url, --stage1-path, --stage1-name,
// --stage1-hash, or --stage1-from-dir then we take what was passed
// and try to load it. If it f... | func getStage1Hash(s *imagestore.Store, ts *treestore.Store, c *config.Config) (*types.Hash, error) | // getStage1Hash will try to get the hash of stage1 to use.
//
// Before getting inside this rats nest, let's try to write up the
// expected behaviour.
//
// If the user passed --stage1-url, --stage1-path, --stage1-name,
// --stage1-hash, or --stage1-from-dir then we take what was passed
// and try to load it. If it f... | {
imgDir := getStage1ImagesDirectory(c)
if overriddenStage1Location.kind != stage1ImageLocationUnset {
// we passed a --stage-{url,path,name,hash,from-dir} flag
return getStage1HashFromFlag(s, ts, overriddenStage1Location, imgDir)
}
imgRef, imgLoc, imgFileName := getStage1DataFromConfig(c)
return getConfigur... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/experiment.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/experiment.go#L35-L48 | go | train | // IsExperimentEnabled returns true if the given rkt experiment is enabled.
// The given name is converted to upper case and a bool RKT_EXPERIMENT_{NAME}
// environment variable is retrieved.
// If the experiment name is unknown, false is returned.
// If the environment variable does not contain a valid bool value
// a... | func IsExperimentEnabled(name string) bool | // IsExperimentEnabled returns true if the given rkt experiment is enabled.
// The given name is converted to upper case and a bool RKT_EXPERIMENT_{NAME}
// environment variable is retrieved.
// If the experiment name is unknown, false is returned.
// If the environment variable does not contain a valid bool value
// a... | {
if _, ok := stage0Experiments[name]; !ok {
return false
}
v := os.Getenv("RKT_EXPERIMENT_" + strings.ToUpper(name))
enabled, err := strconv.ParseBool(v)
if err != nil {
return false // ignore errors from bool conversion
}
return enabled
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/sys/capability.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/sys/capability.go#L25-L35 | go | train | // HasChrootCapability checks if the current process has the CAP_SYS_CHROOT
// capability | func HasChrootCapability() bool | // HasChrootCapability checks if the current process has the CAP_SYS_CHROOT
// capability
func HasChrootCapability() bool | {
// Checking the capabilities should be enough, but in case there're
// problem retrieving them, fallback checking for the effective uid
// (hoping it hasn't dropped its CAP_SYS_CHROOT).
caps, err := capability.NewPid(0)
if err == nil {
return caps.Get(capability.EFFECTIVE, capability.CAP_SYS_CHROOT)
} else {... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/group/group.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/group/group.go#L43-L55 | go | train | // LookupGid reads the group file specified by groupFile, and returns the gid of the group
// specified by groupName. | func LookupGidFromFile(groupName, groupFile string) (gid int, err error) | // LookupGid reads the group file specified by groupFile, and returns the gid of the group
// specified by groupName.
func LookupGidFromFile(groupName, groupFile string) (gid int, err error) | {
groups, err := parseGroupFile(groupFile)
if err != nil {
return -1, errwrap.Wrap(fmt.Errorf("error parsing %q file", groupFile), err)
}
group, ok := groups[groupName]
if !ok {
return -1, fmt.Errorf("%q group not found", groupName)
}
return group.Gid, nil
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/group/group.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/group/group.go#L59-L61 | go | train | // LookupGid reads the group file and returns the gid of the group
// specified by groupName. | func LookupGid(groupName string) (gid int, err error) | // LookupGid reads the group file and returns the gid of the group
// specified by groupName.
func LookupGid(groupName string) (gid int, err error) | {
return LookupGidFromFile(groupName, groupFilePath)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/lock/keylock.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/lock/keylock.go#L59-L76 | go | train | // NewKeyLock returns a KeyLock for the specified key without acquisition.
// lockdir is the directory where the lock file will be created. If lockdir
// doesn't exists it will be created.
// key value must be a valid file name (as the lock file is named after the key
// value). | func NewKeyLock(lockDir string, key string) (*KeyLock, error) | // NewKeyLock returns a KeyLock for the specified key without acquisition.
// lockdir is the directory where the lock file will be created. If lockdir
// doesn't exists it will be created.
// key value must be a valid file name (as the lock file is named after the key
// value).
func NewKeyLock(lockDir string, key stri... | {
err := os.MkdirAll(lockDir, defaultDirPerm)
if err != nil {
return nil, err
}
keyLockFile := filepath.Join(lockDir, key)
// create the file if it doesn't exists
f, err := os.OpenFile(keyLockFile, os.O_RDONLY|os.O_CREATE, defaultFilePerm)
if err != nil {
return nil, errwrap.Wrap(errors.New("error creating ... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/lock/keylock.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/lock/keylock.go#L94-L96 | go | train | // TryExclusiveLock takes an exclusive lock on the key without blocking.
// lockDir is the directory where the lock file will be created.
// It will return ErrLocked if any lock is already held. | func TryExclusiveKeyLock(lockDir string, key string) (*KeyLock, error) | // TryExclusiveLock takes an exclusive lock on the key without blocking.
// lockDir is the directory where the lock file will be created.
// It will return ErrLocked if any lock is already held.
func TryExclusiveKeyLock(lockDir string, key string) (*KeyLock, error) | {
return createAndLock(lockDir, key, keyLockExclusive|keyLockNonBlocking)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/lock/keylock.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/lock/keylock.go#L109-L111 | go | train | // ExclusiveLock takes an exclusive lock on a key.
// lockDir is the directory where the lock file will be created.
// It will block if an exclusive lock is already held on the key. | func ExclusiveKeyLock(lockDir string, key string) (*KeyLock, error) | // ExclusiveLock takes an exclusive lock on a key.
// lockDir is the directory where the lock file will be created.
// It will block if an exclusive lock is already held on the key.
func ExclusiveKeyLock(lockDir string, key string) (*KeyLock, error) | {
return createAndLock(lockDir, key, keyLockExclusive)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/lock/keylock.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/lock/keylock.go#L124-L126 | go | train | // TrySharedLock takes a co-operative (shared) lock on a key without blocking.
// lockDir is the directory where the lock file will be created.
// It will return ErrLocked if an exclusive lock already exists on the key. | func TrySharedKeyLock(lockDir string, key string) (*KeyLock, error) | // TrySharedLock takes a co-operative (shared) lock on a key without blocking.
// lockDir is the directory where the lock file will be created.
// It will return ErrLocked if an exclusive lock already exists on the key.
func TrySharedKeyLock(lockDir string, key string) (*KeyLock, error) | {
return createAndLock(lockDir, key, keyLockShared|keyLockNonBlocking)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/lock/keylock.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/lock/keylock.go#L139-L141 | go | train | // SharedLock takes a co-operative (shared) lock on a key.
// lockDir is the directory where the lock file will be created.
// It will block if an exclusive lock is already held on the key. | func SharedKeyLock(lockDir string, key string) (*KeyLock, error) | // SharedLock takes a co-operative (shared) lock on a key.
// lockDir is the directory where the lock file will be created.
// It will block if an exclusive lock is already held on the key.
func SharedKeyLock(lockDir string, key string) (*KeyLock, error) | {
return createAndLock(lockDir, key, keyLockShared)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/lock/keylock.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/lock/keylock.go#L170-L235 | go | train | // lock is the base function to take a lock and handle changed lock files
// As there's the need to remove unused (see CleanKeyLocks) lock files without
// races, a changed file detection is needed.
//
// Without changed file detection this can happen:
//
// Process A takes exclusive lock on file01
// Process B waits f... | func (l *KeyLock) lock(mode keyLockMode, maxRetries int) error | // lock is the base function to take a lock and handle changed lock files
// As there's the need to remove unused (see CleanKeyLocks) lock files without
// races, a changed file detection is needed.
//
// Without changed file detection this can happen:
//
// Process A takes exclusive lock on file01
// Process B waits f... | {
retries := 0
for {
var err error
var isExclusive bool
var isNonBlocking bool
if mode&keyLockExclusive != 0 {
isExclusive = true
}
if mode&keyLockNonBlocking != 0 {
isNonBlocking = true
}
switch {
case isExclusive && !isNonBlocking:
err = l.keyLock.ExclusiveLock()
case isExclusive && is... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/lock/keylock.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/lock/keylock.go#L238-L244 | go | train | // Unlock unlocks the key lock. | func (l *KeyLock) Unlock() error | // Unlock unlocks the key lock.
func (l *KeyLock) Unlock() error | {
err := l.keyLock.Unlock()
if err != nil {
return err
}
return nil
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/lock/keylock.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/lock/keylock.go#L249-L277 | go | train | // CleanKeyLocks remove lock files from the lockDir.
// For every key it tries to take an Exclusive lock on it and skip it if it
// fails with ErrLocked | func CleanKeyLocks(lockDir string) error | // CleanKeyLocks remove lock files from the lockDir.
// For every key it tries to take an Exclusive lock on it and skip it if it
// fails with ErrLocked
func CleanKeyLocks(lockDir string) error | {
f, err := os.Open(lockDir)
if err != nil {
return errwrap.Wrap(errors.New("error opening lockDir"), err)
}
defer f.Close()
files, err := f.Readdir(0)
if err != nil {
return errwrap.Wrap(errors.New("error getting lock files list"), err)
}
for _, f := range files {
filename := filepath.Join(lockDir, f.Na... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/pubkey/pubkey.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L72-L88 | go | train | // GetPubKeyLocations discovers locations at prefix | func (m *Manager) GetPubKeyLocations(prefix string) ([]string, error) | // GetPubKeyLocations discovers locations at prefix
func (m *Manager) GetPubKeyLocations(prefix string) ([]string, error) | {
ensureLogger(m.Debug)
if prefix == "" {
return nil, fmt.Errorf("empty prefix")
}
kls, err := m.metaDiscoverPubKeyLocations(prefix)
if err != nil {
return nil, errwrap.Wrap(errors.New("prefix meta discovery error"), err)
}
if len(kls) == 0 {
return nil, fmt.Errorf("meta discovery on %s resulted in no k... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/pubkey/pubkey.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L91-L155 | go | train | // AddKeys adds the keys listed in pkls at prefix | func (m *Manager) AddKeys(pkls []string, prefix string, accept AcceptOption) error | // AddKeys adds the keys listed in pkls at prefix
func (m *Manager) AddKeys(pkls []string, prefix string, accept AcceptOption) error | {
ensureLogger(m.Debug)
if m.Ks == nil {
return fmt.Errorf("no keystore available to add keys to")
}
for _, pkl := range pkls {
u, err := url.Parse(pkl)
if err != nil {
return err
}
pk, err := m.getPubKey(u)
if err != nil {
return errwrap.Wrap(fmt.Errorf("error accessing the key %s", pkl), err)
... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/pubkey/pubkey.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L158-L181 | go | train | // metaDiscoverPubKeyLocations discovers the locations of public keys through ACDiscovery by applying prefix as an ACApp | func (m *Manager) metaDiscoverPubKeyLocations(prefix string) ([]string, error) | // metaDiscoverPubKeyLocations discovers the locations of public keys through ACDiscovery by applying prefix as an ACApp
func (m *Manager) metaDiscoverPubKeyLocations(prefix string) ([]string, error) | {
app, err := discovery.NewAppFromString(prefix)
if err != nil {
return nil, err
}
hostHeaders := config.ResolveAuthPerHost(m.AuthPerHost)
insecure := discovery.InsecureNone
if m.InsecureAllowHTTP {
insecure = insecure | discovery.InsecureHTTP
}
if m.InsecureSkipTLSCheck {
insecure = insecure | discover... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/pubkey/pubkey.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L184-L198 | go | train | // getPubKey retrieves a public key (if remote), and verifies it's a gpg key | func (m *Manager) getPubKey(u *url.URL) (*os.File, error) | // getPubKey retrieves a public key (if remote), and verifies it's a gpg key
func (m *Manager) getPubKey(u *url.URL) (*os.File, error) | {
switch u.Scheme {
case "":
return os.Open(u.Path)
case "http":
if !m.InsecureAllowHTTP {
return nil, fmt.Errorf("--insecure-allow-http required for http URLs")
}
fallthrough
case "https":
return downloadKey(u, m.InsecureSkipTLSCheck)
}
return nil, fmt.Errorf("only local files and http or https UR... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/pubkey/pubkey.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L201-L244 | go | train | // downloadKey retrieves the file, storing it in a deleted tempfile | func downloadKey(u *url.URL, skipTLSCheck bool) (*os.File, error) | // downloadKey retrieves the file, storing it in a deleted tempfile
func downloadKey(u *url.URL, skipTLSCheck bool) (*os.File, error) | {
tf, err := ioutil.TempFile("", "")
if err != nil {
return nil, errwrap.Wrap(errors.New("error creating tempfile"), err)
}
os.Remove(tf.Name()) // no need to keep the tempfile around
defer func() {
if tf != nil {
tf.Close()
}
}()
// TODO(krnowak): we should probably apply credential headers
// from... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/pubkey/pubkey.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L275-L296 | go | train | // displayKey shows the key summary | func displayKey(prefix, location string, key *os.File) error | // displayKey shows the key summary
func displayKey(prefix, location string, key *os.File) error | {
defer key.Seek(0, os.SEEK_SET)
kr, err := openpgp.ReadArmoredKeyRing(key)
if err != nil {
return errwrap.Wrap(errors.New("error reading key"), err)
}
log.Printf("prefix: %q\nkey: %q", prefix, location)
for _, k := range kr {
stdout.Printf("gpg key fingerprint is: %s", fingerToString(k.PrimaryKey.Fingerpr... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/pubkey/pubkey.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/pubkey/pubkey.go#L299-L316 | go | train | // reviewKey asks the user to accept the key | func reviewKey() (bool, error) | // reviewKey asks the user to accept the key
func reviewKey() (bool, error) | {
in := bufio.NewReader(os.Stdin)
for {
stdout.Printf("Are you sure you want to trust this key (yes/no)?")
input, err := in.ReadString('\n')
if err != nil {
return false, errwrap.Wrap(errors.New("error reading input"), err)
}
switch input {
case "yes\n":
return true, nil
case "no\n":
return fa... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | networking/kvm.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/kvm.go#L59-L77 | go | train | // setupTapDevice creates persistent tap device
// and returns a newly created netlink.Link structure | func setupTapDevice(podID types.UUID) (netlink.Link, error) | // setupTapDevice creates persistent tap device
// and returns a newly created netlink.Link structure
func setupTapDevice(podID types.UUID) (netlink.Link, error) | {
// network device names are limited to 16 characters
// the suffix %d will be replaced by the kernel with a suitable number
nameTemplate := fmt.Sprintf("rkt-%s-tap%%d", podID.String()[0:4])
ifName, err := tuntap.CreatePersistentIface(nameTemplate, tuntap.Tap)
if err != nil {
return nil, errwrap.Wrap(errors.Ne... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | networking/kvm.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/kvm.go#L92-L146 | go | train | // setupTapDevice creates persistent macvtap device
// and returns a newly created netlink.Link structure
// using part of pod hash and interface number in interface name | func setupMacVTapDevice(podID types.UUID, config MacVTapNetConf, interfaceNumber int) (netlink.Link, error) | // setupTapDevice creates persistent macvtap device
// and returns a newly created netlink.Link structure
// using part of pod hash and interface number in interface name
func setupMacVTapDevice(podID types.UUID, config MacVTapNetConf, interfaceNumber int) (netlink.Link, error) | {
master, err := netlink.LinkByName(config.Master)
if err != nil {
return nil, errwrap.Wrap(fmt.Errorf("cannot find master device '%v'", config.Master), err)
}
var mode netlink.MacvlanMode
switch config.Mode {
// if not set - defaults to bridge mode as in:
// https://github.com/rkt/rkt/blob/master/Documentati... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | networking/kvm.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/kvm.go#L151-L178 | go | train | // kvmSetupNetAddressing calls IPAM plugin (with a hack) to reserve an IP to be
// used by newly create tuntap pair
// in result it updates activeNet.runtime configuration | func kvmSetupNetAddressing(network *Networking, n activeNet, ifName string) error | // kvmSetupNetAddressing calls IPAM plugin (with a hack) to reserve an IP to be
// used by newly create tuntap pair
// in result it updates activeNet.runtime configuration
func kvmSetupNetAddressing(network *Networking, n activeNet, ifName string) error | {
// TODO: very ugly hack, that go through upper plugin, down to ipam plugin
if err := ip.EnableIP4Forward(); err != nil {
return errwrap.Wrap(errors.New("failed to enable forwarding"), err)
}
// patch plugin type only for single IPAM run time, then revert this change
original_type := n.conf.Type
n.conf.Type ... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | networking/kvm.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/kvm.go#L437-L642 | go | train | // kvmSetup prepare new Networking to be used in kvm environment based on tuntap pair interfaces
// to allow communication with virtual machine created by lkvm tool | func kvmSetup(podRoot string, podID types.UUID, fps []commonnet.ForwardedPort, netList common.NetList, localConfig string, noDNS bool) (*Networking, error) | // kvmSetup prepare new Networking to be used in kvm environment based on tuntap pair interfaces
// to allow communication with virtual machine created by lkvm tool
func kvmSetup(podRoot string, podID types.UUID, fps []commonnet.ForwardedPort, netList common.NetList, localConfig string, noDNS bool) (*Networking, error) | {
network := Networking{
podEnv: podEnv{
podRoot: podRoot,
podID: podID,
netsLoadList: netList,
localConfig: localConfig,
},
}
var e error
// If there's a network set as default in CNI configuration
defaultGatewaySet := false
_, defaultNet, err := net.ParseCIDR("0.0.0.0/0")
if err... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | networking/kvm.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/kvm.go#L650-L701 | go | train | /*
extend Networking struct with methods to clean up kvm specific network configurations
*/
// teardownKvmNets teardown every active networking from networking by
// removing tuntap interface and releasing its ip from IPAM plugin | func (n *Networking) teardownKvmNets() | /*
extend Networking struct with methods to clean up kvm specific network configurations
*/
// teardownKvmNets teardown every active networking from networking by
// removing tuntap interface and releasing its ip from IPAM plugin
func (n *Networking) teardownKvmNets() | {
for _, an := range n.nets {
if an.conf.Type == "flannel" {
if err := kvmTransformFlannelNetwork(&an); err != nil {
stderr.PrintE("error transforming flannel network", err)
continue
}
}
switch an.conf.Type {
case "ptp", "bridge":
// remove tuntap interface
tuntap.RemovePersistentIface(an... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | networking/kvm.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/kvm.go#L705-L711 | go | train | // kvmTeardown network teardown for kvm flavor based pods
// similar to Networking.Teardown but without host namespaces | func (n *Networking) kvmTeardown() | // kvmTeardown network teardown for kvm flavor based pods
// similar to Networking.Teardown but without host namespaces
func (n *Networking) kvmTeardown() | {
if err := n.teardownForwarding(); err != nil {
stderr.PrintE("error removing forwarded ports (kvm)", err)
}
n.teardownKvmNets()
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | store/db/db.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/store/db/db.go#L51-L75 | go | train | // Do Opens the db, executes DoTx and then Closes the DB
// To support a multiprocess and multigoroutine model on a single file access
// database like ql there's the need to exlusively lock, open, close, unlock the
// db for every transaction. For this reason every db transaction should be
// fast to not block other p... | func (db *DB) Do(fns ...txfunc) error | // Do Opens the db, executes DoTx and then Closes the DB
// To support a multiprocess and multigoroutine model on a single file access
// database like ql there's the need to exlusively lock, open, close, unlock the
// db for every transaction. For this reason every db transaction should be
// fast to not block other p... | {
l, err := lock.ExclusiveLock(db.dbdir, lock.Dir)
if err != nil {
return err
}
defer l.Close()
sqldb, err := sql.Open("ql", filepath.Join(db.dbdir, DbFilename))
if err != nil {
return err
}
defer sqldb.Close()
tx, err := sqldb.Begin()
if err != nil {
return err
}
for _, fn := range fns {
if err ... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/image/filefetcher.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/filefetcher.go#L39-L61 | go | train | // Hash opens a file, optionally verifies it against passed asc,
// stores it in the store and returns the hash. | func (f *fileFetcher) Hash(aciPath string, a *asc) (string, error) | // Hash opens a file, optionally verifies it against passed asc,
// stores it in the store and returns the hash.
func (f *fileFetcher) Hash(aciPath string, a *asc) (string, error) | {
ensureLogger(f.Debug)
absPath, err := filepath.Abs(aciPath)
if err != nil {
return "", errwrap.Wrap(fmt.Errorf("failed to get an absolute path for %q", aciPath), err)
}
aciPath = absPath
aciFile, err := f.getFile(aciPath, a)
if err != nil {
return "", err
}
defer aciFile.Close()
key, err := f.S.Write... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/image/filefetcher.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/image/filefetcher.go#L82-L116 | go | train | // fetch opens and verifies the ACI. | func (f *fileFetcher) getVerifiedFile(aciPath string, a *asc) (*os.File, error) | // fetch opens and verifies the ACI.
func (f *fileFetcher) getVerifiedFile(aciPath string, a *asc) (*os.File, error) | {
var aciFile *os.File // closed on error
var errClose error // error signaling to close aciFile
f.maybeOverrideAsc(aciPath, a)
ascFile, err := a.Get()
if err != nil {
return nil, errwrap.Wrap(errors.New("error opening signature file"), err)
}
defer ascFile.Close()
aciFile, err = os.Open(aciPath)
if err... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/fs/mount.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/fs/mount.go#L56-L58 | go | train | // NewLoggingMounter returns a MountUnmounter that logs mount events using the given logger func. | func NewLoggingMounter(m Mounter, um Unmounter, logf func(string, ...interface{})) MountUnmounter | // NewLoggingMounter returns a MountUnmounter that logs mount events using the given logger func.
func NewLoggingMounter(m Mounter, um Unmounter, logf func(string, ...interface{})) MountUnmounter | {
return &loggingMounter{m, um, logf}
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | pkg/tpm/tpm.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/pkg/tpm/tpm.go#L29-L33 | go | train | // Extend extends the TPM log with the provided string. Returns any error. | func Extend(description string) error | // Extend extends the TPM log with the provided string. Returns any error.
func Extend(description string) error | {
connection := tpmclient.New("localhost:12041", timeout)
err := connection.Extend(15, 0x1000, nil, description)
return err
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/cgroup_util.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/cgroup_util.go#L43-L74 | go | train | // cgEscape implements very minimal escaping for names to be used as file names
// in the cgroup tree: any name which might conflict with a kernel name or is
// prefixed with '_' is prefixed with a '_'. That way, when reading cgroup
// names it is sufficient to remove a single prefixing underscore if there is
// one. | func cgEscape(p string) string | // cgEscape implements very minimal escaping for names to be used as file names
// in the cgroup tree: any name which might conflict with a kernel name or is
// prefixed with '_' is prefixed with a '_'. That way, when reading cgroup
// names it is sufficient to remove a single prefixing underscore if there is
// one.
f... | {
needPrefix := false
switch {
case strings.HasPrefix(p, "_"):
fallthrough
case strings.HasPrefix(p, "."):
fallthrough
case p == "notify_on_release":
fallthrough
case p == "release_agent":
fallthrough
case p == "tasks":
needPrefix = true
case strings.Contains(p, "."):
sp := strings.Split(p, ".")
... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/cgroup_util.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/cgroup_util.go#L133-L174 | go | train | // SliceToPath explodes a slice name to its corresponding path in the cgroup
// hierarchy. For example, a slice named "foo-bar-baz.slice" corresponds to the
// path "foo.slice/foo-bar.slice/foo-bar-baz.slice". See systemd.slice(5) | func SliceToPath(unit string) (string, error) | // SliceToPath explodes a slice name to its corresponding path in the cgroup
// hierarchy. For example, a slice named "foo-bar-baz.slice" corresponds to the
// path "foo.slice/foo-bar.slice/foo-bar-baz.slice". See systemd.slice(5)
func SliceToPath(unit string) (string, error) | {
if unit == "-.slice" {
return "", nil
}
if !strings.HasSuffix(unit, ".slice") {
return "", fmt.Errorf("not a slice")
}
if !sliceNameIsValid(unit) {
return "", fmt.Errorf("invalid slice name")
}
prefix := unitnameToPrefix(unit)
// don't allow initial dashes
if prefix[0] == '-' {
return "", fmt.Er... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L101-L103 | go | train | // Stage1RootfsPath returns the path to the stage1 rootfs | func Stage1RootfsPath(root string) string | // Stage1RootfsPath returns the path to the stage1 rootfs
func Stage1RootfsPath(root string) string | {
return filepath.Join(Stage1ImagePath(root), aci.RootfsDir)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L106-L108 | go | train | // Stage1ManifestPath returns the path to the stage1's manifest file inside the expanded ACI. | func Stage1ManifestPath(root string) string | // Stage1ManifestPath returns the path to the stage1's manifest file inside the expanded ACI.
func Stage1ManifestPath(root string) string | {
return filepath.Join(Stage1ImagePath(root), aci.ManifestFile)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L140-L142 | go | train | // AppStatusPath returns the path of the status file of an app. | func AppStatusPath(root, appName string) string | // AppStatusPath returns the path of the status file of an app.
func AppStatusPath(root, appName string) string | {
return filepath.Join(AppsStatusesPath(root), appName)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L146-L148 | go | train | // AppStatusPathFromStage1Rootfs returns the path of the status file of an app.
// It receives the stage1 rootfs as parameter instead of the pod root. | func AppStatusPathFromStage1Rootfs(rootfs, appName string) string | // AppStatusPathFromStage1Rootfs returns the path of the status file of an app.
// It receives the stage1 rootfs as parameter instead of the pod root.
func AppStatusPathFromStage1Rootfs(rootfs, appName string) string | {
return filepath.Join(AppsStatusesPathFromStage1Rootfs(rootfs), appName)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L152-L154 | go | train | // AppCreatedPath returns the path of the ${appname}-created file, which is used to record
// the creation timestamp of the app. | func AppCreatedPath(root, appName string) string | // AppCreatedPath returns the path of the ${appname}-created file, which is used to record
// the creation timestamp of the app.
func AppCreatedPath(root, appName string) string | {
return filepath.Join(AppsStatusesPath(root), fmt.Sprintf("%s-created", appName))
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L159-L161 | go | train | // AppCreatedPathFromStage1Rootfs returns the path of the ${appname}-created file,
// which is used to record the creation timestamp of the app.
// It receives the stage1 rootfs as parameter instead of the pod root. | func AppCreatedPathFromStage1Rootfs(rootfs, appName string) string | // AppCreatedPathFromStage1Rootfs returns the path of the ${appname}-created file,
// which is used to record the creation timestamp of the app.
// It receives the stage1 rootfs as parameter instead of the pod root.
func AppCreatedPathFromStage1Rootfs(rootfs, appName string) string | {
return filepath.Join(AppsStatusesPathFromStage1Rootfs(rootfs), fmt.Sprintf("%s-created", appName))
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L182-L184 | go | train | // AppPath returns the path to an app's rootfs. | func AppPath(root string, appName types.ACName) string | // AppPath returns the path to an app's rootfs.
func AppPath(root string, appName types.ACName) string | {
return filepath.Join(AppsPath(root), appName.String())
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L187-L189 | go | train | // AppRootfsPath returns the path to an app's rootfs. | func AppRootfsPath(root string, appName types.ACName) string | // AppRootfsPath returns the path to an app's rootfs.
func AppRootfsPath(root string, appName types.ACName) string | {
return filepath.Join(AppPath(root, appName), aci.RootfsDir)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L192-L194 | go | train | // RelAppPath returns the path of an app relative to the stage1 chroot. | func RelAppPath(appName types.ACName) string | // RelAppPath returns the path of an app relative to the stage1 chroot.
func RelAppPath(appName types.ACName) string | {
return filepath.Join(stage2Dir, appName.String())
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L197-L199 | go | train | // RelAppRootfsPath returns the path of an app's rootfs relative to the stage1 chroot. | func RelAppRootfsPath(appName types.ACName) string | // RelAppRootfsPath returns the path of an app's rootfs relative to the stage1 chroot.
func RelAppRootfsPath(appName types.ACName) string | {
return filepath.Join(RelAppPath(appName), aci.RootfsDir)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L202-L204 | go | train | // ImageManifestPath returns the path to the app's manifest file of a pod. | func ImageManifestPath(root string, appName types.ACName) string | // ImageManifestPath returns the path to the app's manifest file of a pod.
func ImageManifestPath(root string, appName types.ACName) string | {
return filepath.Join(AppPath(root, appName), aci.ManifestFile)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L212-L214 | go | train | // AppInfoPath returns the path to the app's appsinfo directory of a pod. | func AppInfoPath(root string, appName types.ACName) string | // AppInfoPath returns the path to the app's appsinfo directory of a pod.
func AppInfoPath(root string, appName types.ACName) string | {
return filepath.Join(AppsInfoPath(root), appName.String())
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L217-L219 | go | train | // AppTreeStoreIDPath returns the path to the app's treeStoreID file of a pod. | func AppTreeStoreIDPath(root string, appName types.ACName) string | // AppTreeStoreIDPath returns the path to the app's treeStoreID file of a pod.
func AppTreeStoreIDPath(root string, appName types.ACName) string | {
return filepath.Join(AppInfoPath(root, appName), AppTreeStoreIDFilename)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L222-L224 | go | train | // AppImageManifestPath returns the path to the app's ImageManifest file | func AppImageManifestPath(root string, appName types.ACName) string | // AppImageManifestPath returns the path to the app's ImageManifest file
func AppImageManifestPath(root string, appName types.ACName) string | {
return filepath.Join(AppInfoPath(root, appName), aci.ManifestFile)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L233-L246 | go | train | // CreateSharedVolumesPath ensures the sharedVolumePath for the pod root passed
// in exists. It returns the shared volume path or an error. | func CreateSharedVolumesPath(root string) (string, error) | // CreateSharedVolumesPath ensures the sharedVolumePath for the pod root passed
// in exists. It returns the shared volume path or an error.
func CreateSharedVolumesPath(root string) (string, error) | {
sharedVolPath := SharedVolumesPath(root)
if err := os.MkdirAll(sharedVolPath, SharedVolumePerm); err != nil {
return "", errwrap.Wrap(errors.New("could not create shared volumes directory"), err)
}
// In case it already existed and we didn't make it, ensure permissions are
// what the caller expects them to ... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L249-L251 | go | train | // MetadataServicePublicURL returns the public URL used to host the metadata service | func MetadataServicePublicURL(ip net.IP, token string) string | // MetadataServicePublicURL returns the public URL used to host the metadata service
func MetadataServicePublicURL(ip net.IP, token string) string | {
return fmt.Sprintf("http://%v:%v/%v", ip, MetadataServicePort, token)
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L375-L388 | go | train | // LookupPath search for bin in paths. If found, it returns its absolute path,
// if not, an error | func LookupPath(bin string, paths string) (string, error) | // LookupPath search for bin in paths. If found, it returns its absolute path,
// if not, an error
func LookupPath(bin string, paths string) (string, error) | {
pathsArr := filepath.SplitList(paths)
for _, path := range pathsArr {
binPath := filepath.Join(path, bin)
binAbsPath, err := filepath.Abs(binPath)
if err != nil {
return "", fmt.Errorf("unable to find absolute path for %s", binPath)
}
if fileutil.IsExecutable(binAbsPath) {
return binAbsPath, nil
... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L391-L404 | go | train | // SystemdVersion parses and returns the version of a given systemd binary | func SystemdVersion(systemdBinaryPath string) (int, error) | // SystemdVersion parses and returns the version of a given systemd binary
func SystemdVersion(systemdBinaryPath string) (int, error) | {
versionBytes, err := exec.Command(systemdBinaryPath, "--version").CombinedOutput()
if err != nil {
return -1, errwrap.Wrap(fmt.Errorf("unable to probe %s version", systemdBinaryPath), err)
}
versionStr := strings.SplitN(string(versionBytes), "\n", 2)[0]
var version int
n, err := fmt.Sscanf(versionStr, "syste... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L409-L430 | go | train | // SupportsOverlay returns whether the operating system generally supports OverlayFS,
// returning an instance of ErrOverlayUnsupported which encodes the reason.
// It is sufficient to check for nil if the reason is not of interest. | func SupportsOverlay() error | // SupportsOverlay returns whether the operating system generally supports OverlayFS,
// returning an instance of ErrOverlayUnsupported which encodes the reason.
// It is sufficient to check for nil if the reason is not of interest.
func SupportsOverlay() error | {
// ignore exec.Command error, modprobe may not be present on the system,
// or the kernel module will fail to load.
// we'll find out by reading the side effect in /proc/filesystems
_ = exec.Command("modprobe", "overlay").Run()
f, err := os.Open("/proc/filesystems")
if err != nil {
// don't use errwrap so c... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L437-L486 | go | train | // PathSupportsOverlay checks whether the given path is compatible with OverlayFS.
// This method also calls SupportsOverlay().
//
// It returns an instance of ErrOverlayUnsupported if OverlayFS is not supported
// or any other error if determining overlay support failed. | func PathSupportsOverlay(path string) error | // PathSupportsOverlay checks whether the given path is compatible with OverlayFS.
// This method also calls SupportsOverlay().
//
// It returns an instance of ErrOverlayUnsupported if OverlayFS is not supported
// or any other error if determining overlay support failed.
func PathSupportsOverlay(path string) error | {
if err := SupportsOverlay(); err != nil {
// don't wrap since SupportsOverlay already returns ErrOverlayUnsupported
return err
}
var data syscall.Statfs_t
if err := syscall.Statfs(path, &data); err != nil {
return errwrap.Wrap(fmt.Errorf("cannot statfs %q", path), err)
}
switch data.Type {
case FsMagi... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L490-L500 | go | train | // RemoveEmptyLines removes empty lines from the given string
// and breaks it up into a list of strings at newline characters | func RemoveEmptyLines(str string) []string | // RemoveEmptyLines removes empty lines from the given string
// and breaks it up into a list of strings at newline characters
func RemoveEmptyLines(str string) []string | {
lines := make([]string, 0)
for _, v := range strings.Split(str, "\n") {
if len(v) > 0 {
lines = append(lines, v)
}
}
return lines
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L504-L515 | go | train | // GetExitStatus converts an error to an exit status. If it wasn't an exit
// status != 0 it returns the same error that it was called with | func GetExitStatus(err error) (int, error) | // GetExitStatus converts an error to an exit status. If it wasn't an exit
// status != 0 it returns the same error that it was called with
func GetExitStatus(err error) (int, error) | {
if err == nil {
return 0, nil
}
if exiterr, ok := err.(*exec.ExitError); ok {
// the program has exited with an exit code != 0
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
return status.ExitStatus(), nil
}
}
return -1, err
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | common/common.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/common/common.go#L545-L555 | go | train | // ImageNameToAppName converts the full name of image to an app name without special
// characters - we use it as a default app name when specyfing it is optional | func ImageNameToAppName(name types.ACIdentifier) (*types.ACName, error) | // ImageNameToAppName converts the full name of image to an app name without special
// characters - we use it as a default app name when specyfing it is optional
func ImageNameToAppName(name types.ACIdentifier) (*types.ACName, error) | {
parts := strings.Split(name.String(), "/")
last := parts[len(parts)-1]
sn, err := types.SanitizeACName(last)
if err != nil {
return nil, err
}
return types.MustACName(sn), nil
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage1/init/kvm/network.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/network.go#L32-L38 | go | train | // GetNetworkDescriptions converts activeNets to netDescribers | func GetNetworkDescriptions(n *networking.Networking) []NetDescriber | // GetNetworkDescriptions converts activeNets to netDescribers
func GetNetworkDescriptions(n *networking.Networking) []NetDescriber | {
var nds []NetDescriber
for _, an := range n.GetActiveNetworks() {
nds = append(nds, an)
}
return nds
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage1/init/kvm/network.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/network.go#L55-L66 | go | train | // GetKVMNetArgs returns additional arguments that need to be passed
// to lkvm tool to configure networks properly.
// Logic is based on Network configuration extracted from Networking struct
// and essentially from activeNets that expose netDescriber behavior | func GetKVMNetArgs(nds []NetDescriber) ([]string, error) | // GetKVMNetArgs returns additional arguments that need to be passed
// to lkvm tool to configure networks properly.
// Logic is based on Network configuration extracted from Networking struct
// and essentially from activeNets that expose netDescriber behavior
func GetKVMNetArgs(nds []NetDescriber) ([]string, error) | {
var lkvmArgs []string
for _, nd := range nds {
lkvmArgs = append(lkvmArgs, "--network")
lkvmArg := fmt.Sprintf("mode=tap,tapif=%s,host_ip=%s,guest_ip=%s", nd.IfName(), nd.Gateway(), nd.GuestIP())
lkvmArgs = append(lkvmArgs, lkvmArg)
}
return lkvmArgs, nil
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage1/init/kvm/network.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage1/init/kvm/network.go#L70-L83 | go | train | // generateMacAddress returns net.HardwareAddr filled with fixed 3 byte prefix
// complemented by 3 random bytes. | func generateMacAddress() (net.HardwareAddr, error) | // generateMacAddress returns net.HardwareAddr filled with fixed 3 byte prefix
// complemented by 3 random bytes.
func generateMacAddress() (net.HardwareAddr, error) | {
mac := []byte{
2, // locally administered unicast
0x65, 0x02, // OUI (randomly chosen by jell)
0, 0, 0, // bytes to randomly overwrite
}
_, err := rand.Read(mac[3:6])
if err != nil {
return nil, errwrap.Wrap(errors.New("cannot generate random mac address"), err)
}
return mac, nil
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | tools/depsgen/util.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/tools/depsgen/util.go#L30-L44 | go | train | // toMap creates a map from passed strings. This function expects an
// even number of strings, otherwise it will bail out. Odd (first,
// third and so on) strings are keys, even (second, fourth and so on)
// strings are values. | func toMap(kv ...string) map[string]string | // toMap creates a map from passed strings. This function expects an
// even number of strings, otherwise it will bail out. Odd (first,
// third and so on) strings are keys, even (second, fourth and so on)
// strings are values.
func toMap(kv ...string) map[string]string | {
if len(kv)%2 != 0 {
common.Die("Expected even number of strings in toMap")
}
r := make(map[string]string, len(kv))
lastKey := ""
for i, kv := range kv {
if i%2 == 0 {
lastKey = kv
} else {
r[lastKey] = kv
}
}
return r
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | tools/depsgen/util.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/tools/depsgen/util.go#L54-L59 | go | train | // replacePlaceholders replaces placeholders with values in kv in
// initial str. Placeholders are in form of !!!FOO!!!, but those
// passed here should be without exclamation marks. | func replacePlaceholders(str string, kv ...string) string | // replacePlaceholders replaces placeholders with values in kv in
// initial str. Placeholders are in form of !!!FOO!!!, but those
// passed here should be without exclamation marks.
func replacePlaceholders(str string, kv ...string) string | {
for ph, value := range toMap(kv...) {
str = strings.Replace(str, "!!!"+ph+"!!!", value, -1)
}
return str
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | tools/depsgen/util.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/tools/depsgen/util.go#L62-L66 | go | train | // standardFlags returns a new flag set with target flag already set up | func standardFlags(cmd string) (*flag.FlagSet, *string) | // standardFlags returns a new flag set with target flag already set up
func standardFlags(cmd string) (*flag.FlagSet, *string) | {
f := flag.NewFlagSet(appName()+" "+cmd, flag.ExitOnError)
target := f.String("target", "", "Make target (example: $(FOO_BINARY))")
return f, target
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | stage0/enter.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/stage0/enter.go#L34-L55 | go | train | // Enter enters the pod/app by exec()ing the stage1's /enter similar to /init
// /enter can expect to have its CWD set to the app root.
// appName and command are supplied to /enter on argv followed by any arguments.
// stage1Path is the path of the stage1 rootfs | func Enter(cdir string, podPID int, appName types.ACName, stage1Path string, cmdline []string) error | // Enter enters the pod/app by exec()ing the stage1's /enter similar to /init
// /enter can expect to have its CWD set to the app root.
// appName and command are supplied to /enter on argv followed by any arguments.
// stage1Path is the path of the stage1 rootfs
func Enter(cdir string, podPID int, appName types.ACName... | {
if err := os.Chdir(cdir); err != nil {
return errwrap.Wrap(errors.New("error changing to dir"), err)
}
ep, err := getStage1Entrypoint(cdir, enterEntrypoint)
if err != nil {
return errwrap.Wrap(errors.New("error determining 'enter' entrypoint"), err)
}
argv := []string{filepath.Join(stage1Path, ep)}
argv... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | networking/net_plugin.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/networking/net_plugin.go#L54-L73 | go | train | // Executes a given network plugin. If successful, mutates n.runtime with
// the runtime information | func (e *podEnv) netPluginAdd(n *activeNet, netns string) error | // Executes a given network plugin. If successful, mutates n.runtime with
// the runtime information
func (e *podEnv) netPluginAdd(n *activeNet, netns string) error | {
output, err := e.execNetPlugin("ADD", n, netns)
if err != nil {
return pluginErr(err, output)
}
pr := cnitypes.Result{}
if err = json.Unmarshal(output, &pr); err != nil {
err = errwrap.Wrap(fmt.Errorf("parsing %q", string(output)), err)
return errwrap.Wrap(fmt.Errorf("error parsing %q result", n.conf.Nam... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/api_service.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L89-L104 | go | train | // copyPod copies the immutable information of the pod into the new pod. | func copyPod(pod *v1alpha.Pod) *v1alpha.Pod | // copyPod copies the immutable information of the pod into the new pod.
func copyPod(pod *v1alpha.Pod) *v1alpha.Pod | {
p := &v1alpha.Pod{
Id: pod.Id,
Manifest: pod.Manifest,
Annotations: pod.Annotations,
}
for _, app := range pod.Apps {
p.Apps = append(p.Apps, &v1alpha.App{
Name: app.Name,
Image: app.Image,
Annotations: app.Annotations,
})
}
return p
} |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/api_service.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L107-L119 | go | train | // copyImage copies the image object to avoid modification on the original one. | func copyImage(img *v1alpha.Image) *v1alpha.Image | // copyImage copies the image object to avoid modification on the original one.
func copyImage(img *v1alpha.Image) *v1alpha.Image | {
return &v1alpha.Image{
BaseFormat: img.BaseFormat,
Id: img.Id,
Name: img.Name,
Version: img.Version,
ImportTimestamp: img.ImportTimestamp,
Manifest: img.Manifest,
Size: img.Size,
Annotations: img.Annotations,
Labels: img.Labels,
... |
rkt/rkt | 0c8765619cae3391a9ffa12c8dbd12ba7a475eb8 | rkt/api_service.go | https://github.com/rkt/rkt/blob/0c8765619cae3391a9ffa12c8dbd12ba7a475eb8/rkt/api_service.go#L154-L170 | go | train | // GetInfo returns the information about the rkt, appc, api server version. | func (s *v1AlphaAPIServer) GetInfo(context.Context, *v1alpha.GetInfoRequest) (*v1alpha.GetInfoResponse, error) | // GetInfo returns the information about the rkt, appc, api server version.
func (s *v1AlphaAPIServer) GetInfo(context.Context, *v1alpha.GetInfoRequest) (*v1alpha.GetInfoResponse, error) | {
return &v1alpha.GetInfoResponse{
Info: &v1alpha.Info{
RktVersion: version.Version,
AppcVersion: schema.AppContainerVersion.String(),
ApiVersion: supportedAPIVersion,
GlobalFlags: &v1alpha.GlobalFlags{
Dir: getDataDir(),
SystemConfigDir: globalFlags.SystemConfigDir,
Loca... |
Dataset Card for CodeSearchNet for CodeGen
This is a processed version of the CodeSearchNet dataset. Namely, I separated the doc (documentation/docstring), sign (function signature), and output (function body) into separate fields; doc and sign are concatenated (according to the correct order of the programming language) into the problem field, making it suitable for the code generation task.
Dataset Details
Dataset Description
- Curated by: [More Information Needed]
- Funded by [optional]: [More Information Needed]
- Shared by [optional]: [More Information Needed]
- Language(s) (NLP): code
- License: apache-2.0
Dataset Sources [optional]
- Repository: [More Information Needed]
- Paper [optional]: [More Information Needed]
- Demo [optional]: [More Information Needed]
Uses
Direct Use
[More Information Needed]
Out-of-Scope Use
[More Information Needed]
Dataset Structure
[More Information Needed]
Dataset Creation
Curation Rationale
[More Information Needed]
Source Data
Data Collection and Processing
During processing of the original dataset, 731 records were ignored due to various reasons:
- python: no docstring at function begin: 651 cases
- java: code cutoff at wrong end: 49 cases
- php: multiple fields/methods: 17 cases
- ruby: parse error: 7 cases
- python: mixing spaces and tabs: 4 cases
- go: no method body: 1 cases
- php: code cutoff at wrong end: 1 cases
- php: no method body: 1 cases
Who are the source data producers?
[More Information Needed]
Annotations [optional]
Annotation process
[More Information Needed]
Who are the annotators?
[More Information Needed]
Personal and Sensitive Information
[More Information Needed]
Bias, Risks, and Limitations
[More Information Needed]
Recommendations
Users should be made aware of the risks, biases and limitations of the dataset. More information needed for further recommendations.
Citation [optional]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
Glossary [optional]
[More Information Needed]
More Information [optional]
[More Information Needed]
Dataset Card Authors [optional]
Pengyu Nie pynie@uwaterloo.ca
Dataset Card Contact
[More Information Needed]
- Downloads last month
- 10