compose/containers/api.go

60 lines
1.5 KiB
Go
Raw Normal View History

package containers
import (
"context"
2020-05-03 13:35:25 +02:00
"io"
)
2020-05-03 13:35:25 +02:00
// Container represents a created container
type Container struct {
ID string
Status string
Image string
Command string
CPUTime uint64
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
}
// 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
}
// 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
// Delete removes containers
Delete(ctx context.Context, id string, force bool) error
}