Documentation
¶
Index ¶
- Variables
- func ExecCommandEndpoint(svc Service) endpoint.Endpoint
- func ImageDescriptionEndpoint(svc Service) endpoint.Endpoint
- func ListContainersEndpoint(svc Service) endpoint.Endpoint
- func ListImagesEndpoint(svc Service) endpoint.Endpoint
- func LogsContainerEndpoint(svc Service) endpoint.Endpoint
- func PullImageEndpoint(svc Service) endpoint.Endpoint
- func RemoveAllContainersEndpoint(svc Service) endpoint.Endpoint
- func RemoveContainerEndpoint(svc Service) endpoint.Endpoint
- func RunContainerEndpoint(svc Service) endpoint.Endpoint
- func RunContainerOnceEndpoint(svc Service) endpoint.Endpoint
- func SendAndReadEndpoint(svc Service) endpoint.Endpoint
- func SendToContainerEndpoint(svc Service) endpoint.Endpoint
- func WaitEndpoint(svc Service) endpoint.Endpoint
- type Container
- type ContextKey
- type ExecCommandRequest
- type ListImagesRequest
- type LogsContainerRequest
- type RemoveContainerRequest
- type RunContainerRequest
- type SendAndReadRequest
- type SendToContainerRequest
- type Service
- type ServiceMiddleware
- type WaitRequest
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoWorkspaceID = errors.New("no workspace ID in context") ErrWorkspaceNotFound = errors.New("workspace not found") ErrContainerNotFound = errors.New("container not found in workspace") ErrContainerNotRunning = errors.New("container is not running") )
View Source
var (
ErrInvalidRequest = errors.New("invalid request")
)
Functions ¶
func ExecCommandEndpoint ¶
func ListContainersEndpoint ¶
func ListImagesEndpoint ¶
func LogsContainerEndpoint ¶
func PullImageEndpoint ¶
func RemoveContainerEndpoint ¶
func RunContainerEndpoint ¶
func SendAndReadEndpoint ¶
func SendToContainerEndpoint ¶
func WaitEndpoint ¶
Types ¶
type Container ¶
func (*Container) MarshalJSON ¶
type ExecCommandRequest ¶
type ListImagesRequest ¶
type LogsContainerRequest ¶
func (*LogsContainerRequest) UnmarshalJSON ¶
func (req *LogsContainerRequest) UnmarshalJSON(data []byte) error
type RemoveContainerRequest ¶
type RemoveContainerRequest struct {
ContainerID string `json:"container_id"`
}
type RunContainerRequest ¶
type SendAndReadRequest ¶
func (*SendAndReadRequest) UnmarshalJSON ¶
func (req *SendAndReadRequest) UnmarshalJSON(data []byte) error
type SendToContainerRequest ¶
type Service ¶
type Service interface {
// ImageDescription retrieves the description of a Docker image from Docker Hub.
// i.e. https://hub.docker.com/v2/repositories/<image>
ImageDescription(ctx context.Context, image string) (description string, err error)
// ListImages lists all available Docker images on the host.
// i.e. sudo docker images
ListImages(ctx context.Context, page int, pageSize int) (images []string, err error)
// PullImage pulls a Docker image from a registry.
// i.e. sudo docker pull <image>
PullImage(ctx context.Context, image string) error
// ListContainers lists all containers in the current workspace.
// i.e. sudo docker ps -a --filter "label=workspace=<workspaceID>"
ListContainers(ctx context.Context) (containers []*Container, err error)
// RunContainerOnce runs a container to execute a command and then removes the container.
// i.e. sudo docker run --rm alpine:latest echo hello world
RunContainerOnce(ctx context.Context, image string, mountPath string, workDir string, cmd ...string) (output string, err error)
// RunContainer runs a container with interactive shell.
// i.e. sudo docker run -id alpine:latest /bin/sh
RunContainer(ctx context.Context, image string, mountPath string, workDir string, cmd ...string) (containerID string, err error)
// SendToContainer sends input to the container's stdin.
SendToContainer(ctx context.Context, containerID string, input string) error
// LogsContainer retrieves the logs of a container.
// i.e. sudo docker logs --tail <lines> <containerID>
LogsContainer(ctx context.Context, containerID string, since time.Time, tail ...int) (output string, err error)
// ExecCommand executes a command in a running container.
// i.e. sudo docker exec <containerID> <command>
ExecCommand(ctx context.Context, containerID string, cmd ...string) (output string, err error)
// Wait waits for the specified duration.
Wait(ctx context.Context, timeout time.Duration)
// SendAndRead sends input to the container's stdin and reads the output.
SendAndRead(ctx context.Context, containerID string, input string, wait time.Duration) (output string, err error)
// RemoveContainer removes a container.
// i.e. sudo docker rm -f <containerID>
RemoveContainer(ctx context.Context, containerID string) error
// RemoveAllContainers removes all containers in the current workspace.
RemoveAllContainers(ctx context.Context) error
// Close closes the service and cleans up any resources.
Close(ctx context.Context) error
}
func NewService ¶
type ServiceMiddleware ¶
func LoggingMiddleware ¶
func LoggingMiddleware(log *zap.Logger) ServiceMiddleware
type WaitRequest ¶
Click to show internal directories.
Click to hide internal directories.