Documentation ¶
Index ¶
- Constants
- type Container
- func (c *Container) CleanupArtifacts() error
- func (c *Container) GetEnv() []string
- func (c *Container) Load() error
- func (c *Container) Run() (string, error)
- func (c *Container) SetRunStatus(containerID string, newStatus string) error
- func (c *Container) SetUpdatedAt()
- func (c *Container) Unload() error
- func (c *Container) Validate() error
- type ContainerOption
- type ContainerRun
- type Output
- type OutputLine
Constants ¶
const ( StdoutType = "stdout" StderrType = "stderr" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct { // Configuration Name string `json:"name"` Image string `json:"image"` Cmd []string `json:"cmd"` Env map[string]string `json:"env"` EntryPoint []string `json:"entrypoint"` RetainArtifacts bool `json:"retain_artifacts"` // Runtime information CreatedAt *time.Time `json:"created_at,omitempty"` UpdatedAt *time.Time `json:"updated_at,omitempty"` ImageExists bool `json:"image_exists"` Runs map[string]*ContainerRun `json:"runs"` // contains filtered or unexported fields }
func NewContainer ¶
func NewContainer(options ...ContainerOption) (*Container, error)
NewConfig creates a new Function Config with the provided options.
func (*Container) CleanupArtifacts ¶
Cleanup all docker containers for the given container.
func (*Container) SetRunStatus ¶
func (*Container) SetUpdatedAt ¶
func (c *Container) SetUpdatedAt()
SetUpdatedAt sets the updated at time.
type ContainerOption ¶
Option defines a function signature for configuring the Docker client.
func WithContext ¶
func WithContext(ctx context.Context) ContainerOption
WithContext configures the Docker client with a specific context.
func WithDockerClient ¶
func WithDockerClient(client *docker.DockerClient) ContainerOption
WithConfigDockerClient configures the Docker client.
func WithRunContext ¶
func WithRunContext(ctx context.Context) ContainerOption
type ContainerRun ¶
type Output ¶
type Output struct {
Lines []OutputLine
}
func (*Output) Combined ¶
Combined returns the combined stdout and stderr output as a single string.
func (*Output) FromDockerLogsReader ¶
FromDockerLogsReader reads the output from a docker logs reader and populates the Output struct. Docker logs inject a control character at the start of each line to indicate if it's stdout or stderr.
For example, the bytes output: [1 0 0 0 0 0 0 2 123 10 1 0 0 0 0 0 0 14 32 32 32 32 34 86 112 99 115 34 58 32 91 10
which corresponds to the stdout: 1 0 0 0 0 0 0 2 { 1 0 0 0 0 0 0 14 "Vpcs": [
Specifically it has "1 0 0 0 w x y z" as the start of each line, indicating stdout (1) or stderr (2) and with the last 4 bytes being the length of the payload.
See https://github.com/moby/moby/issues/7375#issuecomment-51462963
This function will read that input into our Output struct so we can choose the format we want later.