2020-04-29 19:57:53 +02:00
|
|
|
package containers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-05-03 13:35:25 +02:00
|
|
|
"io"
|
2020-04-29 19:57:53 +02:00
|
|
|
)
|
|
|
|
|
2020-05-03 13:35:25 +02:00
|
|
|
// Container represents a created container
|
2020-04-29 19:57:53 +02:00
|
|
|
type Container struct {
|
|
|
|
ID string
|
|
|
|
Status string
|
|
|
|
Image string
|
|
|
|
Command string
|
2020-05-04 23:00:21 +02:00
|
|
|
CPUTime uint64
|
2020-04-29 19:57:53 +02:00
|
|
|
MemoryUsage uint64
|
|
|
|
MemoryLimit uint64
|
|
|
|
PidsCurrent uint64
|
|
|
|
PidsLimit uint64
|
|
|
|
Labels []string
|
|
|
|
}
|
|
|
|
|
2020-05-03 13:35:25 +02:00
|
|
|
// Port represents a published port of a container
|
2020-05-01 15:28:44 +02:00
|
|
|
type Port struct {
|
2020-05-03 13:35:25 +02:00
|
|
|
// Source is the source port
|
|
|
|
Source uint32
|
|
|
|
// Destination is the destination port
|
2020-05-01 16:03:33 +02:00
|
|
|
Destination uint32
|
2020-05-01 15:28:44 +02:00
|
|
|
}
|
|
|
|
|
2020-05-03 13:35:25 +02:00
|
|
|
// ContainerConfig contains the configuration data about a container
|
2020-05-01 15:28:44 +02:00
|
|
|
type ContainerConfig struct {
|
2020-05-03 13:35:25 +02:00
|
|
|
// ID uniquely identifies the container
|
|
|
|
ID string
|
|
|
|
// Image specifies the iamge reference used for a container
|
2020-05-01 15:28:44 +02:00
|
|
|
Image string
|
2020-05-03 13:35:25 +02:00
|
|
|
// Ports provide a list of published ports
|
2020-05-01 15:28:44 +02:00
|
|
|
Ports []Port
|
|
|
|
}
|
|
|
|
|
2020-05-04 23:00:21 +02:00
|
|
|
// LogsRequest contains configuration about a log request
|
2020-05-04 16:38:02 +02:00
|
|
|
type LogsRequest struct {
|
|
|
|
Follow bool
|
|
|
|
Tail string
|
|
|
|
Writer io.Writer
|
|
|
|
}
|
|
|
|
|
2020-05-05 15:37:12 +02:00
|
|
|
// Service interacts with the underlying container backend
|
|
|
|
type Service interface {
|
2020-05-03 13:35:25 +02:00
|
|
|
// List returns all the containers
|
|
|
|
List(ctx context.Context) ([]Container, error)
|
|
|
|
// Run creates and starts a container
|
|
|
|
Run(ctx context.Context, config ContainerConfig) error
|
|
|
|
// Exec executes a command inside a running container
|
|
|
|
Exec(ctx context.Context, containerName string, command string, reader io.Reader, writer io.Writer) error
|
2020-05-03 13:41:45 +02:00
|
|
|
// Logs returns all the logs of a container
|
2020-05-04 16:38:02 +02:00
|
|
|
Logs(ctx context.Context, containerName string, request LogsRequest) error
|
2020-05-10 22:37:28 +02:00
|
|
|
// Delete removes containers
|
|
|
|
Delete(ctx context.Context, id string, force bool) error
|
2020-04-29 19:57:53 +02:00
|
|
|
}
|