Unexport certain internal funcs and types
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
5c246d038f
commit
d909440c48
|
@ -2,7 +2,7 @@ package libcontainer
|
|||
|
||||
import "io"
|
||||
|
||||
// Console is a psuedo TTY.
|
||||
// Console represents a psuedo TTY.
|
||||
type Console interface {
|
||||
io.ReadWriter
|
||||
io.Closer
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
NOTE: The API is in flux and mainly not implemented. Proceed with caution until further notice.
|
||||
*/
|
||||
// Libcontainer provides a native Go implementation for creating containers
|
||||
// with namespaces, cgroups, capabilities, and filesystem access controls.
|
||||
// It allows you to manage the lifecycle of the container performing additional operations
|
||||
// after the container is created.
|
||||
package libcontainer
|
||||
|
||||
import (
|
||||
|
|
|
@ -23,7 +23,7 @@ func newGenericError(err error, c ErrorCode) Error {
|
|||
if le, ok := err.(Error); ok {
|
||||
return le
|
||||
}
|
||||
return &GenericError{
|
||||
return &genericError{
|
||||
Timestamp: time.Now(),
|
||||
Err: err,
|
||||
ECode: c,
|
||||
|
@ -35,7 +35,7 @@ func newSystemError(err error) Error {
|
|||
if le, ok := err.(Error); ok {
|
||||
return le
|
||||
}
|
||||
return &GenericError{
|
||||
return &genericError{
|
||||
Timestamp: time.Now(),
|
||||
Err: err,
|
||||
ECode: SystemError,
|
||||
|
@ -43,21 +43,21 @@ func newSystemError(err error) Error {
|
|||
}
|
||||
}
|
||||
|
||||
type GenericError struct {
|
||||
type genericError struct {
|
||||
Timestamp time.Time
|
||||
ECode ErrorCode
|
||||
Err error
|
||||
Stack stacktrace.Stacktrace
|
||||
}
|
||||
|
||||
func (e *GenericError) Error() string {
|
||||
func (e *genericError) Error() string {
|
||||
return fmt.Sprintf("[%d] %s: %s", e.ECode, e.ECode, e.Err)
|
||||
}
|
||||
|
||||
func (e *GenericError) Code() ErrorCode {
|
||||
func (e *genericError) Code() ErrorCode {
|
||||
return e.ECode
|
||||
}
|
||||
|
||||
func (e *GenericError) Detail(w io.Writer) error {
|
||||
func (e *genericError) Detail(w io.Writer) error {
|
||||
return errorTemplate.Execute(w, e)
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import (
|
|||
"github.com/docker/libcontainer/label"
|
||||
)
|
||||
|
||||
// NewConsole returns an initalized console that can be used within a container by copying bytes
|
||||
// from the master side to the slave that is attached as the tty for the container's init process.
|
||||
func NewConsole() (Console, error) {
|
||||
master, err := os.OpenFile("/dev/ptmx", syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_CLOEXEC, 0)
|
||||
if err != nil {
|
||||
|
|
|
@ -289,7 +289,7 @@ func (c *linuxContainer) Signal(signal os.Signal) error {
|
|||
}
|
||||
|
||||
func (c *linuxContainer) NotifyOOM() (<-chan struct{}, error) {
|
||||
return NotifyOnOOM(c.cgroupManager.GetPaths())
|
||||
return notifyOnOOM(c.cgroupManager.GetPaths())
|
||||
}
|
||||
|
||||
func (c *linuxContainer) updateState(process parentProcess) error {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
package libcontainer
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
|
@ -15,10 +14,6 @@ import (
|
|||
"github.com/docker/libcontainer/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotValidStrategyType = errors.New("not a valid network strategy type")
|
||||
)
|
||||
|
||||
var strategies = map[string]networkStrategy{
|
||||
"veth": &veth{},
|
||||
"loopback": &loopback{},
|
||||
|
@ -32,19 +27,18 @@ type networkStrategy interface {
|
|||
}
|
||||
|
||||
// getStrategy returns the specific network strategy for the
|
||||
// provided type. If no strategy is registered for the type an
|
||||
// ErrNotValidStrategyType is returned.
|
||||
// provided type.
|
||||
func getStrategy(tpe string) (networkStrategy, error) {
|
||||
s, exists := strategies[tpe]
|
||||
if !exists {
|
||||
return nil, ErrNotValidStrategyType
|
||||
return nil, fmt.Errorf("unknown strategy type %q", tpe)
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// Returns the network statistics for the network interfaces represented by the NetworkRuntimeInfo.
|
||||
func getNetworkInterfaceStats(interfaceName string) (*NetworkInterface, error) {
|
||||
out := &NetworkInterface{Name: interfaceName}
|
||||
func getNetworkInterfaceStats(interfaceName string) (*networkInterface, error) {
|
||||
out := &networkInterface{Name: interfaceName}
|
||||
// This can happen if the network runtime information is missing - possible if the
|
||||
// container was created by an old version of libcontainer.
|
||||
if interfaceName == "" {
|
||||
|
|
|
@ -12,10 +12,10 @@ import (
|
|||
|
||||
const oomCgroupName = "memory"
|
||||
|
||||
// NotifyOnOOM returns channel on which you can expect event about OOM,
|
||||
// notifyOnOOM returns channel on which you can expect event about OOM,
|
||||
// if process died without OOM this channel will be closed.
|
||||
// s is current *libcontainer.State for container.
|
||||
func NotifyOnOOM(paths map[string]string) (<-chan struct{}, error) {
|
||||
func notifyOnOOM(paths map[string]string) (<-chan struct{}, error) {
|
||||
dir := paths[oomCgroupName]
|
||||
if dir == "" {
|
||||
return nil, fmt.Errorf("There is no path for %q in state", oomCgroupName)
|
|
@ -30,7 +30,7 @@ func TestNotifyOnOOM(t *testing.T) {
|
|||
paths := map[string]string{
|
||||
"memory": memoryPath,
|
||||
}
|
||||
ooms, err := NotifyOnOOM(paths)
|
||||
ooms, err := notifyOnOOM(paths)
|
||||
if err != nil {
|
||||
t.Fatal("expected no error, got:", err)
|
||||
}
|
12
stats.go
12
stats.go
|
@ -2,7 +2,12 @@ package libcontainer
|
|||
|
||||
import "github.com/docker/libcontainer/cgroups"
|
||||
|
||||
type NetworkInterface struct {
|
||||
type Stats struct {
|
||||
Interfaces []*networkInterface
|
||||
CgroupStats *cgroups.Stats
|
||||
}
|
||||
|
||||
type networkInterface struct {
|
||||
// Name is the name of the network interface.
|
||||
Name string
|
||||
|
||||
|
@ -15,8 +20,3 @@ type NetworkInterface struct {
|
|||
TxErrors uint64
|
||||
TxDropped uint64
|
||||
}
|
||||
|
||||
type Stats struct {
|
||||
Interfaces []*NetworkInterface
|
||||
CgroupStats *cgroups.Stats
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue