repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
cri-o/cri-o
lib/sandbox/sandbox.go
AddContainer
func (s *Sandbox) AddContainer(c *oci.Container) { s.containers.Add(c.Name(), c) }
go
func (s *Sandbox) AddContainer(c *oci.Container) { s.containers.Add(c.Name(), c) }
[ "func", "(", "s", "*", "Sandbox", ")", "AddContainer", "(", "c", "*", "oci", ".", "Container", ")", "{", "s", ".", "containers", ".", "Add", "(", "c", ".", "Name", "(", ")", ",", "c", ")", "\n", "}" ]
// AddContainer adds a container to the sandbox
[ "AddContainer", "adds", "a", "container", "to", "the", "sandbox" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/sandbox.go#L328-L330
train
cri-o/cri-o
lib/sandbox/sandbox.go
GetContainer
func (s *Sandbox) GetContainer(name string) *oci.Container { return s.containers.Get(name) }
go
func (s *Sandbox) GetContainer(name string) *oci.Container { return s.containers.Get(name) }
[ "func", "(", "s", "*", "Sandbox", ")", "GetContainer", "(", "name", "string", ")", "*", "oci", ".", "Container", "{", "return", "s", ".", "containers", ".", "Get", "(", "name", ")", "\n", "}" ]
// GetContainer retrieves a container from the sandbox
[ "GetContainer", "retrieves", "a", "container", "from", "the", "sandbox" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/sandbox.go#L333-L335
train
cri-o/cri-o
lib/sandbox/sandbox.go
RemoveContainer
func (s *Sandbox) RemoveContainer(c *oci.Container) { s.containers.Delete(c.Name()) }
go
func (s *Sandbox) RemoveContainer(c *oci.Container) { s.containers.Delete(c.Name()) }
[ "func", "(", "s", "*", "Sandbox", ")", "RemoveContainer", "(", "c", "*", "oci", ".", "Container", ")", "{", "s", ".", "containers", ".", "Delete", "(", "c", ".", "Name", "(", ")", ")", "\n", "}" ]
// RemoveContainer deletes a container from the sandbox
[ "RemoveContainer", "deletes", "a", "container", "from", "the", "sandbox" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/sandbox.go#L338-L340
train
cri-o/cri-o
lib/sandbox/sandbox.go
SetInfraContainer
func (s *Sandbox) SetInfraContainer(infraCtr *oci.Container) error { if s.infraContainer != nil { return fmt.Errorf("sandbox already has an infra container") } else if infraCtr == nil { return fmt.Errorf("must provide non-nil infra container") } s.infraContainer = infraCtr return nil }
go
func (s *Sandbox) SetInfraContainer(infraCtr *oci.Container) error { if s.infraContainer != nil { return fmt.Errorf("sandbox already has an infra container") } else if infraCtr == nil { return fmt.Errorf("must provide non-nil infra container") } s.infraContainer = infraCtr return nil }
[ "func", "(", "s", "*", "Sandbox", ")", "SetInfraContainer", "(", "infraCtr", "*", "oci", ".", "Container", ")", "error", "{", "if", "s", ".", "infraContainer", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "else",...
// SetInfraContainer sets the infrastructure container of a sandbox // Attempts to set the infrastructure container after one is already present will throw an error
[ "SetInfraContainer", "sets", "the", "infrastructure", "container", "of", "a", "sandbox", "Attempts", "to", "set", "the", "infrastructure", "container", "after", "one", "is", "already", "present", "will", "throw", "an", "error" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/sandbox.go#L344-L354
train
cri-o/cri-o
lib/sandbox/sandbox.go
NetNs
func (s *Sandbox) NetNs() *NetNs { if s.netns == nil { return nil } return s.netns.Get() }
go
func (s *Sandbox) NetNs() *NetNs { if s.netns == nil { return nil } return s.netns.Get() }
[ "func", "(", "s", "*", "Sandbox", ")", "NetNs", "(", ")", "*", "NetNs", "{", "if", "s", ".", "netns", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "s", ".", "netns", ".", "Get", "(", ")", "\n", "}" ]
// NetNs retrieves the network namespace of the sandbox // If the sandbox uses the host namespace, nil is returned
[ "NetNs", "retrieves", "the", "network", "namespace", "of", "the", "sandbox", "If", "the", "sandbox", "uses", "the", "host", "namespace", "nil", "is", "returned" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/sandbox.go#L363-L368
train
cri-o/cri-o
lib/sandbox/sandbox.go
NetNsPath
func (s *Sandbox) NetNsPath() string { if s.netns == nil || s.netns.Get() == nil || s.netns.Get().symlink == nil { if s.infraContainer != nil { return fmt.Sprintf("/proc/%v/ns/net", s.infraContainer.State().Pid) } return "" } return s.netns.Get().symlink.Name() }
go
func (s *Sandbox) NetNsPath() string { if s.netns == nil || s.netns.Get() == nil || s.netns.Get().symlink == nil { if s.infraContainer != nil { return fmt.Sprintf("/proc/%v/ns/net", s.infraContainer.State().Pid) } return "" } return s.netns.Get().symlink.Name() }
[ "func", "(", "s", "*", "Sandbox", ")", "NetNsPath", "(", ")", "string", "{", "if", "s", ".", "netns", "==", "nil", "||", "s", ".", "netns", ".", "Get", "(", ")", "==", "nil", "||", "s", ".", "netns", ".", "Get", "(", ")", ".", "symlink", "=="...
// NetNsPath returns the path to the network namespace of the sandbox. // If the sandbox uses the host namespace, nil is returned
[ "NetNsPath", "returns", "the", "path", "to", "the", "network", "namespace", "of", "the", "sandbox", ".", "If", "the", "sandbox", "uses", "the", "host", "namespace", "nil", "is", "returned" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/sandbox.go#L372-L382
train
cri-o/cri-o
lib/sandbox/sandbox.go
UserNsPath
func (s *Sandbox) UserNsPath() string { if s.infraContainer != nil { return fmt.Sprintf("/proc/%v/ns/user", s.infraContainer.State().Pid) } return "" }
go
func (s *Sandbox) UserNsPath() string { if s.infraContainer != nil { return fmt.Sprintf("/proc/%v/ns/user", s.infraContainer.State().Pid) } return "" }
[ "func", "(", "s", "*", "Sandbox", ")", "UserNsPath", "(", ")", "string", "{", "if", "s", ".", "infraContainer", "!=", "nil", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "infraContainer", ".", "State", "(", ")", ".", "Pid",...
// UserNsPath returns the path to the user namespace of the sandbox. // If the sandbox uses the host namespace, nil is returned
[ "UserNsPath", "returns", "the", "path", "to", "the", "user", "namespace", "of", "the", "sandbox", ".", "If", "the", "sandbox", "uses", "the", "host", "namespace", "nil", "is", "returned" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/sandbox.go#L386-L391
train
cri-o/cri-o
lib/sandbox/sandbox.go
NetNsCreate
func (s *Sandbox) NetNsCreate(netNs NetNsIface) error { // Create a new netNs if nil provided if netNs == nil { netNs = &NetNs{} } // Check if interface is already initialized if netNs.Initialized() { return fmt.Errorf("net NS already initialized") } netNs, err := netNs.Initialize() if err != nil { retu...
go
func (s *Sandbox) NetNsCreate(netNs NetNsIface) error { // Create a new netNs if nil provided if netNs == nil { netNs = &NetNs{} } // Check if interface is already initialized if netNs.Initialized() { return fmt.Errorf("net NS already initialized") } netNs, err := netNs.Initialize() if err != nil { retu...
[ "func", "(", "s", "*", "Sandbox", ")", "NetNsCreate", "(", "netNs", "NetNsIface", ")", "error", "{", "// Create a new netNs if nil provided", "if", "netNs", "==", "nil", "{", "netNs", "=", "&", "NetNs", "{", "}", "\n", "}", "\n\n", "// Check if interface is al...
// NetNsCreate creates a new network namespace for the sandbox
[ "NetNsCreate", "creates", "a", "new", "network", "namespace", "for", "the", "sandbox" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/sandbox.go#L394-L422
train
cri-o/cri-o
lib/sandbox/sandbox.go
NetNsJoin
func (s *Sandbox) NetNsJoin(nspath, name string) error { if s.netns != nil { return fmt.Errorf("sandbox already has a network namespace, cannot join another") } netNS, err := s.NetNsGet(nspath, name) if err != nil { return err } s.netns = netNS return nil }
go
func (s *Sandbox) NetNsJoin(nspath, name string) error { if s.netns != nil { return fmt.Errorf("sandbox already has a network namespace, cannot join another") } netNS, err := s.NetNsGet(nspath, name) if err != nil { return err } s.netns = netNS return nil }
[ "func", "(", "s", "*", "Sandbox", ")", "NetNsJoin", "(", "nspath", ",", "name", "string", ")", "error", "{", "if", "s", ".", "netns", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "netNS", ",", "err", ...
// NetNsJoin attempts to join the sandbox to an existing network namespace // This will fail if the sandbox is already part of a network namespace
[ "NetNsJoin", "attempts", "to", "join", "the", "sandbox", "to", "an", "existing", "network", "namespace", "This", "will", "fail", "if", "the", "sandbox", "is", "already", "part", "of", "a", "network", "namespace" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/sandbox.go#L439-L452
train
cri-o/cri-o
lib/sandbox/sandbox.go
NetNsRemove
func (s *Sandbox) NetNsRemove() error { if s.netns == nil { logrus.Warn("no networking namespace") return nil } return s.netns.Remove() }
go
func (s *Sandbox) NetNsRemove() error { if s.netns == nil { logrus.Warn("no networking namespace") return nil } return s.netns.Remove() }
[ "func", "(", "s", "*", "Sandbox", ")", "NetNsRemove", "(", ")", "error", "{", "if", "s", ".", "netns", "==", "nil", "{", "logrus", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "nil", "\n", "}", "\n\n", "return", "s", ".", "netns", ".", "R...
// NetNsRemove removes the network namespace associated with the sandbox
[ "NetNsRemove", "removes", "the", "network", "namespace", "associated", "with", "the", "sandbox" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/sandbox.go#L455-L462
train
cri-o/cri-o
client/client.go
New
func New(crioSocketPath string) (CrioClient, error) { tr := new(http.Transport) configureUnixTransport(tr, "unix", crioSocketPath) c := &http.Client{ Transport: tr, } return &crioClientImpl{ client: c, crioSocketPath: crioSocketPath, }, nil }
go
func New(crioSocketPath string) (CrioClient, error) { tr := new(http.Transport) configureUnixTransport(tr, "unix", crioSocketPath) c := &http.Client{ Transport: tr, } return &crioClientImpl{ client: c, crioSocketPath: crioSocketPath, }, nil }
[ "func", "New", "(", "crioSocketPath", "string", ")", "(", "CrioClient", ",", "error", ")", "{", "tr", ":=", "new", "(", "http", ".", "Transport", ")", "\n", "configureUnixTransport", "(", "tr", ",", "\"", "\"", ",", "crioSocketPath", ")", "\n", "c", ":...
// New returns a crio client
[ "New", "returns", "a", "crio", "client" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/client/client.go#L43-L53
train
cri-o/cri-o
client/client.go
DaemonInfo
func (c *crioClientImpl) DaemonInfo() (types.CrioInfo, error) { info := types.CrioInfo{} req, err := c.getRequest("/info") if err != nil { return info, err } resp, err := c.client.Do(req) if err != nil { return info, err } defer resp.Body.Close() err = json.NewDecoder(resp.Body).Decode(&info) return info,...
go
func (c *crioClientImpl) DaemonInfo() (types.CrioInfo, error) { info := types.CrioInfo{} req, err := c.getRequest("/info") if err != nil { return info, err } resp, err := c.client.Do(req) if err != nil { return info, err } defer resp.Body.Close() err = json.NewDecoder(resp.Body).Decode(&info) return info,...
[ "func", "(", "c", "*", "crioClientImpl", ")", "DaemonInfo", "(", ")", "(", "types", ".", "CrioInfo", ",", "error", ")", "{", "info", ":=", "types", ".", "CrioInfo", "{", "}", "\n", "req", ",", "err", ":=", "c", ".", "getRequest", "(", "\"", "\"", ...
// DaemonInfo return cri-o daemon info from the cri-o // info endpoint.
[ "DaemonInfo", "return", "cri", "-", "o", "daemon", "info", "from", "the", "cri", "-", "o", "info", "endpoint", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/client/client.go#L70-L83
train
cri-o/cri-o
client/client.go
ContainerInfo
func (c *crioClientImpl) ContainerInfo(id string) (*types.ContainerInfo, error) { req, err := c.getRequest("/containers/" + id) if err != nil { return nil, err } resp, err := c.client.Do(req) if err != nil { return nil, err } defer resp.Body.Close() cInfo := types.ContainerInfo{} if err := json.NewDecoder(...
go
func (c *crioClientImpl) ContainerInfo(id string) (*types.ContainerInfo, error) { req, err := c.getRequest("/containers/" + id) if err != nil { return nil, err } resp, err := c.client.Do(req) if err != nil { return nil, err } defer resp.Body.Close() cInfo := types.ContainerInfo{} if err := json.NewDecoder(...
[ "func", "(", "c", "*", "crioClientImpl", ")", "ContainerInfo", "(", "id", "string", ")", "(", "*", "types", ".", "ContainerInfo", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "getRequest", "(", "\"", "\"", "+", "id", ")", "\n", "if", ...
// ContainerInfo returns container info by querying // the cri-o container endpoint.
[ "ContainerInfo", "returns", "container", "info", "by", "querying", "the", "cri", "-", "o", "container", "endpoint", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/client/client.go#L87-L102
train
cri-o/cri-o
utils/fifo/fifo.go
Write
func (f *fifo) Write(b []byte) (int, error) { if f.flag&(syscall.O_WRONLY|syscall.O_RDWR) == 0 { return 0, errors.New("writing to read-only fifo") } select { case <-f.opened: return f.file.Write(b) default: } select { case <-f.opened: return f.file.Write(b) case <-f.closed: return 0, errors.New("writin...
go
func (f *fifo) Write(b []byte) (int, error) { if f.flag&(syscall.O_WRONLY|syscall.O_RDWR) == 0 { return 0, errors.New("writing to read-only fifo") } select { case <-f.opened: return f.file.Write(b) default: } select { case <-f.opened: return f.file.Write(b) case <-f.closed: return 0, errors.New("writin...
[ "func", "(", "f", "*", "fifo", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "f", ".", "flag", "&", "(", "syscall", ".", "O_WRONLY", "|", "syscall", ".", "O_RDWR", ")", "==", "0", "{", "return", "0",...
// Write from byte array to a fifo.
[ "Write", "from", "byte", "array", "to", "a", "fifo", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/fifo/fifo.go#L166-L181
train
cri-o/cri-o
server/useragent/useragent.go
Get
func Get(ctx context.Context) string { httpVersion := make([]VersionInfo, 0, 4) httpVersion = append(httpVersion, VersionInfo{Name: "cri-o", Version: version.Version}) httpVersion = append(httpVersion, VersionInfo{Name: "go", Version: runtime.Version()}) httpVersion = append(httpVersion, VersionInfo{Name: "os", Ver...
go
func Get(ctx context.Context) string { httpVersion := make([]VersionInfo, 0, 4) httpVersion = append(httpVersion, VersionInfo{Name: "cri-o", Version: version.Version}) httpVersion = append(httpVersion, VersionInfo{Name: "go", Version: runtime.Version()}) httpVersion = append(httpVersion, VersionInfo{Name: "os", Ver...
[ "func", "Get", "(", "ctx", "context", ".", "Context", ")", "string", "{", "httpVersion", ":=", "make", "(", "[", "]", "VersionInfo", ",", "0", ",", "4", ")", "\n", "httpVersion", "=", "append", "(", "httpVersion", ",", "VersionInfo", "{", "Name", ":", ...
// Get is the User-Agent the CRI-O daemon uses to identify itself.
[ "Get", "is", "the", "User", "-", "Agent", "the", "CRI", "-", "O", "daemon", "uses", "to", "identify", "itself", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/useragent/useragent.go#L11-L19
train
cri-o/cri-o
server/secrets.go
SaveTo
func (s SecretData) SaveTo(dir string) error { path := filepath.Join(dir, s.Name) if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil && !os.IsExist(err) { return err } return ioutil.WriteFile(path, s.Data, 0700) }
go
func (s SecretData) SaveTo(dir string) error { path := filepath.Join(dir, s.Name) if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil && !os.IsExist(err) { return err } return ioutil.WriteFile(path, s.Data, 0700) }
[ "func", "(", "s", "SecretData", ")", "SaveTo", "(", "dir", "string", ")", "error", "{", "path", ":=", "filepath", ".", "Join", "(", "dir", ",", "s", ".", "Name", ")", "\n", "if", "err", ":=", "os", ".", "MkdirAll", "(", "filepath", ".", "Dir", "(...
// SaveTo saves secret data to given directory
[ "SaveTo", "saves", "secret", "data", "to", "given", "directory" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/secrets.go#L23-L29
train
cri-o/cri-o
server/secrets.go
secretMounts
func secretMounts(defaultMountsPaths []string, mountLabel, containerWorkingDir string, runtimeMounts []rspec.Mount) ([]rspec.Mount, error) { mounts := make([]rspec.Mount, 0, len(defaultMountsPaths)) for _, path := range defaultMountsPaths { hostDir, ctrDir, err := getMountsMap(path) if err != nil { return nil,...
go
func secretMounts(defaultMountsPaths []string, mountLabel, containerWorkingDir string, runtimeMounts []rspec.Mount) ([]rspec.Mount, error) { mounts := make([]rspec.Mount, 0, len(defaultMountsPaths)) for _, path := range defaultMountsPaths { hostDir, ctrDir, err := getMountsMap(path) if err != nil { return nil,...
[ "func", "secretMounts", "(", "defaultMountsPaths", "[", "]", "string", ",", "mountLabel", ",", "containerWorkingDir", "string", ",", "runtimeMounts", "[", "]", "rspec", ".", "Mount", ")", "(", "[", "]", "rspec", ".", "Mount", ",", "error", ")", "{", "mount...
// secretMount copies the contents of host directory to container directory // and returns a list of mounts
[ "secretMount", "copies", "the", "contents", "of", "host", "directory", "to", "container", "directory", "and", "returns", "a", "list", "of", "mounts" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/secrets.go#L103-L157
train
cri-o/cri-o
utils/io/logger.go
NewCRILogger
func NewCRILogger(path string, w io.Writer, stream StreamType, maxLen int) (io.WriteCloser, <-chan struct{}) { logrus.Debugf("Start writing stream %q to log file %q", stream, path) prc, pwc := io.Pipe() stop := make(chan struct{}) go func() { redirectLogs(path, prc, w, stream, maxLen) close(stop) }() return p...
go
func NewCRILogger(path string, w io.Writer, stream StreamType, maxLen int) (io.WriteCloser, <-chan struct{}) { logrus.Debugf("Start writing stream %q to log file %q", stream, path) prc, pwc := io.Pipe() stop := make(chan struct{}) go func() { redirectLogs(path, prc, w, stream, maxLen) close(stop) }() return p...
[ "func", "NewCRILogger", "(", "path", "string", ",", "w", "io", ".", "Writer", ",", "stream", "StreamType", ",", "maxLen", "int", ")", "(", "io", ".", "WriteCloser", ",", "<-", "chan", "struct", "{", "}", ")", "{", "logrus", ".", "Debugf", "(", "\"", ...
// NewCRILogger returns a write closer which redirect container log into // log file, and decorate the log line into CRI defined format. It also // returns a channel which indicates whether the logger is stopped. // maxLen is the max length limit of a line. A line longer than the // limit will be cut into multiple line...
[ "NewCRILogger", "returns", "a", "write", "closer", "which", "redirect", "container", "log", "into", "log", "file", "and", "decorate", "the", "log", "line", "into", "CRI", "defined", "format", ".", "It", "also", "returns", "a", "channel", "which", "indicates", ...
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/io/logger.go#L53-L62
train
cri-o/cri-o
server/utils.go
inStringSlice
func inStringSlice(ss []string, str string) bool { for _, s := range ss { if strings.EqualFold(s, str) { return true } } return false }
go
func inStringSlice(ss []string, str string) bool { for _, s := range ss { if strings.EqualFold(s, str) { return true } } return false }
[ "func", "inStringSlice", "(", "ss", "[", "]", "string", ",", "str", "string", ")", "bool", "{", "for", "_", ",", "s", ":=", "range", "ss", "{", "if", "strings", ".", "EqualFold", "(", "s", ",", "str", ")", "{", "return", "true", "\n", "}", "\n", ...
// inStringSlice checks whether a string is inside a string slice. // Comparison is case insensitive.
[ "inStringSlice", "checks", "whether", "a", "string", "is", "inside", "a", "string", "slice", ".", "Comparison", "is", "case", "insensitive", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/utils.go#L113-L120
train
cri-o/cri-o
server/utils.go
getOCICapabilitiesList
func getOCICapabilitiesList() []string { caps := make([]string, 0, len(capability.List())) for _, cap := range capability.List() { if cap > validate.LastCap() { continue } caps = append(caps, "CAP_"+strings.ToUpper(cap.String())) } return caps }
go
func getOCICapabilitiesList() []string { caps := make([]string, 0, len(capability.List())) for _, cap := range capability.List() { if cap > validate.LastCap() { continue } caps = append(caps, "CAP_"+strings.ToUpper(cap.String())) } return caps }
[ "func", "getOCICapabilitiesList", "(", ")", "[", "]", "string", "{", "caps", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "capability", ".", "List", "(", ")", ")", ")", "\n", "for", "_", ",", "cap", ":=", "range", "capability",...
// getOCICapabilitiesList returns a list of all available capabilities.
[ "getOCICapabilitiesList", "returns", "a", "list", "of", "all", "available", "capabilities", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/utils.go#L123-L132
train
cri-o/cri-o
server/utils.go
validateSysctl
func validateSysctl(sysctl string, hostNet, hostIPC bool) error { nsErrorFmt := "%q not allowed with host %s enabled" if ns, found := namespaces[sysctl]; found { if ns == IpcNamespace && hostIPC { return errors.Errorf(nsErrorFmt, sysctl, ns) } if ns == NetNamespace && hostNet { return errors.Errorf(nsErro...
go
func validateSysctl(sysctl string, hostNet, hostIPC bool) error { nsErrorFmt := "%q not allowed with host %s enabled" if ns, found := namespaces[sysctl]; found { if ns == IpcNamespace && hostIPC { return errors.Errorf(nsErrorFmt, sysctl, ns) } if ns == NetNamespace && hostNet { return errors.Errorf(nsErro...
[ "func", "validateSysctl", "(", "sysctl", "string", ",", "hostNet", ",", "hostIPC", "bool", ")", "error", "{", "nsErrorFmt", ":=", "\"", "\"", "\n", "if", "ns", ",", "found", ":=", "namespaces", "[", "sysctl", "]", ";", "found", "{", "if", "ns", "==", ...
// validateSysctl checks that a sysctl is whitelisted because it is known // to be namespaced by the Linux kernel. // The parameters hostNet and hostIPC are used to forbid sysctls for pod sharing the // respective namespaces with the host. This check is only used on sysctls defined by // the user in the crio.conf file.
[ "validateSysctl", "checks", "that", "a", "sysctl", "is", "whitelisted", "because", "it", "is", "known", "to", "be", "namespaced", "by", "the", "Linux", "kernel", ".", "The", "parameters", "hostNet", "and", "hostIPC", "are", "used", "to", "forbid", "sysctls", ...
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/utils.go#L230-L253
train
cri-o/cri-o
server/utils.go
translateLabelsToDescription
func translateLabelsToDescription(labels map[string]string) string { return fmt.Sprintf("%s/%s/%s", labels[types.KubernetesPodNamespaceLabel], labels[types.KubernetesPodNameLabel], labels[types.KubernetesContainerNameLabel]) }
go
func translateLabelsToDescription(labels map[string]string) string { return fmt.Sprintf("%s/%s/%s", labels[types.KubernetesPodNamespaceLabel], labels[types.KubernetesPodNameLabel], labels[types.KubernetesContainerNameLabel]) }
[ "func", "translateLabelsToDescription", "(", "labels", "map", "[", "string", "]", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "labels", "[", "types", ".", "KubernetesPodNamespaceLabel", "]", ",", "labels", "[", "types...
// Translate container labels to a description of the container
[ "Translate", "container", "labels", "to", "a", "description", "of", "the", "container" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/utils.go#L279-L281
train
cri-o/cri-o
lib/config.go
GetStore
func (c *Config) GetStore() (cstorage.Store, error) { return cstorage.GetStore(cstorage.StoreOptions{ RunRoot: c.RunRoot, GraphRoot: c.Root, GraphDriverName: c.Storage, GraphDriverOptions: c.StorageOptions, }) }
go
func (c *Config) GetStore() (cstorage.Store, error) { return cstorage.GetStore(cstorage.StoreOptions{ RunRoot: c.RunRoot, GraphRoot: c.Root, GraphDriverName: c.Storage, GraphDriverOptions: c.StorageOptions, }) }
[ "func", "(", "c", "*", "Config", ")", "GetStore", "(", ")", "(", "cstorage", ".", "Store", ",", "error", ")", "{", "return", "cstorage", ".", "GetStore", "(", "cstorage", ".", "StoreOptions", "{", "RunRoot", ":", "c", ".", "RunRoot", ",", "GraphRoot", ...
// GetStore returns the container storage for a given configuration
[ "GetStore", "returns", "the", "container", "storage", "for", "a", "given", "configuration" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/config.go#L49-L56
train
cri-o/cri-o
lib/config.go
UpdateFromFile
func (c *Config) UpdateFromFile(path string) error { data, err := ioutil.ReadFile(path) if err != nil { return err } t := new(tomlConfig) t.fromConfig(c) _, err = toml.Decode(string(data), t) if err != nil { return fmt.Errorf("unable to decode configuration %v: %v", path, err) } t.toConfig(c) return ni...
go
func (c *Config) UpdateFromFile(path string) error { data, err := ioutil.ReadFile(path) if err != nil { return err } t := new(tomlConfig) t.fromConfig(c) _, err = toml.Decode(string(data), t) if err != nil { return fmt.Errorf("unable to decode configuration %v: %v", path, err) } t.toConfig(c) return ni...
[ "func", "(", "c", "*", "Config", ")", "UpdateFromFile", "(", "path", "string", ")", "error", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "t", ...
// UpdateFromFile populates the Config from the TOML-encoded file at the given path. // Returns errors encountered when reading or parsing the files, or nil // otherwise.
[ "UpdateFromFile", "populates", "the", "Config", "from", "the", "TOML", "-", "encoded", "file", "at", "the", "given", "path", ".", "Returns", "errors", "encountered", "when", "reading", "or", "parsing", "the", "files", "or", "nil", "otherwise", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/config.go#L320-L336
train
cri-o/cri-o
lib/config.go
ToFile
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
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) }
[ "func", "(", "c", "*", "Config", ")", "ToFile", "(", "path", "string", ")", "error", "{", "var", "w", "bytes", ".", "Buffer", "\n", "e", ":=", "toml", ".", "NewEncoder", "(", "&", "w", ")", "\n\n", "t", ":=", "new", "(", "tomlConfig", ")", "\n", ...
// ToFile outputs the given Config as a TOML-encoded file at the given path. // Returns errors encountered when generating or writing the file, or nil // otherwise.
[ "ToFile", "outputs", "the", "given", "Config", "as", "a", "TOML", "-", "encoded", "file", "at", "the", "given", "path", ".", "Returns", "errors", "encountered", "when", "generating", "or", "writing", "the", "file", "or", "nil", "otherwise", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/config.go#L341-L353
train
cri-o/cri-o
lib/config.go
Validate
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
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); ...
[ "func", "(", "c", "*", "Config", ")", "Validate", "(", "onExecution", "bool", ")", "error", "{", "if", "err", ":=", "c", ".", "RootConfig", ".", "Validate", "(", "onExecution", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Wrapf", "(",...
// Validate is the main entry point for library configuration validation. // The parameter `onExecution` specifies if the validation should include // execution checks. It returns an `error` on validation failure, otherwise // `nil`.
[ "Validate", "is", "the", "main", "entry", "point", "for", "library", "configuration", "validation", ".", "The", "parameter", "onExecution", "specifies", "if", "the", "validation", "should", "include", "execution", "checks", ".", "It", "returns", "an", "error", "...
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/config.go#L422-L436
train
cri-o/cri-o
lib/config.go
Validate
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
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 }
[ "func", "(", "c", "*", "RootConfig", ")", "Validate", "(", "onExecution", "bool", ")", "error", "{", "if", "onExecution", "{", "if", "err", ":=", "os", ".", "MkdirAll", "(", "c", ".", "LogDir", ",", "0700", ")", ";", "err", "!=", "nil", "{", "retur...
// Validate is the main entry point for root configuration validation. // The parameter `onExecution` specifies if the validation should include // execution checks. It returns an `error` on validation failure, otherwise // `nil`.
[ "Validate", "is", "the", "main", "entry", "point", "for", "root", "configuration", "validation", ".", "The", "parameter", "onExecution", "specifies", "if", "the", "validation", "should", "include", "execution", "checks", ".", "It", "returns", "an", "error", "on"...
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/config.go#L442-L450
train
cri-o/cri-o
lib/config.go
Validate
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
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'...
[ "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...
// Validate is the main entry point for runtime configuration validation // The parameter `onExecution` specifies if the validation should include // execution checks. It returns an `error` on validation failure, otherwise // `nil`.
[ "Validate", "is", "the", "main", "entry", "point", "for", "runtime", "configuration", "validation", "The", "parameter", "onExecution", "specifies", "if", "the", "validation", "should", "include", "execution", "checks", ".", "It", "returns", "an", "error", "on", ...
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/config.go#L456-L531
train
cri-o/cri-o
lib/config.go
Validate
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
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 ...
[ "func", "(", "c", "*", "NetworkConfig", ")", "Validate", "(", "onExecution", "bool", ")", "error", "{", "if", "onExecution", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "c", ".", "NetworkDir", ")", ";", "err", "!=", "nil", "{", "retur...
// Validate is the main entry point for network configuration validation. // The parameter `onExecution` specifies if the validation should include // execution checks. It returns an `error` on validation failure, otherwise // `nil`.
[ "Validate", "is", "the", "main", "entry", "point", "for", "network", "configuration", "validation", ".", "The", "parameter", "onExecution", "specifies", "if", "the", "validation", "should", "include", "execution", "checks", ".", "It", "returns", "an", "error", "...
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/config.go#L537-L551
train
cri-o/cri-o
server/sandbox_run.go
privilegedSandbox
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
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 =...
[ "func", "(", "s", "*", "Server", ")", "privilegedSandbox", "(", "req", "*", "pb", ".", "RunPodSandboxRequest", ")", "bool", "{", "securityContext", ":=", "req", ".", "GetConfig", "(", ")", ".", "GetLinux", "(", ")", ".", "GetSecurityContext", "(", ")", "...
// privilegedSandbox returns true if the sandbox configuration // requires additional host privileges for the sandbox.
[ "privilegedSandbox", "returns", "true", "if", "the", "sandbox", "configuration", "requires", "additional", "host", "privileges", "for", "the", "sandbox", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/sandbox_run.go#L28-L50
train
cri-o/cri-o
server/sandbox_run.go
runtimeHandler
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
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...
[ "func", "(", "s", "*", "Server", ")", "runtimeHandler", "(", "req", "*", "pb", ".", "RunPodSandboxRequest", ")", "(", "string", ",", "error", ")", "{", "handler", ":=", "req", ".", "GetRuntimeHandler", "(", ")", "\n", "if", "handler", "==", "\"", "\"",...
// runtimeHandler returns the runtime handler key provided by CRI if the key // does exist and the associated data are valid. If the key is empty, there // is nothing to do, and the empty key is returned. For every other case, this // function will return an empty string with the error associated.
[ "runtimeHandler", "returns", "the", "runtime", "handler", "key", "provided", "by", "CRI", "if", "the", "key", "does", "exist", "and", "the", "associated", "data", "are", "valid", ".", "If", "the", "key", "is", "empty", "there", "is", "nothing", "to", "do",...
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/sandbox_run.go#L56-L72
train
cri-o/cri-o
server/sandbox_run.go
RunPodSandbox
func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest) (resp *pb.RunPodSandboxResponse, err error) { // platform dependent call return s.runPodSandbox(ctx, req) }
go
func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest) (resp *pb.RunPodSandboxResponse, err error) { // platform dependent call return s.runPodSandbox(ctx, req) }
[ "func", "(", "s", "*", "Server", ")", "RunPodSandbox", "(", "ctx", "context", ".", "Context", ",", "req", "*", "pb", ".", "RunPodSandboxRequest", ")", "(", "resp", "*", "pb", ".", "RunPodSandboxResponse", ",", "err", "error", ")", "{", "// platform depende...
// RunPodSandbox creates and runs a pod-level sandbox.
[ "RunPodSandbox", "creates", "and", "runs", "a", "pod", "-", "level", "sandbox", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/sandbox_run.go#L79-L82
train
cri-o/cri-o
server/sandbox_stop.go
StopPodSandbox
func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxRequest) (resp *pb.StopPodSandboxResponse, err error) { // platform dependent call return s.stopPodSandbox(ctx, req) }
go
func (s *Server) StopPodSandbox(ctx context.Context, req *pb.StopPodSandboxRequest) (resp *pb.StopPodSandboxResponse, err error) { // platform dependent call return s.stopPodSandbox(ctx, req) }
[ "func", "(", "s", "*", "Server", ")", "StopPodSandbox", "(", "ctx", "context", ".", "Context", ",", "req", "*", "pb", ".", "StopPodSandboxRequest", ")", "(", "resp", "*", "pb", ".", "StopPodSandboxResponse", ",", "err", "error", ")", "{", "// platform depe...
// StopPodSandbox stops the sandbox. If there are any running containers in the // sandbox, they should be force terminated.
[ "StopPodSandbox", "stops", "the", "sandbox", ".", "If", "there", "are", "any", "running", "containers", "in", "the", "sandbox", "they", "should", "be", "force", "terminated", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/sandbox_stop.go#L11-L14
train
cri-o/cri-o
server/sandbox_stop.go
stopAllPodSandboxes
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
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...
[ "func", "(", "s", "*", "Server", ")", "stopAllPodSandboxes", "(", "ctx", "context", ".", "Context", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ")", "\n", "for", "_", ",", "sb", ":=", "range", "s", ".", "ContainerServer", ".", "ListSandboxes", ...
// stopAllPodSandboxes removes all pod sandboxes
[ "stopAllPodSandboxes", "removes", "all", "pod", "sandboxes" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/sandbox_stop.go#L17-L27
train
cri-o/cri-o
lib/container_server.go
localeToLanguage
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
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 }
[ "func", "localeToLanguage", "(", "locale", "string", ")", "string", "{", "locale", "=", "strings", ".", "Replace", "(", "strings", ".", "SplitN", "(", "locale", ",", "\"", "\"", ",", "2", ")", "[", "0", "]", ",", "\"", "\"", ",", "\"", "\"", ",", ...
// localeToLanguage translates POSIX locale strings to BCP 47 language tags.
[ "localeToLanguage", "translates", "POSIX", "locale", "strings", "to", "BCP", "47", "language", "tags", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L111-L118
train
cri-o/cri-o
lib/container_server.go
ContainerStateFromDisk
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
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 }
[ "func", "(", "c", "*", "ContainerServer", ")", "ContainerStateFromDisk", "(", "ctr", "*", "oci", ".", "Container", ")", "error", "{", "if", "err", ":=", "ctr", ".", "FromDisk", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n",...
// ContainerStateFromDisk retrieves information on the state of a running container // from the disk
[ "ContainerStateFromDisk", "retrieves", "information", "on", "the", "state", "of", "a", "running", "container", "from", "the", "disk" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L599-L608
train
cri-o/cri-o
lib/container_server.go
ContainerStateToDisk
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
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 != ...
[ "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...
// ContainerStateToDisk writes the container's state information to a JSON file // on disk
[ "ContainerStateToDisk", "writes", "the", "container", "s", "state", "information", "to", "a", "JSON", "file", "on", "disk" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L612-L624
train
cri-o/cri-o
lib/container_server.go
ReserveContainerName
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
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 }
[ "func", "(", "c", "*", "ContainerServer", ")", "ReserveContainerName", "(", "id", ",", "name", "string", ")", "(", "string", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ctrNameIndex", ".", "Reserve", "(", "name", ",", "id", ")", ";", "err",...
// ReserveContainerName holds a name for a container that is being created
[ "ReserveContainerName", "holds", "a", "name", "for", "a", "container", "that", "is", "being", "created" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L627-L634
train
cri-o/cri-o
lib/container_server.go
ReservePodName
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
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 }
[ "func", "(", "c", "*", "ContainerServer", ")", "ReservePodName", "(", "id", ",", "name", "string", ")", "(", "string", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "podNameIndex", ".", "Reserve", "(", "name", ",", "id", ")", ";", "err", "!=...
// ReservePodName holds a name for a pod that is being created
[ "ReservePodName", "holds", "a", "name", "for", "a", "pod", "that", "is", "being", "created" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L643-L650
train
cri-o/cri-o
lib/container_server.go
AddContainer
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
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) }
[ "func", "(", "c", "*", "ContainerServer", ")", "AddContainer", "(", "ctr", "*", "oci", ".", "Container", ")", "{", "sandbox", ":=", "c", ".", "state", ".", "sandboxes", ".", "Get", "(", "ctr", ".", "Sandbox", "(", ")", ")", "\n", "if", "sandbox", "...
// AddContainer adds a container to the container state store
[ "AddContainer", "adds", "a", "container", "to", "the", "container", "state", "store" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L676-L683
train
cri-o/cri-o
lib/container_server.go
AddInfraContainer
func (c *ContainerServer) AddInfraContainer(ctr *oci.Container) { c.state.infraContainers.Add(ctr.ID(), ctr) }
go
func (c *ContainerServer) AddInfraContainer(ctr *oci.Container) { c.state.infraContainers.Add(ctr.ID(), ctr) }
[ "func", "(", "c", "*", "ContainerServer", ")", "AddInfraContainer", "(", "ctr", "*", "oci", ".", "Container", ")", "{", "c", ".", "state", ".", "infraContainers", ".", "Add", "(", "ctr", ".", "ID", "(", ")", ",", "ctr", ")", "\n", "}" ]
// AddInfraContainer adds a container to the container state store
[ "AddInfraContainer", "adds", "a", "container", "to", "the", "container", "state", "store" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L686-L688
train
cri-o/cri-o
lib/container_server.go
GetContainer
func (c *ContainerServer) GetContainer(id string) *oci.Container { return c.state.containers.Get(id) }
go
func (c *ContainerServer) GetContainer(id string) *oci.Container { return c.state.containers.Get(id) }
[ "func", "(", "c", "*", "ContainerServer", ")", "GetContainer", "(", "id", "string", ")", "*", "oci", ".", "Container", "{", "return", "c", ".", "state", ".", "containers", ".", "Get", "(", "id", ")", "\n", "}" ]
// GetContainer returns a container by its ID
[ "GetContainer", "returns", "a", "container", "by", "its", "ID" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L691-L693
train
cri-o/cri-o
lib/container_server.go
GetInfraContainer
func (c *ContainerServer) GetInfraContainer(id string) *oci.Container { return c.state.infraContainers.Get(id) }
go
func (c *ContainerServer) GetInfraContainer(id string) *oci.Container { return c.state.infraContainers.Get(id) }
[ "func", "(", "c", "*", "ContainerServer", ")", "GetInfraContainer", "(", "id", "string", ")", "*", "oci", ".", "Container", "{", "return", "c", ".", "state", ".", "infraContainers", ".", "Get", "(", "id", ")", "\n", "}" ]
// GetInfraContainer returns a container by its ID
[ "GetInfraContainer", "returns", "a", "container", "by", "its", "ID" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L696-L698
train
cri-o/cri-o
lib/container_server.go
HasContainer
func (c *ContainerServer) HasContainer(id string) bool { return c.state.containers.Get(id) != nil }
go
func (c *ContainerServer) HasContainer(id string) bool { return c.state.containers.Get(id) != nil }
[ "func", "(", "c", "*", "ContainerServer", ")", "HasContainer", "(", "id", "string", ")", "bool", "{", "return", "c", ".", "state", ".", "containers", ".", "Get", "(", "id", ")", "!=", "nil", "\n", "}" ]
// HasContainer checks if a container exists in the state
[ "HasContainer", "checks", "if", "a", "container", "exists", "in", "the", "state" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L701-L703
train
cri-o/cri-o
lib/container_server.go
RemoveContainer
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
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()) }
[ "func", "(", "c", "*", "ContainerServer", ")", "RemoveContainer", "(", "ctr", "*", "oci", ".", "Container", ")", "{", "sbID", ":=", "ctr", ".", "Sandbox", "(", ")", "\n", "sb", ":=", "c", ".", "state", ".", "sandboxes", ".", "Get", "(", "sbID", ")"...
// RemoveContainer removes a container from the container state store
[ "RemoveContainer", "removes", "a", "container", "from", "the", "container", "state", "store" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L706-L714
train
cri-o/cri-o
lib/container_server.go
RemoveInfraContainer
func (c *ContainerServer) RemoveInfraContainer(ctr *oci.Container) { c.state.infraContainers.Delete(ctr.ID()) }
go
func (c *ContainerServer) RemoveInfraContainer(ctr *oci.Container) { c.state.infraContainers.Delete(ctr.ID()) }
[ "func", "(", "c", "*", "ContainerServer", ")", "RemoveInfraContainer", "(", "ctr", "*", "oci", ".", "Container", ")", "{", "c", ".", "state", ".", "infraContainers", ".", "Delete", "(", "ctr", ".", "ID", "(", ")", ")", "\n", "}" ]
// RemoveInfraContainer removes a container from the container state store
[ "RemoveInfraContainer", "removes", "a", "container", "from", "the", "container", "state", "store" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L717-L719
train
cri-o/cri-o
lib/container_server.go
ListContainers
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
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...
[ "func", "(", "c", "*", "ContainerServer", ")", "ListContainers", "(", "filters", "...", "func", "(", "*", "oci", ".", "Container", ")", "bool", ")", "(", "[", "]", "*", "oci", ".", "Container", ",", "error", ")", "{", "containers", ":=", "c", ".", ...
// ListContainers returns a list of all containers stored by the server state // that match the given filter function
[ "ListContainers", "returns", "a", "list", "of", "all", "containers", "stored", "by", "the", "server", "state", "that", "match", "the", "given", "filter", "function" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L728-L742
train
cri-o/cri-o
lib/container_server.go
AddSandbox
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
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) }
[ "func", "(", "c", "*", "ContainerServer", ")", "AddSandbox", "(", "sb", "*", "sandbox", ".", "Sandbox", ")", "error", "{", "c", ".", "state", ".", "sandboxes", ".", "Add", "(", "sb", ".", "ID", "(", ")", ",", "sb", ")", "\n\n", "c", ".", "stateLo...
// AddSandbox adds a sandbox to the sandbox state store
[ "AddSandbox", "adds", "a", "sandbox", "to", "the", "sandbox", "state", "store" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L745-L751
train
cri-o/cri-o
lib/container_server.go
GetSandbox
func (c *ContainerServer) GetSandbox(id string) *sandbox.Sandbox { return c.state.sandboxes.Get(id) }
go
func (c *ContainerServer) GetSandbox(id string) *sandbox.Sandbox { return c.state.sandboxes.Get(id) }
[ "func", "(", "c", "*", "ContainerServer", ")", "GetSandbox", "(", "id", "string", ")", "*", "sandbox", ".", "Sandbox", "{", "return", "c", ".", "state", ".", "sandboxes", ".", "Get", "(", "id", ")", "\n", "}" ]
// GetSandbox returns a sandbox by its ID
[ "GetSandbox", "returns", "a", "sandbox", "by", "its", "ID" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L754-L756
train
cri-o/cri-o
lib/container_server.go
GetSandboxContainer
func (c *ContainerServer) GetSandboxContainer(id string) *oci.Container { sb := c.state.sandboxes.Get(id) if sb == nil { return nil } return sb.InfraContainer() }
go
func (c *ContainerServer) GetSandboxContainer(id string) *oci.Container { sb := c.state.sandboxes.Get(id) if sb == nil { return nil } return sb.InfraContainer() }
[ "func", "(", "c", "*", "ContainerServer", ")", "GetSandboxContainer", "(", "id", "string", ")", "*", "oci", ".", "Container", "{", "sb", ":=", "c", ".", "state", ".", "sandboxes", ".", "Get", "(", "id", ")", "\n", "if", "sb", "==", "nil", "{", "ret...
// GetSandboxContainer returns a sandbox's infra container
[ "GetSandboxContainer", "returns", "a", "sandbox", "s", "infra", "container" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L759-L765
train
cri-o/cri-o
lib/container_server.go
HasSandbox
func (c *ContainerServer) HasSandbox(id string) bool { return c.state.sandboxes.Get(id) != nil }
go
func (c *ContainerServer) HasSandbox(id string) bool { return c.state.sandboxes.Get(id) != nil }
[ "func", "(", "c", "*", "ContainerServer", ")", "HasSandbox", "(", "id", "string", ")", "bool", "{", "return", "c", ".", "state", ".", "sandboxes", ".", "Get", "(", "id", ")", "!=", "nil", "\n", "}" ]
// HasSandbox checks if a sandbox exists in the state
[ "HasSandbox", "checks", "if", "a", "sandbox", "exists", "in", "the", "state" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L768-L770
train
cri-o/cri-o
lib/container_server.go
RemoveSandbox
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
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 }
[ "func", "(", "c", "*", "ContainerServer", ")", "RemoveSandbox", "(", "id", "string", ")", "error", "{", "sb", ":=", "c", ".", "state", ".", "sandboxes", ".", "Get", "(", "id", ")", "\n", "if", "sb", "==", "nil", "{", "return", "nil", "\n", "}", "...
// RemoveSandbox removes a sandbox from the state store
[ "RemoveSandbox", "removes", "a", "sandbox", "from", "the", "state", "store" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/container_server.go#L773-L787
train
cri-o/cri-o
server/sandbox_status.go
PodSandboxStatus
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
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)...
[ "func", "(", "s", "*", "Server", ")", "PodSandboxStatus", "(", "ctx", "context", ".", "Context", ",", "req", "*", "pb", ".", "PodSandboxStatusRequest", ")", "(", "resp", "*", "pb", ".", "PodSandboxStatusResponse", ",", "err", "error", ")", "{", "const", ...
// PodSandboxStatus returns the Status of the PodSandbox.
[ "PodSandboxStatus", "returns", "the", "Status", "of", "the", "PodSandbox", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/sandbox_status.go#L13-L60
train
cri-o/cri-o
server/runtime_status.go
Status
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
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...
[ "func", "(", "s", "*", "Server", ")", "Status", "(", "ctx", "context", ".", "Context", ",", "req", "*", "pb", ".", "StatusRequest", ")", "(", "resp", "*", "pb", ".", "StatusResponse", ",", "err", "error", ")", "{", "const", "operation", "=", "\"", ...
// Status returns the status of the runtime
[ "Status", "returns", "the", "status", "of", "the", "runtime" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/runtime_status.go#L15-L47
train
cri-o/cri-o
server/metrics/metrics.go
Register
func Register() { registerMetrics.Do(func() { prometheus.MustRegister(CRIOOperations) prometheus.MustRegister(CRIOOperationsLatency) prometheus.MustRegister(CRIOOperationsErrors) }) }
go
func Register() { registerMetrics.Do(func() { prometheus.MustRegister(CRIOOperations) prometheus.MustRegister(CRIOOperationsLatency) prometheus.MustRegister(CRIOOperationsErrors) }) }
[ "func", "Register", "(", ")", "{", "registerMetrics", ".", "Do", "(", "func", "(", ")", "{", "prometheus", ".", "MustRegister", "(", "CRIOOperations", ")", "\n", "prometheus", ".", "MustRegister", "(", "CRIOOperationsLatency", ")", "\n", "prometheus", ".", "...
// Register all metrics
[ "Register", "all", "metrics" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/metrics/metrics.go#L59-L65
train
cri-o/cri-o
pkg/storage/image.go
prepareReference
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
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...
[ "func", "(", "svc", "*", "imageService", ")", "prepareReference", "(", "imageName", "string", ",", "options", "*", "copy", ".", "Options", ")", "(", "types", ".", "ImageReference", ",", "error", ")", "{", "if", "imageName", "==", "\"", "\"", "{", "return...
// prepareReference creates an image reference from an image string and set options // for the source context
[ "prepareReference", "creates", "an", "image", "reference", "from", "an", "image", "string", "and", "set", "options", "for", "the", "source", "context" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/pkg/storage/image.go#L358-L386
train
cri-o/cri-o
server/container_updateruntimeconfig.go
UpdateRuntimeConfig
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
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...
[ "func", "(", "s", "*", "Server", ")", "UpdateRuntimeConfig", "(", "ctx", "context", ".", "Context", ",", "req", "*", "pb", ".", "UpdateRuntimeConfigRequest", ")", "(", "resp", "*", "pb", ".", "UpdateRuntimeConfigResponse", ",", "err", "error", ")", "{", "c...
// UpdateRuntimeConfig updates the configuration of a running container.
[ "UpdateRuntimeConfig", "updates", "the", "configuration", "of", "a", "running", "container", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/container_updateruntimeconfig.go#L11-L19
train
cri-o/cri-o
server/container_attach.go
Attach
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
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...
[ "func", "(", "ss", "StreamService", ")", "Attach", "(", "containerID", "string", ",", "inputStream", "io", ".", "Reader", ",", "outputStream", ",", "errorStream", "io", ".", "WriteCloser", ",", "tty", "bool", ",", "resize", "<-", "chan", "remotecommand", "."...
// Attach endpoint for streaming.Runtime
[ "Attach", "endpoint", "for", "streaming", ".", "Runtime" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/container_attach.go#L33-L49
train
cri-o/cri-o
server/sandbox_network.go
networkStart
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
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() {...
[ "func", "(", "s", "*", "Server", ")", "networkStart", "(", "sb", "*", "sandbox", ".", "Sandbox", ")", "(", "podIP", "string", ",", "result", "cnitypes", ".", "Result", ",", "err", "error", ")", "{", "if", "sb", ".", "HostNetwork", "(", ")", "{", "r...
// networkStart sets up the sandbox's network and returns the pod IP on success // or an error
[ "networkStart", "sets", "up", "the", "sandbox", "s", "network", "and", "returns", "the", "pod", "IP", "on", "success", "or", "an", "error" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/sandbox_network.go#L17-L75
train
cri-o/cri-o
server/sandbox_network.go
getSandboxIP
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
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(...
[ "func", "(", "s", "*", "Server", ")", "getSandboxIP", "(", "sb", "*", "sandbox", ".", "Sandbox", ")", "(", "string", ",", "error", ")", "{", "if", "sb", ".", "HostNetwork", "(", ")", "{", "return", "s", ".", "hostIP", ",", "nil", "\n", "}", "\n\n...
// getSandboxIP retrieves the IP address for the sandbox
[ "getSandboxIP", "retrieves", "the", "IP", "address", "for", "the", "sandbox" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/sandbox_network.go#L78-L95
train
cri-o/cri-o
server/sandbox_network.go
networkStop
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
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 ...
[ "func", "(", "s", "*", "Server", ")", "networkStop", "(", "sb", "*", "sandbox", ".", "Sandbox", ")", "{", "if", "sb", ".", "HostNetwork", "(", ")", "{", "return", "\n", "}", "\n\n", "if", "err", ":=", "s", ".", "hostportManager", ".", "Remove", "("...
// networkStop cleans up and removes a pod's network. It is best-effort and // must call the network plugin even if the network namespace is already gone
[ "networkStop", "cleans", "up", "and", "removes", "a", "pod", "s", "network", ".", "It", "is", "best", "-", "effort", "and", "must", "call", "the", "network", "plugin", "even", "if", "the", "network", "namespace", "is", "already", "gone" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/sandbox_network.go#L99-L118
train
cri-o/cri-o
server/image_status.go
getUserFromImage
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
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. ...
[ "func", "getUserFromImage", "(", "user", "string", ")", "(", "*", "int64", ",", "string", ")", "{", "// return both empty if user is not specified in the image.", "if", "user", "==", "\"", "\"", "{", "return", "nil", ",", "\"", "\"", "\n", "}", "\n", "// split...
// getUserFromImage gets uid or user name of the image user. // If user is numeric, it will be treated as uid; or else, it is treated as user name.
[ "getUserFromImage", "gets", "uid", "or", "user", "name", "of", "the", "image", "user", ".", "If", "user", "is", "numeric", "it", "will", "be", "treated", "as", "uid", ";", "or", "else", "it", "is", "treated", "as", "user", "name", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/image_status.go#L94-L109
train
cri-o/cri-o
server/container_reopen_log.go
ReopenContainerLog
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
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 ...
[ "func", "(", "s", "*", "Server", ")", "ReopenContainerLog", "(", "ctx", "context", ".", "Context", ",", "req", "*", "pb", ".", "ReopenContainerLogRequest", ")", "(", "resp", "*", "pb", ".", "ReopenContainerLogResponse", ",", "err", "error", ")", "{", "cons...
// ReopenContainerLog reopens the containers log file
[ "ReopenContainerLog", "reopens", "the", "containers", "log", "file" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/container_reopen_log.go#L14-L45
train
cri-o/cri-o
server/sandbox_list.go
filterSandbox
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
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)) { ...
[ "func", "filterSandbox", "(", "p", "*", "pb", ".", "PodSandbox", ",", "filter", "*", "pb", ".", "PodSandboxFilter", ")", "bool", "{", "if", "filter", "!=", "nil", "{", "if", "filter", ".", "State", "!=", "nil", "{", "if", "p", ".", "State", "!=", "...
// filterSandbox returns whether passed container matches filtering criteria
[ "filterSandbox", "returns", "whether", "passed", "container", "matches", "filtering", "criteria" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/sandbox_list.go#L15-L30
train
cri-o/cri-o
server/sandbox_list.go
ListPodSandbox
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
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...
[ "func", "(", "s", "*", "Server", ")", "ListPodSandbox", "(", "ctx", "context", ".", "Context", ",", "req", "*", "pb", ".", "ListPodSandboxRequest", ")", "(", "resp", "*", "pb", ".", "ListPodSandboxResponse", ",", "err", "error", ")", "{", "const", "opera...
// ListPodSandbox returns a list of SandBoxes.
[ "ListPodSandbox", "returns", "a", "list", "of", "SandBoxes", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/sandbox_list.go#L33-L103
train
cri-o/cri-o
server/container_remove.go
RemoveContainer
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
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) // ...
[ "func", "(", "s", "*", "Server", ")", "RemoveContainer", "(", "ctx", "context", ".", "Context", ",", "req", "*", "pb", ".", "RemoveContainerRequest", ")", "(", "resp", "*", "pb", ".", "RemoveContainerResponse", ",", "err", "error", ")", "{", "const", "op...
// RemoveContainer removes the container. If the container is running, the container // should be force removed.
[ "RemoveContainer", "removes", "the", "container", ".", "If", "the", "container", "is", "running", "the", "container", "should", "be", "force", "removed", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/container_remove.go#L13-L36
train
cri-o/cri-o
utils/ioutil/read_closer.go
Close
func (w *wrapReadCloser) Close() error { w.reader.Close() w.writer.Close() return nil }
go
func (w *wrapReadCloser) Close() error { w.reader.Close() w.writer.Close() return nil }
[ "func", "(", "w", "*", "wrapReadCloser", ")", "Close", "(", ")", "error", "{", "w", ".", "reader", ".", "Close", "(", ")", "\n", "w", ".", "writer", ".", "Close", "(", ")", "\n", "return", "nil", "\n", "}" ]
// Close closes read closer.
[ "Close", "closes", "read", "closer", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/ioutil/read_closer.go#L53-L57
train
cri-o/cri-o
server/config.go
Validate
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
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(...
[ "func", "(", "c", "*", "Config", ")", "Validate", "(", "onExecution", "bool", ")", "error", "{", "switch", "c", ".", "ImageVolumes", "{", "case", "lib", ".", "ImageVolumesMkdir", ":", "case", "lib", ".", "ImageVolumesIgnore", ":", "case", "lib", ".", "Im...
// Validate is the main entry point for configuration validation // The parameter `onExecution` specifies if the validation should include // execution checks. It returns an `error` on validation failure, otherwise // `nil`.
[ "Validate", "is", "the", "main", "entry", "point", "for", "configuration", "validation", "The", "parameter", "onExecution", "specifies", "if", "the", "validation", "should", "include", "execution", "checks", ".", "It", "returns", "an", "error", "on", "validation",...
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/server/config.go#L167-L192
train
cri-o/cri-o
oci/runtime_oci.go
newRuntimeOCI
func newRuntimeOCI(r *Runtime, handler *RuntimeHandler) RuntimeImpl { return &runtimeOCI{ Runtime: r, path: handler.RuntimePath, root: handler.RuntimeRoot, } }
go
func newRuntimeOCI(r *Runtime, handler *RuntimeHandler) RuntimeImpl { return &runtimeOCI{ Runtime: r, path: handler.RuntimePath, root: handler.RuntimeRoot, } }
[ "func", "newRuntimeOCI", "(", "r", "*", "Runtime", ",", "handler", "*", "RuntimeHandler", ")", "RuntimeImpl", "{", "return", "&", "runtimeOCI", "{", "Runtime", ":", "r", ",", "path", ":", "handler", ".", "RuntimePath", ",", "root", ":", "handler", ".", "...
// newRuntimeOCI creates a new runtimeOCI instance
[ "newRuntimeOCI", "creates", "a", "new", "runtimeOCI", "instance" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/oci/runtime_oci.go#L49-L55
train
cri-o/cri-o
lib/sandbox/history.go
Less
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
func (history *History) Less(i, j int) bool { sandboxes := *history // FIXME: state access should be serialized return sandboxes[j].createdAt.Before(sandboxes[i].createdAt) }
[ "func", "(", "history", "*", "History", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "sandboxes", ":=", "*", "history", "\n", "// FIXME: state access should be serialized", "return", "sandboxes", "[", "j", "]", ".", "createdAt", ".", "Before", ...
// Less compares two sandboxes and returns true if the second one // was created before the first one.
[ "Less", "compares", "two", "sandboxes", "and", "returns", "true", "if", "the", "second", "one", "was", "created", "before", "the", "first", "one", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/history.go#L16-L20
train
cri-o/cri-o
lib/sandbox/history.go
Swap
func (history *History) Swap(i, j int) { sandboxes := *history sandboxes[i], sandboxes[j] = sandboxes[j], sandboxes[i] }
go
func (history *History) Swap(i, j int) { sandboxes := *history sandboxes[i], sandboxes[j] = sandboxes[j], sandboxes[i] }
[ "func", "(", "history", "*", "History", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "sandboxes", ":=", "*", "history", "\n", "sandboxes", "[", "i", "]", ",", "sandboxes", "[", "j", "]", "=", "sandboxes", "[", "j", "]", ",", "sandboxes", "["...
// Swap switches sandboxes i and j positions in the history.
[ "Swap", "switches", "sandboxes", "i", "and", "j", "positions", "in", "the", "history", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/sandbox/history.go#L23-L26
train
cri-o/cri-o
utils/io/exec_io.go
NewExecIO
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
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:...
[ "func", "NewExecIO", "(", "id", ",", "root", "string", ",", "tty", ",", "stdin", "bool", ")", "(", "*", "ExecIO", ",", "error", ")", "{", "fifos", ",", "err", ":=", "newFifos", "(", "root", ",", "id", ",", "tty", ",", "stdin", ")", "\n", "if", ...
// NewExecIO creates exec io.
[ "NewExecIO", "creates", "exec", "io", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/io/exec_io.go#L40-L55
train
cri-o/cri-o
utils/io/exec_io.go
Attach
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
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...
[ "func", "(", "e", "*", "ExecIO", ")", "Attach", "(", "opts", "AttachOptions", ")", "<-", "chan", "struct", "{", "}", "{", "var", "wg", "sync", ".", "WaitGroup", "\n", "var", "stdinStreamRC", "io", ".", "ReadCloser", "\n", "if", "e", ".", "stdin", "!=...
// Attach attaches exec stdio. The logic is similar with container io attach.
[ "Attach", "attaches", "exec", "stdio", ".", "The", "logic", "is", "similar", "with", "container", "io", "attach", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/io/exec_io.go#L63-L125
train
cri-o/cri-o
oci/stats.go
getContainerNetIO
func getContainerNetIO(stats *libcontainer.Stats) (received uint64, transmitted uint64) { for _, iface := range stats.Interfaces { received += iface.RxBytes transmitted += iface.TxBytes } return }
go
func getContainerNetIO(stats *libcontainer.Stats) (received uint64, transmitted uint64) { for _, iface := range stats.Interfaces { received += iface.RxBytes transmitted += iface.TxBytes } return }
[ "func", "getContainerNetIO", "(", "stats", "*", "libcontainer", ".", "Stats", ")", "(", "received", "uint64", ",", "transmitted", "uint64", ")", "{", "for", "_", ",", "iface", ":=", "range", "stats", ".", "Interfaces", "{", "received", "+=", "iface", ".", ...
// Returns the total number of bytes transmitted and received for the given container stats
[ "Returns", "the", "total", "number", "of", "bytes", "transmitted", "and", "received", "for", "the", "given", "container", "stats" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/oci/stats.go#L27-L33
train
cri-o/cri-o
oci/stats.go
getMemLimit
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
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 }
[ "func", "getMemLimit", "(", "cgroupLimit", "uint64", ")", "uint64", "{", "si", ":=", "&", "syscall", ".", "Sysinfo_t", "{", "}", "\n", "err", ":=", "syscall", ".", "Sysinfo", "(", "si", ")", "\n", "if", "err", "!=", "nil", "{", "return", "cgroupLimit",...
// getMemory limit returns the memory limit for a given cgroup // If the configured memory limit is larger than the total memory on the sys, the // physical system memory size is returned
[ "getMemory", "limit", "returns", "the", "memory", "limit", "for", "a", "given", "cgroup", "If", "the", "configured", "memory", "limit", "is", "larger", "than", "the", "total", "memory", "on", "the", "sys", "the", "physical", "system", "memory", "size", "is",...
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/oci/stats.go#L50-L62
train
cri-o/cri-o
utils/io/container_io.go
streamKey
func streamKey(id, name string, stream StreamType) string { return strings.Join([]string{id, name, string(stream)}, "-") }
go
func streamKey(id, name string, stream StreamType) string { return strings.Join([]string{id, name, string(stream)}, "-") }
[ "func", "streamKey", "(", "id", ",", "name", "string", ",", "stream", "StreamType", ")", "string", "{", "return", "strings", ".", "Join", "(", "[", "]", "string", "{", "id", ",", "name", ",", "string", "(", "stream", ")", "}", ",", "\"", "\"", ")",...
// streamKey generates a key for the stream.
[ "streamKey", "generates", "a", "key", "for", "the", "stream", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/io/container_io.go#L33-L35
train
cri-o/cri-o
utils/io/container_io.go
WithFIFOs
func WithFIFOs(fifos *cio.FIFOSet) ContainerIOOpts { return func(c *ContainerIO) error { c.fifos = fifos return nil } }
go
func WithFIFOs(fifos *cio.FIFOSet) ContainerIOOpts { return func(c *ContainerIO) error { c.fifos = fifos return nil } }
[ "func", "WithFIFOs", "(", "fifos", "*", "cio", ".", "FIFOSet", ")", "ContainerIOOpts", "{", "return", "func", "(", "c", "*", "ContainerIO", ")", "error", "{", "c", ".", "fifos", "=", "fifos", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// WithFIFOs specifies existing fifos for the container io.
[ "WithFIFOs", "specifies", "existing", "fifos", "for", "the", "container", "io", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/io/container_io.go#L56-L61
train
cri-o/cri-o
utils/io/container_io.go
WithNewFIFOs
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
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) } }
[ "func", "WithNewFIFOs", "(", "root", "string", ",", "tty", ",", "stdin", "bool", ")", "ContainerIOOpts", "{", "return", "func", "(", "c", "*", "ContainerIO", ")", "error", "{", "fifos", ",", "err", ":=", "newFifos", "(", "root", ",", "c", ".", "id", ...
// WithNewFIFOs creates new fifos for the container io.
[ "WithNewFIFOs", "creates", "new", "fifos", "for", "the", "container", "io", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/io/container_io.go#L64-L72
train
cri-o/cri-o
utils/io/container_io.go
NewContainerIO
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
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 { ...
[ "func", "NewContainerIO", "(", "id", "string", ",", "opts", "...", "ContainerIOOpts", ")", "(", "_", "*", "ContainerIO", ",", "err", "error", ")", "{", "c", ":=", "&", "ContainerIO", "{", "id", ":", "id", ",", "stdoutGroup", ":", "cioutil", ".", "NewWr...
// NewContainerIO creates container io.
[ "NewContainerIO", "creates", "container", "io", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/io/container_io.go#L75-L97
train
cri-o/cri-o
utils/io/container_io.go
Pipe
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
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...
[ "func", "(", "c", "*", "ContainerIO", ")", "Pipe", "(", ")", "{", "wg", ":=", "c", ".", "closer", ".", "wg", "\n", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", ")", "{", "if", "_", ",", "err", ":=", "io", ".", "Copy", "(", "c...
// Pipe creates container fifos and pipe container output // to output stream.
[ "Pipe", "creates", "container", "fifos", "and", "pipe", "container", "output", "to", "output", "stream", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/io/container_io.go#L106-L131
train
cri-o/cri-o
utils/io/container_io.go
AddOutput
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
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...
[ "func", "(", "c", "*", "ContainerIO", ")", "AddOutput", "(", "name", "string", ",", "stdout", ",", "stderr", "io", ".", "WriteCloser", ")", "(", "io", ".", "WriteCloser", ",", "io", ".", "WriteCloser", ")", "{", "var", "oldStdout", ",", "oldStderr", "i...
// AddOutput adds new write closers to the container stream, and returns existing // write closers if there are any.
[ "AddOutput", "adds", "new", "write", "closers", "to", "the", "container", "stream", "and", "returns", "existing", "write", "closers", "if", "there", "are", "any", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/io/container_io.go#L202-L215
train
cri-o/cri-o
lib/logs.go
GetLogs
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
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...
[ "func", "(", "c", "*", "ContainerServer", ")", "GetLogs", "(", "container", "string", ",", "logChan", "chan", "string", ",", "opts", "LogOptions", ")", "error", "{", "defer", "close", "(", "logChan", ")", "\n", "// Get the full ID of the container", "ctr", ","...
// GetLogs gets each line of a log file and, if it matches the criteria in logOptions, sends it down logChan
[ "GetLogs", "gets", "each", "line", "of", "a", "log", "file", "and", "if", "it", "matches", "the", "criteria", "in", "logOptions", "sends", "it", "down", "logChan" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/lib/logs.go#L20-L52
train
cri-o/cri-o
oci/container.go
NewContainer
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
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...
[ "func", "NewContainer", "(", "id", "string", ",", "name", "string", ",", "bundlePath", "string", ",", "logPath", "string", ",", "netns", "string", ",", "labels", "map", "[", "string", "]", "string", ",", "crioAnnotations", "map", "[", "string", "]", "strin...
// NewContainer creates a container object.
[ "NewContainer", "creates", "a", "container", "object", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/oci/container.go#L79-L106
train
cri-o/cri-o
oci/container.go
GetStopSignal
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
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 }
[ "func", "(", "c", "*", "Container", ")", "GetStopSignal", "(", ")", "string", "{", "if", "c", ".", "stopSignal", "==", "\"", "\"", "{", "return", "defaultStopSignal", "\n", "}", "\n", "cleanSignal", ":=", "strings", ".", "TrimPrefix", "(", "strings", "."...
// GetStopSignal returns the container's own stop signal configured from the // image configuration or the default one.
[ "GetStopSignal", "returns", "the", "container", "s", "own", "stop", "signal", "configured", "from", "the", "image", "configuration", "or", "the", "default", "one", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/oci/container.go#L120-L130
train
cri-o/cri-o
oci/container.go
StopSignal
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
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 }
[ "func", "(", "c", "*", "Container", ")", "StopSignal", "(", ")", "syscall", ".", "Signal", "{", "if", "c", ".", "stopSignal", "==", "\"", "\"", "{", "return", "defaultStopSignalInt", "\n", "}", "\n", "cleanSignal", ":=", "strings", ".", "TrimPrefix", "("...
// StopSignal returns the container's own stop signal configured from // the image configuration or the default one.
[ "StopSignal", "returns", "the", "container", "s", "own", "stop", "signal", "configured", "from", "the", "image", "configuration", "or", "the", "default", "one", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/oci/container.go#L134-L144
train
cri-o/cri-o
oci/container.go
FromDisk
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
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) }
[ "func", "(", "c", "*", "Container", ")", "FromDisk", "(", ")", "error", "{", "jsonSource", ",", "err", ":=", "os", ".", "Open", "(", "c", ".", "StatePath", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "d...
// FromDisk restores container's state from disk
[ "FromDisk", "restores", "container", "s", "state", "from", "disk" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/oci/container.go#L147-L156
train
cri-o/cri-o
oci/container.go
NetNsPath
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
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 }
[ "func", "(", "c", "*", "Container", ")", "NetNsPath", "(", ")", "(", "string", ",", "error", ")", "{", "if", "c", ".", "state", "==", "nil", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", ...
// NetNsPath returns the path to the network namespace of the container.
[ "NetNsPath", "returns", "the", "path", "to", "the", "network", "namespace", "of", "the", "container", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/oci/container.go#L239-L249
train
cri-o/cri-o
oci/container.go
State
func (c *Container) State() *ContainerState { c.opLock.RLock() defer c.opLock.RUnlock() return c.state }
go
func (c *Container) State() *ContainerState { c.opLock.RLock() defer c.opLock.RUnlock() return c.state }
[ "func", "(", "c", "*", "Container", ")", "State", "(", ")", "*", "ContainerState", "{", "c", ".", "opLock", ".", "RLock", "(", ")", "\n", "defer", "c", ".", "opLock", ".", "RUnlock", "(", ")", "\n", "return", "c", ".", "state", "\n", "}" ]
// State returns the state of the running container
[ "State", "returns", "the", "state", "of", "the", "running", "container" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/oci/container.go#L257-L261
train
cri-o/cri-o
oci/container.go
AddVolume
func (c *Container) AddVolume(v ContainerVolume) { c.volumes = append(c.volumes, v) }
go
func (c *Container) AddVolume(v ContainerVolume) { c.volumes = append(c.volumes, v) }
[ "func", "(", "c", "*", "Container", ")", "AddVolume", "(", "v", "ContainerVolume", ")", "{", "c", ".", "volumes", "=", "append", "(", "c", ".", "volumes", ",", "v", ")", "\n", "}" ]
// AddVolume adds a volume to list of container volumes.
[ "AddVolume", "adds", "a", "volume", "to", "list", "of", "container", "volumes", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/oci/container.go#L269-L271
train
cri-o/cri-o
oci/container.go
SetStartFailed
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
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() } }
[ "func", "(", "c", "*", "Container", ")", "SetStartFailed", "(", "err", "error", ")", "{", "c", ".", "opLock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "opLock", ".", "Unlock", "(", ")", "\n", "// adjust finished and started times", "c", ".", "st...
// SetStartFailed sets the container state appropriately after a start failure
[ "SetStartFailed", "sets", "the", "container", "state", "appropriately", "after", "a", "start", "failure" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/oci/container.go#L310-L318
train
cri-o/cri-o
oci/container.go
Description
func (c *Container) Description() string { return fmt.Sprintf("%s/%s/%s", c.Labels()[types.KubernetesPodNamespaceLabel], c.Labels()[types.KubernetesPodNameLabel], c.Labels()[types.KubernetesContainerNameLabel]) }
go
func (c *Container) Description() string { return fmt.Sprintf("%s/%s/%s", c.Labels()[types.KubernetesPodNamespaceLabel], c.Labels()[types.KubernetesPodNameLabel], c.Labels()[types.KubernetesContainerNameLabel]) }
[ "func", "(", "c", "*", "Container", ")", "Description", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "Labels", "(", ")", "[", "types", ".", "KubernetesPodNamespaceLabel", "]", ",", "c", ".", "Labels", "(",...
// Description returns a description for the container
[ "Description", "returns", "a", "description", "for", "the", "container" ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/oci/container.go#L321-L323
train
cri-o/cri-o
utils/ioutil/write_closer.go
NewWriteCloseInformer
func NewWriteCloseInformer(wc io.WriteCloser) (io.WriteCloser, <-chan struct{}) { close := make(chan struct{}) return &writeCloseInformer{ close: close, wc: wc, }, close }
go
func NewWriteCloseInformer(wc io.WriteCloser) (io.WriteCloser, <-chan struct{}) { close := make(chan struct{}) return &writeCloseInformer{ close: close, wc: wc, }, close }
[ "func", "NewWriteCloseInformer", "(", "wc", "io", ".", "WriteCloser", ")", "(", "io", ".", "WriteCloser", ",", "<-", "chan", "struct", "{", "}", ")", "{", "close", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "return", "&", "writeCloseInfo...
// NewWriteCloseInformer creates the writeCloseInformer from a write closer.
[ "NewWriteCloseInformer", "creates", "the", "writeCloseInformer", "from", "a", "write", "closer", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/ioutil/write_closer.go#L33-L39
train
cri-o/cri-o
utils/ioutil/write_closer.go
Write
func (w *writeCloseInformer) Write(p []byte) (int, error) { return w.wc.Write(p) }
go
func (w *writeCloseInformer) Write(p []byte) (int, error) { return w.wc.Write(p) }
[ "func", "(", "w", "*", "writeCloseInformer", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "return", "w", ".", "wc", ".", "Write", "(", "p", ")", "\n", "}" ]
// Write passes through the data into the internal write closer.
[ "Write", "passes", "through", "the", "data", "into", "the", "internal", "write", "closer", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/ioutil/write_closer.go#L42-L44
train
cri-o/cri-o
utils/ioutil/write_closer.go
Close
func (w *writeCloseInformer) Close() error { err := w.wc.Close() close(w.close) return err }
go
func (w *writeCloseInformer) Close() error { err := w.wc.Close() close(w.close) return err }
[ "func", "(", "w", "*", "writeCloseInformer", ")", "Close", "(", ")", "error", "{", "err", ":=", "w", ".", "wc", ".", "Close", "(", ")", "\n", "close", "(", "w", ".", "close", ")", "\n", "return", "err", "\n", "}" ]
// Close closes the internal write closer and inform the close channel.
[ "Close", "closes", "the", "internal", "write", "closer", "and", "inform", "the", "close", "channel", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/ioutil/write_closer.go#L47-L51
train
cri-o/cri-o
utils/ioutil/write_closer.go
Write
func (n *nopWriteCloser) Write(p []byte) (int, error) { return n.w.Write(p) }
go
func (n *nopWriteCloser) Write(p []byte) (int, error) { return n.w.Write(p) }
[ "func", "(", "n", "*", "nopWriteCloser", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "return", "n", ".", "w", ".", "Write", "(", "p", ")", "\n", "}" ]
// Write passes through the data into the internal writer.
[ "Write", "passes", "through", "the", "data", "into", "the", "internal", "writer", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/ioutil/write_closer.go#L64-L66
train
cri-o/cri-o
utils/ioutil/write_closer.go
Write
func (s *serialWriteCloser) Write(data []byte) (int, error) { s.mu.Lock() defer s.mu.Unlock() return s.wc.Write(data) }
go
func (s *serialWriteCloser) Write(data []byte) (int, error) { s.mu.Lock() defer s.mu.Unlock() return s.wc.Write(data) }
[ "func", "(", "s", "*", "serialWriteCloser", ")", "Write", "(", "data", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "...
// Write writes a group of byte arrays in order atomically.
[ "Write", "writes", "a", "group", "of", "byte", "arrays", "in", "order", "atomically", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/ioutil/write_closer.go#L91-L95
train
cri-o/cri-o
utils/ioutil/write_closer.go
Close
func (s *serialWriteCloser) Close() error { s.mu.Lock() defer s.mu.Unlock() return s.wc.Close() }
go
func (s *serialWriteCloser) Close() error { s.mu.Lock() defer s.mu.Unlock() return s.wc.Close() }
[ "func", "(", "s", "*", "serialWriteCloser", ")", "Close", "(", ")", "error", "{", "s", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "s", ".", "wc", ".", "Close", "(", ")", "\n", "}"...
// Close closes the write closer.
[ "Close", "closes", "the", "write", "closer", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/utils/ioutil/write_closer.go#L98-L102
train
cri-o/cri-o
pkg/seccomp/seccomp.go
IsEnabled
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
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...
[ "func", "IsEnabled", "(", ")", "bool", "{", "enabled", ":=", "false", "\n", "// Check if Seccomp is supported, via CONFIG_SECCOMP.", "if", "err", ":=", "unix", ".", "Prctl", "(", "unix", ".", "PR_GET_SECCOMP", ",", "0", ",", "0", ",", "0", ",", "0", ")", "...
// IsEnabled returns true if seccomp is enabled for the host.
[ "IsEnabled", "returns", "true", "if", "seccomp", "is", "enabled", "for", "the", "host", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/pkg/seccomp/seccomp.go#L19-L30
train
cri-o/cri-o
pkg/seccomp/seccomp.go
LoadProfileFromStruct
func LoadProfileFromStruct(config *Seccomp, specgen *generate.Generator) error { return setupSeccomp(config, specgen) }
go
func LoadProfileFromStruct(config *Seccomp, specgen *generate.Generator) error { return setupSeccomp(config, specgen) }
[ "func", "LoadProfileFromStruct", "(", "config", "*", "Seccomp", ",", "specgen", "*", "generate", ".", "Generator", ")", "error", "{", "return", "setupSeccomp", "(", "config", ",", "specgen", ")", "\n", "}" ]
// LoadProfileFromStruct takes a Seccomp struct and setup seccomp in the spec.
[ "LoadProfileFromStruct", "takes", "a", "Seccomp", "struct", "and", "setup", "seccomp", "in", "the", "spec", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/pkg/seccomp/seccomp.go#L33-L35
train
cri-o/cri-o
pkg/seccomp/seccomp.go
LoadProfileFromBytes
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
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) }
[ "func", "LoadProfileFromBytes", "(", "body", "[", "]", "byte", ",", "specgen", "*", "generate", ".", "Generator", ")", "error", "{", "config", ":=", "&", "Seccomp", "{", "}", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "body", ",", "config"...
// LoadProfileFromBytes takes a byte slice and decodes the seccomp profile.
[ "LoadProfileFromBytes", "takes", "a", "byte", "slice", "and", "decodes", "the", "seccomp", "profile", "." ]
0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5
https://github.com/cri-o/cri-o/blob/0eac7be02d0a9d12b8b4bd1f2f0919c386ed61f5/pkg/seccomp/seccomp.go#L38-L44
train