_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q27800 | ToFile | train | func (c *Config) ToFile(path string) error {
var w bytes.Buffer
e := toml.NewEncoder(&w)
t := new(tomlConfig)
t.fromConfig(c)
if err := e.Encode(*t); err != nil {
return err
}
return ioutil.WriteFile(path, w.Bytes(), 0644)
} | go | {
"resource": ""
} |
q27801 | Validate | train | func (c *Config) Validate(onExecution bool) error {
if err := c.RootConfig.Validate(onExecution); err != nil {
return errors.Wrapf(err, "root config")
}
if err := c.RuntimeConfig.Validate(onExecution); err != nil {
return errors.Wrapf(err, "runtime config")
}
if err := c.NetworkConfig.Validate(onExecution); ... | go | {
"resource": ""
} |
q27802 | Validate | train | func (c *RootConfig) Validate(onExecution bool) error {
if onExecution {
if err := os.MkdirAll(c.LogDir, 0700); err != nil {
return errors.Wrapf(err, "invalid log_dir")
}
}
return nil
} | go | {
"resource": ""
} |
q27803 | Validate | train | func (c *RuntimeConfig) Validate(onExecution bool) error {
// This is somehow duplicated with server.getUlimitsFromConfig under server/utils.go
// but I don't want to export that function for the sake of validation here
// so, keep it in mind if things start to blow up.
// Reason for having this here is that I don'... | go | {
"resource": ""
} |
q27804 | Validate | train | func (c *NetworkConfig) Validate(onExecution bool) error {
if onExecution {
if _, err := os.Stat(c.NetworkDir); err != nil {
return errors.Wrapf(err, "invalid network_dir")
}
for _, pluginDir := range c.PluginDir {
if err := os.MkdirAll(pluginDir, 0755); err != nil {
return errors.Wrapf(err, "invalid ... | go | {
"resource": ""
} |
q27805 | privilegedSandbox | train | func (s *Server) privilegedSandbox(req *pb.RunPodSandboxRequest) bool {
securityContext := req.GetConfig().GetLinux().GetSecurityContext()
if securityContext == nil {
return false
}
if securityContext.Privileged {
return true
}
namespaceOptions := securityContext.GetNamespaceOptions()
if namespaceOptions =... | go | {
"resource": ""
} |
q27806 | runtimeHandler | train | func (s *Server) runtimeHandler(req *pb.RunPodSandboxRequest) (string, error) {
handler := req.GetRuntimeHandler()
if handler == "" {
return handler, nil
}
runtime, ok := s.Runtime().(*oci.Runtime)
if !ok {
return "", fmt.Errorf("runtime interface conversion error")
}
if _, err := runtime.ValidateRuntimeHa... | go | {
"resource": ""
} |
q27807 | RunPodSandbox | train | func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest) (resp *pb.RunPodSandboxResponse, err error) {
// platform dependent call
return s.runPodSandbox(ctx, req)
} | go | {
"resource": ""
} |
q27808 | StopPodSandbox | train | func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxRequest) (resp *pb.StopPodSandboxResponse, err error) {
// platform dependent call
return s.stopPodSandbox(ctx, req)
} | go | {
"resource": ""
} |
q27809 | stopAllPodSandboxes | train | func (s *Server) stopAllPodSandboxes(ctx context.Context) {
logrus.Debugf("stopAllPodSandboxes")
for _, sb := range s.ContainerServer.ListSandboxes() {
pod := &pb.StopPodSandboxRequest{
PodSandboxId: sb.ID(),
}
if _, err := s.StopPodSandbox(ctx, pod); err != nil {
logrus.Warnf("could not StopPodSandbox %s... | go | {
"resource": ""
} |
q27810 | localeToLanguage | train | func localeToLanguage(locale string) string {
locale = strings.Replace(strings.SplitN(locale, ".", 2)[0], "_", "-", 1)
langString, ok := localeToLanguageMap[strings.ToLower(locale)]
if !ok {
langString = locale
}
return langString
} | go | {
"resource": ""
} |
q27811 | ContainerStateFromDisk | train | func (c *ContainerServer) ContainerStateFromDisk(ctr *oci.Container) error {
if err := ctr.FromDisk(); err != nil {
return err
}
// ignore errors, this is a best effort to have up-to-date info about
// a given container before its state gets stored
c.runtime.UpdateContainerStatus(ctr)
return nil
} | go | {
"resource": ""
} |
q27812 | ContainerStateToDisk | train | func (c *ContainerServer) ContainerStateToDisk(ctr *oci.Container) error {
// ignore errors, this is a best effort to have up-to-date info about
// a given container before its state gets stored
c.Runtime().UpdateContainerStatus(ctr)
jsonSource, err := ioutils.NewAtomicFileWriter(ctr.StatePath(), 0644)
if err != ... | go | {
"resource": ""
} |
q27813 | ReserveContainerName | train | func (c *ContainerServer) ReserveContainerName(id, name string) (string, error) {
if err := c.ctrNameIndex.Reserve(name, id); err != nil {
err = fmt.Errorf("error reserving ctr name %s for id %s", name, id)
logrus.Warn(err)
return "", err
}
return name, nil
} | go | {
"resource": ""
} |
q27814 | ReservePodName | train | func (c *ContainerServer) ReservePodName(id, name string) (string, error) {
if err := c.podNameIndex.Reserve(name, id); err != nil {
err = fmt.Errorf("error reserving pod name %s for id %s", name, id)
logrus.Warn(err)
return "", err
}
return name, nil
} | go | {
"resource": ""
} |
q27815 | AddContainer | train | func (c *ContainerServer) AddContainer(ctr *oci.Container) {
sandbox := c.state.sandboxes.Get(ctr.Sandbox())
if sandbox == nil {
return
}
sandbox.AddContainer(ctr)
c.state.containers.Add(ctr.ID(), ctr)
} | go | {
"resource": ""
} |
q27816 | AddInfraContainer | train | func (c *ContainerServer) AddInfraContainer(ctr *oci.Container) {
c.state.infraContainers.Add(ctr.ID(), ctr)
} | go | {
"resource": ""
} |
q27817 | GetContainer | train | func (c *ContainerServer) GetContainer(id string) *oci.Container {
return c.state.containers.Get(id)
} | go | {
"resource": ""
} |
q27818 | GetInfraContainer | train | func (c *ContainerServer) GetInfraContainer(id string) *oci.Container {
return c.state.infraContainers.Get(id)
} | go | {
"resource": ""
} |
q27819 | HasContainer | train | func (c *ContainerServer) HasContainer(id string) bool {
return c.state.containers.Get(id) != nil
} | go | {
"resource": ""
} |
q27820 | RemoveContainer | train | func (c *ContainerServer) RemoveContainer(ctr *oci.Container) {
sbID := ctr.Sandbox()
sb := c.state.sandboxes.Get(sbID)
if sb == nil {
return
}
sb.RemoveContainer(ctr)
c.state.containers.Delete(ctr.ID())
} | go | {
"resource": ""
} |
q27821 | RemoveInfraContainer | train | func (c *ContainerServer) RemoveInfraContainer(ctr *oci.Container) {
c.state.infraContainers.Delete(ctr.ID())
} | go | {
"resource": ""
} |
q27822 | ListContainers | train | func (c *ContainerServer) ListContainers(filters ...func(*oci.Container) bool) ([]*oci.Container, error) {
containers := c.listContainers()
if len(filters) == 0 {
return containers, nil
}
filteredContainers := make([]*oci.Container, 0, len(containers))
for _, container := range containers {
for _, filter := ra... | go | {
"resource": ""
} |
q27823 | AddSandbox | train | func (c *ContainerServer) AddSandbox(sb *sandbox.Sandbox) error {
c.state.sandboxes.Add(sb.ID(), sb)
c.stateLock.Lock()
defer c.stateLock.Unlock()
return c.addSandboxPlatform(sb)
} | go | {
"resource": ""
} |
q27824 | GetSandbox | train | func (c *ContainerServer) GetSandbox(id string) *sandbox.Sandbox {
return c.state.sandboxes.Get(id)
} | go | {
"resource": ""
} |
q27825 | GetSandboxContainer | train | func (c *ContainerServer) GetSandboxContainer(id string) *oci.Container {
sb := c.state.sandboxes.Get(id)
if sb == nil {
return nil
}
return sb.InfraContainer()
} | go | {
"resource": ""
} |
q27826 | HasSandbox | train | func (c *ContainerServer) HasSandbox(id string) bool {
return c.state.sandboxes.Get(id) != nil
} | go | {
"resource": ""
} |
q27827 | RemoveSandbox | train | func (c *ContainerServer) RemoveSandbox(id string) error {
sb := c.state.sandboxes.Get(id)
if sb == nil {
return nil
}
c.stateLock.Lock()
defer c.stateLock.Unlock()
if err := c.removeSandboxPlatform(sb); err != nil {
return err
}
c.state.sandboxes.Delete(id)
return nil
} | go | {
"resource": ""
} |
q27828 | PodSandboxStatus | train | func (s *Server) PodSandboxStatus(ctx context.Context, req *pb.PodSandboxStatusRequest) (resp *pb.PodSandboxStatusResponse, err error) {
const operation = "pod_sandbox_status"
defer func() {
recordOperation(operation, time.Now())
recordError(operation, err)
}()
logrus.Debugf("PodSandboxStatusRequest %+v", req)... | go | {
"resource": ""
} |
q27829 | Status | train | func (s *Server) Status(ctx context.Context, req *pb.StatusRequest) (resp *pb.StatusResponse, err error) {
const operation = "status"
defer func() {
recordOperation(operation, time.Now())
recordError(operation, err)
}()
runtimeCondition := &pb.RuntimeCondition{
Type: pb.RuntimeReady,
Status: true,
}
ne... | go | {
"resource": ""
} |
q27830 | Register | train | func Register() {
registerMetrics.Do(func() {
prometheus.MustRegister(CRIOOperations)
prometheus.MustRegister(CRIOOperationsLatency)
prometheus.MustRegister(CRIOOperationsErrors)
})
} | go | {
"resource": ""
} |
q27831 | prepareReference | train | func (svc *imageService) prepareReference(imageName string, options *copy.Options) (types.ImageReference, error) {
if imageName == "" {
return nil, storage.ErrNotAnImage
}
srcRef, err := alltransports.ParseImageName(imageName)
if err != nil {
if svc.defaultTransport == "" {
return nil, err
}
srcRef2, er... | go | {
"resource": ""
} |
q27832 | UpdateRuntimeConfig | train | func (s *Server) UpdateRuntimeConfig(ctx context.Context, req *pb.UpdateRuntimeConfigRequest) (resp *pb.UpdateRuntimeConfigResponse, err error) {
const operation = "update_runtime_config"
defer func() {
recordOperation(operation, time.Now())
recordError(operation, err)
}()
return &pb.UpdateRuntimeConfigRespons... | go | {
"resource": ""
} |
q27833 | Attach | train | func (ss StreamService) Attach(containerID string, inputStream io.Reader, outputStream, errorStream io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize) error {
c, err := ss.runtimeServer.GetContainerFromShortID(containerID)
if err != nil {
return fmt.Errorf("could not find container %q: %v", contain... | go | {
"resource": ""
} |
q27834 | networkStart | train | func (s *Server) networkStart(sb *sandbox.Sandbox) (podIP string, result cnitypes.Result, err error) {
if sb.HostNetwork() {
return s.hostIP, nil, nil
}
// Ensure network resources are cleaned up if the plugin succeeded
// but an error happened between plugin success and the end of networkStart()
defer func() {... | go | {
"resource": ""
} |
q27835 | getSandboxIP | train | func (s *Server) getSandboxIP(sb *sandbox.Sandbox) (string, error) {
if sb.HostNetwork() {
return s.hostIP, nil
}
podNetwork := newPodNetwork(sb)
result, err := s.netPlugin.GetPodNetworkStatus(podNetwork)
if err != nil {
return "", fmt.Errorf("failed to get network status for pod sandbox %s(%s): %v", sb.Name(... | go | {
"resource": ""
} |
q27836 | networkStop | train | func (s *Server) networkStop(sb *sandbox.Sandbox) {
if sb.HostNetwork() {
return
}
if err := s.hostportManager.Remove(sb.ID(), &hostport.PodPortMapping{
Name: sb.Name(),
PortMappings: sb.PortMappings(),
HostNetwork: false,
}); err != nil {
logrus.Warnf("failed to remove hostport for pod sandbox ... | go | {
"resource": ""
} |
q27837 | getUserFromImage | train | func getUserFromImage(user string) (*int64, string) {
// return both empty if user is not specified in the image.
if user == "" {
return nil, ""
}
// split instances where the id may contain user:group
user = strings.Split(user, ":")[0]
// user could be either uid or user name. Try to interpret as numeric uid.
... | go | {
"resource": ""
} |
q27838 | ReopenContainerLog | train | func (s *Server) ReopenContainerLog(ctx context.Context, req *pb.ReopenContainerLogRequest) (resp *pb.ReopenContainerLogResponse, err error) {
const operation = "container_reopen_log"
defer func() {
recordOperation(operation, time.Now())
recordError(operation, err)
}()
logrus.Debugf("ReopenContainerLogRequest ... | go | {
"resource": ""
} |
q27839 | filterSandbox | train | func filterSandbox(p *pb.PodSandbox, filter *pb.PodSandboxFilter) bool {
if filter != nil {
if filter.State != nil {
if p.State != filter.State.State {
return false
}
}
if filter.LabelSelector != nil {
sel := fields.SelectorFromSet(filter.LabelSelector)
if !sel.Matches(fields.Set(p.Labels)) {
... | go | {
"resource": ""
} |
q27840 | ListPodSandbox | train | func (s *Server) ListPodSandbox(ctx context.Context, req *pb.ListPodSandboxRequest) (resp *pb.ListPodSandboxResponse, err error) {
const operation = "list_pod_sandbox"
defer func() {
recordOperation(operation, time.Now())
recordError(operation, err)
}()
logrus.Debugf("ListPodSandboxRequest %+v", req)
var pods... | go | {
"resource": ""
} |
q27841 | RemoveContainer | train | func (s *Server) RemoveContainer(ctx context.Context, req *pb.RemoveContainerRequest) (resp *pb.RemoveContainerResponse, err error) {
const operation = "remove_container"
defer func() {
recordOperation(operation, time.Now())
recordError(operation, err)
}()
logrus.Debugf("RemoveContainerRequest: %+v", req)
// ... | go | {
"resource": ""
} |
q27842 | Close | train | func (w *wrapReadCloser) Close() error {
w.reader.Close()
w.writer.Close()
return nil
} | go | {
"resource": ""
} |
q27843 | Validate | train | func (c *Config) Validate(onExecution bool) error {
switch c.ImageVolumes {
case lib.ImageVolumesMkdir:
case lib.ImageVolumesIgnore:
case lib.ImageVolumesBind:
default:
return fmt.Errorf("unrecognized image volume type specified")
}
if err := c.Config.Validate(onExecution); err != nil {
return errors.Wrapf(... | go | {
"resource": ""
} |
q27844 | newRuntimeOCI | train | func newRuntimeOCI(r *Runtime, handler *RuntimeHandler) RuntimeImpl {
return &runtimeOCI{
Runtime: r,
path: handler.RuntimePath,
root: handler.RuntimeRoot,
}
} | go | {
"resource": ""
} |
q27845 | Less | train | func (history *History) Less(i, j int) bool {
sandboxes := *history
// FIXME: state access should be serialized
return sandboxes[j].createdAt.Before(sandboxes[i].createdAt)
} | go | {
"resource": ""
} |
q27846 | Swap | train | func (history *History) Swap(i, j int) {
sandboxes := *history
sandboxes[i], sandboxes[j] = sandboxes[j], sandboxes[i]
} | go | {
"resource": ""
} |
q27847 | NewExecIO | train | func NewExecIO(id, root string, tty, stdin bool) (*ExecIO, error) {
fifos, err := newFifos(root, id, tty, stdin)
if err != nil {
return nil, err
}
stdio, closer, err := newStdioPipes(fifos)
if err != nil {
return nil, err
}
return &ExecIO{
id: id,
fifos: fifos,
stdioPipes: stdio,
closer:... | go | {
"resource": ""
} |
q27848 | Attach | train | func (e *ExecIO) Attach(opts AttachOptions) <-chan struct{} {
var wg sync.WaitGroup
var stdinStreamRC io.ReadCloser
if e.stdin != nil && opts.Stdin != nil {
stdinStreamRC = cioutil.NewWrapReadCloser(opts.Stdin)
wg.Add(1)
go func() {
if _, err := io.Copy(e.stdin, stdinStreamRC); err != nil {
logrus.WithE... | go | {
"resource": ""
} |
q27849 | getContainerNetIO | train | func getContainerNetIO(stats *libcontainer.Stats) (received uint64, transmitted uint64) {
for _, iface := range stats.Interfaces {
received += iface.RxBytes
transmitted += iface.TxBytes
}
return
} | go | {
"resource": ""
} |
q27850 | getMemLimit | train | func getMemLimit(cgroupLimit uint64) uint64 {
si := &syscall.Sysinfo_t{}
err := syscall.Sysinfo(si)
if err != nil {
return cgroupLimit
}
physicalLimit := si.Totalram
if cgroupLimit > physicalLimit {
return physicalLimit
}
return cgroupLimit
} | go | {
"resource": ""
} |
q27851 | streamKey | train | func streamKey(id, name string, stream StreamType) string {
return strings.Join([]string{id, name, string(stream)}, "-")
} | go | {
"resource": ""
} |
q27852 | WithFIFOs | train | func WithFIFOs(fifos *cio.FIFOSet) ContainerIOOpts {
return func(c *ContainerIO) error {
c.fifos = fifos
return nil
}
} | go | {
"resource": ""
} |
q27853 | WithNewFIFOs | train | func WithNewFIFOs(root string, tty, stdin bool) ContainerIOOpts {
return func(c *ContainerIO) error {
fifos, err := newFifos(root, c.id, tty, stdin)
if err != nil {
return err
}
return WithFIFOs(fifos)(c)
}
} | go | {
"resource": ""
} |
q27854 | NewContainerIO | train | func NewContainerIO(id string, opts ...ContainerIOOpts) (_ *ContainerIO, err error) {
c := &ContainerIO{
id: id,
stdoutGroup: cioutil.NewWriterGroup(),
stderrGroup: cioutil.NewWriterGroup(),
}
for _, opt := range opts {
if err := opt(c); err != nil {
return nil, err
}
}
if c.fifos == nil {
... | go | {
"resource": ""
} |
q27855 | Pipe | train | func (c *ContainerIO) Pipe() {
wg := c.closer.wg
wg.Add(1)
go func() {
if _, err := io.Copy(c.stdoutGroup, c.stdout); err != nil {
logrus.WithError(err).Errorf("Failed to pipe stdout of container %q", c.id)
}
c.stdout.Close()
c.stdoutGroup.Close()
wg.Done()
logrus.Infof("Finish piping stdout of contai... | go | {
"resource": ""
} |
q27856 | AddOutput | train | func (c *ContainerIO) AddOutput(name string, stdout, stderr io.WriteCloser) (io.WriteCloser, io.WriteCloser) {
var oldStdout, oldStderr io.WriteCloser
if stdout != nil {
key := streamKey(c.id, name, Stdout)
oldStdout = c.stdoutGroup.Get(key)
c.stdoutGroup.Add(key, stdout)
}
if stderr != nil {
key := streamK... | go | {
"resource": ""
} |
q27857 | GetLogs | train | func (c *ContainerServer) GetLogs(container string, logChan chan string, opts LogOptions) error {
defer close(logChan)
// Get the full ID of the container
ctr, err := c.LookupContainer(container)
if err != nil {
return err
}
containerID := ctr.ID()
sandbox := ctr.Sandbox()
if sandbox == "" {
sandbox = cont... | go | {
"resource": ""
} |
q27858 | NewContainer | train | func NewContainer(id string, name string, bundlePath string, logPath string, netns string, labels map[string]string, crioAnnotations map[string]string, annotations map[string]string, image string, imageName string, imageRef string, metadata *pb.ContainerMetadata, sandbox string, terminal bool, stdin bool, stdinOnce boo... | go | {
"resource": ""
} |
q27859 | GetStopSignal | train | func (c *Container) GetStopSignal() string {
if c.stopSignal == "" {
return defaultStopSignal
}
cleanSignal := strings.TrimPrefix(strings.ToUpper(c.stopSignal), "SIG")
_, ok := signal.SignalMap[cleanSignal]
if !ok {
return defaultStopSignal
}
return cleanSignal
} | go | {
"resource": ""
} |
q27860 | StopSignal | train | func (c *Container) StopSignal() syscall.Signal {
if c.stopSignal == "" {
return defaultStopSignalInt
}
cleanSignal := strings.TrimPrefix(strings.ToUpper(c.stopSignal), "SIG")
sig, ok := signal.SignalMap[cleanSignal]
if !ok {
return defaultStopSignalInt
}
return sig
} | go | {
"resource": ""
} |
q27861 | FromDisk | train | func (c *Container) FromDisk() error {
jsonSource, err := os.Open(c.StatePath())
if err != nil {
return err
}
defer jsonSource.Close()
dec := json.NewDecoder(jsonSource)
return dec.Decode(c.state)
} | go | {
"resource": ""
} |
q27862 | NetNsPath | train | func (c *Container) NetNsPath() (string, error) {
if c.state == nil {
return "", fmt.Errorf("container state is not populated")
}
if c.netns == "" {
return fmt.Sprintf("/proc/%d/ns/net", c.state.Pid), nil
}
return c.netns, nil
} | go | {
"resource": ""
} |
q27863 | State | train | func (c *Container) State() *ContainerState {
c.opLock.RLock()
defer c.opLock.RUnlock()
return c.state
} | go | {
"resource": ""
} |
q27864 | AddVolume | train | func (c *Container) AddVolume(v ContainerVolume) {
c.volumes = append(c.volumes, v)
} | go | {
"resource": ""
} |
q27865 | SetStartFailed | train | func (c *Container) SetStartFailed(err error) {
c.opLock.Lock()
defer c.opLock.Unlock()
// adjust finished and started times
c.state.Finished, c.state.Started = c.state.Created, c.state.Created
if err != nil {
c.state.Error = err.Error()
}
} | go | {
"resource": ""
} |
q27866 | Description | train | func (c *Container) Description() string {
return fmt.Sprintf("%s/%s/%s", c.Labels()[types.KubernetesPodNamespaceLabel], c.Labels()[types.KubernetesPodNameLabel], c.Labels()[types.KubernetesContainerNameLabel])
} | go | {
"resource": ""
} |
q27867 | NewWriteCloseInformer | train | func NewWriteCloseInformer(wc io.WriteCloser) (io.WriteCloser, <-chan struct{}) {
close := make(chan struct{})
return &writeCloseInformer{
close: close,
wc: wc,
}, close
} | go | {
"resource": ""
} |
q27868 | Write | train | func (w *writeCloseInformer) Write(p []byte) (int, error) {
return w.wc.Write(p)
} | go | {
"resource": ""
} |
q27869 | Close | train | func (w *writeCloseInformer) Close() error {
err := w.wc.Close()
close(w.close)
return err
} | go | {
"resource": ""
} |
q27870 | Write | train | func (n *nopWriteCloser) Write(p []byte) (int, error) {
return n.w.Write(p)
} | go | {
"resource": ""
} |
q27871 | Write | train | func (s *serialWriteCloser) Write(data []byte) (int, error) {
s.mu.Lock()
defer s.mu.Unlock()
return s.wc.Write(data)
} | go | {
"resource": ""
} |
q27872 | Close | train | func (s *serialWriteCloser) Close() error {
s.mu.Lock()
defer s.mu.Unlock()
return s.wc.Close()
} | go | {
"resource": ""
} |
q27873 | IsEnabled | train | func IsEnabled() bool {
enabled := false
// Check if Seccomp is supported, via CONFIG_SECCOMP.
if err := unix.Prctl(unix.PR_GET_SECCOMP, 0, 0, 0, 0); err != unix.EINVAL {
// Make sure the kernel has CONFIG_SECCOMP_FILTER.
if err := unix.Prctl(unix.PR_SET_SECCOMP, unix.SECCOMP_MODE_FILTER, 0, 0, 0); err != unix.E... | go | {
"resource": ""
} |
q27874 | LoadProfileFromStruct | train | func LoadProfileFromStruct(config *Seccomp, specgen *generate.Generator) error {
return setupSeccomp(config, specgen)
} | go | {
"resource": ""
} |
q27875 | LoadProfileFromBytes | train | func LoadProfileFromBytes(body []byte, specgen *generate.Generator) error {
config := &Seccomp{}
if err := json.Unmarshal(body, config); err != nil {
return fmt.Errorf("decoding seccomp profile failed: %v", err)
}
return setupSeccomp(config, specgen)
} | go | {
"resource": ""
} |
q27876 | Remove | train | func (c *ContainerServer) Remove(ctx context.Context, container string, force bool) (string, error) {
ctr, err := c.LookupContainer(container)
if err != nil {
return "", err
}
ctrID := ctr.ID()
cStatus := ctr.State()
switch cStatus.Status {
case oci.ContainerStatePaused:
return "", errors.Errorf("cannot rem... | go | {
"resource": ""
} |
q27877 | Register | train | func Register(v interface{}, args ...string) {
var (
t = tryDereference(v)
p = path.Join(args...)
)
mu.Lock()
defer mu.Unlock()
if et, ok := registry[t]; ok {
if et != p {
panic(errors.Errorf("type registred with alternate path %q != %q", et, p))
}
return
}
registry[t] = p
} | go | {
"resource": ""
} |
q27878 | Is | train | func Is(any *types.Any, v interface{}) bool {
// call to check that v is a pointer
tryDereference(v)
url, err := TypeURL(v)
if err != nil {
return false
}
return any.TypeUrl == url
} | go | {
"resource": ""
} |
q27879 | MarshalAny | train | func MarshalAny(v interface{}) (*types.Any, error) {
var marshal func(v interface{}) ([]byte, error)
switch t := v.(type) {
case *types.Any:
// avoid reserializing the type if we have an any.
return t, nil
case proto.Message:
marshal = func(v interface{}) ([]byte, error) {
return proto.Marshal(t)
}
defa... | go | {
"resource": ""
} |
q27880 | UnmarshalAny | train | func UnmarshalAny(any *types.Any) (interface{}, error) {
t, err := getTypeByURL(any.TypeUrl)
if err != nil {
return nil, err
}
v := reflect.New(t.t).Interface()
if t.isProto {
err = proto.Unmarshal(any.Value, v.(proto.Message))
} else {
err = json.Unmarshal(any.Value, v)
}
return v, err
} | go | {
"resource": ""
} |
q27881 | resolveSymbolicLink | train | func resolveSymbolicLink(path, scope string) (string, error) {
info, err := os.Lstat(path)
if err != nil {
return "", err
}
if info.Mode()&os.ModeSymlink != os.ModeSymlink {
return path, nil
}
if scope == "" {
scope = "/"
}
return symlink.FollowSymlinkInScope(path, scope)
} | go | {
"resource": ""
} |
q27882 | buildOCIProcessArgs | train | func buildOCIProcessArgs(containerKubeConfig *pb.ContainerConfig, imageOCIConfig *v1.Image) ([]string, error) {
// # Start the nginx container using the default command, but use custom
// arguments (arg1 .. argN) for that command.
// kubectl run nginx --image=nginx -- <arg1> <arg2> ... <argN>
// # Start the nginx ... | go | {
"resource": ""
} |
q27883 | setupContainerUser | train | func setupContainerUser(specgen *generate.Generator, rootfs, mountLabel, ctrRunDir string, sc *pb.LinuxContainerSecurityContext, imageConfig *v1.Image) error {
if sc == nil {
return nil
}
if sc.GetRunAsGroup() != nil && sc.GetRunAsUser() == nil && sc.GetRunAsUsername() == "" {
return fmt.Errorf("user group is sp... | go | {
"resource": ""
} |
q27884 | generateUserString | train | func generateUserString(username, imageUser string, uid *pb.Int64Value) string {
var userstr string
if uid != nil {
userstr = strconv.FormatInt(uid.GetValue(), 10)
}
if username != "" {
userstr = username
}
// We use the user from the image config if nothing is provided
if userstr == "" {
userstr = imageUs... | go | {
"resource": ""
} |
q27885 | addSecretsBindMounts | train | func addSecretsBindMounts(mountLabel, ctrRunDir string, defaultMounts []string, specgen generate.Generator) ([]rspec.Mount, error) {
containerMounts := specgen.Config.Mounts
mounts, err := secretMounts(defaultMounts, mountLabel, ctrRunDir, containerMounts)
if err != nil {
return nil, err
}
return mounts, nil
} | go | {
"resource": ""
} |
q27886 | getAppArmorProfileName | train | func (s *Server) getAppArmorProfileName(profile string) string {
if profile == "" {
return ""
}
if profile == apparmorRuntimeDefault {
// If the value is runtime/default, then return default profile.
return s.appArmorProfile
}
return strings.TrimPrefix(profile, apparmorLocalHostPrefix)
} | go | {
"resource": ""
} |
q27887 | GetRuntimeService | train | func GetRuntimeService(ctx context.Context, storageImageServer ImageServer, pauseImage, pauseImageAuthFile string) RuntimeServer {
return &runtimeService{
storageImageServer: storageImageServer,
pauseImage: pauseImage,
pauseImageAuthFile: pauseImageAuthFile,
ctx: ctx,
}
} | go | {
"resource": ""
} |
q27888 | List | train | func (c *memoryStore) List() []*Sandbox {
sandboxes := History(c.all())
sandboxes.sort()
return sandboxes
} | go | {
"resource": ""
} |
q27889 | First | train | func (c *memoryStore) First(filter StoreFilter) *Sandbox {
for _, cont := range c.all() {
if filter(cont) {
return cont
}
}
return nil
} | go | {
"resource": ""
} |
q27890 | ContainerRename | train | func (c *ContainerServer) ContainerRename(container, name string) error {
ctr, err := c.LookupContainer(container)
if err != nil {
return err
}
oldName := ctr.Name()
_, err = c.ReserveContainerName(ctr.ID(), name)
if err != nil {
return err
}
defer func() {
if err != nil {
c.ReleaseContainerName(name)... | go | {
"resource": ""
} |
q27891 | updateMetadata | train | func updateMetadata(specAnnotations map[string]string, name string) string {
oldMetadata := specAnnotations[annotations.Metadata]
containerType := specAnnotations[annotations.ContainerType]
switch containerType {
case "container":
metadata := runtime.ContainerMetadata{}
err := json.Unmarshal([]byte(oldMetadata)... | go | {
"resource": ""
} |
q27892 | GetDiskUsageStats | train | func GetDiskUsageStats(path string) (dirSize, inodeCount uint64, err error) {
err = filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
// Walk does not follow symbolic links
if err != nil {
return err
}
dirSize += uint64(info.Size())
inodeCount++
return nil
})
if err != nil ... | go | {
"resource": ""
} |
q27893 | ContainerKill | train | func (c *ContainerServer) ContainerKill(container string, killSignal syscall.Signal) (string, error) {
ctr, err := c.LookupContainer(container)
if err != nil {
return "", errors.Wrapf(err, "failed to find container %s", container)
}
c.runtime.UpdateContainerStatus(ctr)
cStatus := ctr.State()
// If the containe... | go | {
"resource": ""
} |
q27894 | Initialize | train | func (n *NetNs) Initialize() (NetNsIface, error) {
netNS, err := ns.NewNS()
if err != nil {
return nil, err
}
n.netNS = netNS
n.closed = false
n.initialized = true
return n, nil
} | go | {
"resource": ""
} |
q27895 | SymlinkCreate | train | func (n *NetNs) SymlinkCreate(name string) error {
if n.netNS == nil {
return errors.New("no netns set up")
}
b := make([]byte, 4)
_, randErr := rand.Reader.Read(b)
if randErr != nil {
return randErr
}
nsName := fmt.Sprintf("%s-%x", name, b)
symlinkPath := filepath.Join(NsRunDir, nsName)
if err := os.Sym... | go | {
"resource": ""
} |
q27896 | Path | train | func (n *NetNs) Path() string {
if n == nil || n.netNS == nil {
return ""
}
return n.netNS.Path()
} | go | {
"resource": ""
} |
q27897 | Close | train | func (n *NetNs) Close() error {
if n == nil || n.netNS == nil {
return nil
}
return n.netNS.Close()
} | go | {
"resource": ""
} |
q27898 | Remove | train | func (n *NetNs) Remove() error {
n.Lock()
defer n.Unlock()
if n.closed {
// netNsRemove() can be called multiple
// times without returning an error.
return nil
}
if err := n.symlinkRemove(); err != nil {
return err
}
if err := n.Close(); err != nil {
return err
}
n.closed = true
if n.restored ... | go | {
"resource": ""
} |
q27899 | newFifos | train | func newFifos(root, id string, tty, stdin bool) (*cio.FIFOSet, error) {
root = filepath.Join(root, "io")
if err := os.MkdirAll(root, 0700); err != nil {
return nil, err
}
fifos, err := cio.NewFIFOSetInDir(root, id, tty)
if err != nil {
return nil, err
}
if !stdin {
fifos.Stdin = ""
}
return fifos, nil
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.