Documentation ¶
Index ¶
- Constants
- type Container
- func (c *Container) Build() error
- func (c *Container) CleanupArtifacts(keepLatest bool) error
- func (c *Container) GetImageLatestTag() string
- func (c *Container) GetImageName() string
- func (c *Container) GetImageTag() string
- func (c *Container) IsFromSource() bool
- func (c *Container) Load() error
- func (c *Container) Run(cConfig ContainerRunConfig) (string, int, error)
- func (c *Container) SetRunStatus(containerID string, newStatus string) error
- func (c *Container) SetUpdatedAt()
- func (c *Container) Unload() error
- func (c *Container) Validate() error
- func (c *Container) Watch() error
- type ContainerOption
- type ContainerRun
- type ContainerRunConfig
- type Output
- type OutputLine
- type StreamLines
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"` Source string `json:"source"` // 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)
NewContainer creates a new Container with the provided ContainerOption.
func (*Container) CleanupArtifacts ¶
CleanupArtifacts will clean up all docker artifacts for the given container
func (*Container) GetImageLatestTag ¶ added in v0.2.0
GetImageLatestTag returns the docker image name with latest as tag
func (*Container) GetImageName ¶ added in v0.2.0
GetImageName returns the docker image name (e.g. flowpipe/my_func) for the function.
func (*Container) GetImageTag ¶ added in v0.2.0
GetImageTag returns the docker image name and a timestamped tag
func (*Container) IsFromSource ¶ added in v0.2.0
func (*Container) SetRunStatus ¶
func (*Container) SetUpdatedAt ¶
func (c *Container) SetUpdatedAt()
SetUpdatedAt sets the updated at time.
type ContainerOption ¶
ContainerOption defines a function signature for configuring the Container.
func WithContext ¶
func WithContext(ctx context.Context) ContainerOption
WithContext configures the Container with a specific context.
func WithDockerClient ¶
func WithDockerClient(client *docker.DockerClient) ContainerOption
WithDockerClient configures the Docker client.
func WithName ¶ added in v0.2.0
func WithName(name string) ContainerOption
func WithRunContext ¶
func WithRunContext(ctx context.Context) ContainerOption
WithRunContext configures the Container with a specific run context.
type ContainerRun ¶
type ContainerRun struct { ContainerID string `json:"container_id"` Status string `json:"status"` Stdout string `json:"stdout"` Stderr string `json:"stderr"` Lines []OutputLine `json:"lines"` }
type ContainerRunConfig ¶ added in v0.2.1
type ContainerRunConfig struct { Cmd []string `json:"cmd"` Env map[string]string `json:"env"` EntryPoint []string `json:"entrypoint"` RetainArtifacts bool `json:"retain_artifacts"` Timeout *int64 `json:"timeout"` User string `json:"user"` Workdir string `json:"workdir"` // Host configuration Memory *int64 `json:"memory"` MemoryReservation *int64 `json:"memory_reservation"` MemorySwap *int64 `json:"memory_swap"` MemorySwappiness *int64 `json:"memory_swappiness"` ReadOnly *bool `json:"read_only"` }
func (*ContainerRunConfig) GetEnv ¶ added in v0.2.1
func (crc *ContainerRunConfig) GetEnv() []string
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.