Documentation
¶
Index ¶
- func Build(ctx context.Context, log *slog.Logger, imageName string, dockerfilePath string, ...) error
- func Exec(ctx context.Context, cli *client.Client, containerID string, cmd []string, ...) ([]byte, error)
- func ExecReturnJSONList(ctx context.Context, cli *client.Client, containerID string, cmd []string, ...) ([]map[string]any, error)
- func ExecReturnObject[T any](ctx context.Context, cli *client.Client, containerID string, cmd []string, ...) (T, error)
- func ExecReturnReader(ctx context.Context, cli *client.Client, containerID string, cmd []string, ...) (int, io.Reader, error)
- func Pull(ctx context.Context, log *slog.Logger, imageName string, verbose bool) error
- func Run(ctx context.Context, log *slog.Logger, imageName string, verbose bool, ...) ([]byte, error)
- type ExecOption
- type ExecOptions
- type ProcessOption
- type ProcessOptionFunc
- type ProcessOptions
- type SubnetAllocator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecReturnJSONList ¶
func ExecReturnObject ¶
func ExecReturnReader ¶
func ExecReturnReader(ctx context.Context, cli *client.Client, containerID string, cmd []string, options ...ProcessOption) (int, io.Reader, error)
The following code is adapted from the Exec function in testcontainers-go: https://github.com/testcontainers/testcontainers-go/blob/main/docker.go
The MIT license applies **only to this function and the related types or logic directly derived from the above source**. All other code in this file/project is licensed under the Apache License 2.0.
The MIT License (MIT)
Copyright (c) 2017–2019 Gianluca Arbezzano ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Types ¶
type ExecOption ¶
type ExecOption func(*ExecOptions)
func NoPrintOnError ¶
func NoPrintOnError() ExecOption
type ExecOptions ¶
type ExecOptions struct {
PrintOnError bool
}
type ProcessOption ¶
type ProcessOption interface {
Apply(opts *ProcessOptions)
}
ProcessOption defines a common interface to modify the reader processor These options can be passed to the Exec function in a variadic way to customize the returned Reader instance
func Multiplexed ¶
func Multiplexed() ProcessOption
Multiplexed returns a ProcessOption that configures the command execution to combine stdout and stderr into a single stream without Docker's multiplexing headers.
func WithEnv ¶
func WithEnv(env []string) ProcessOption
func WithUser ¶
func WithUser(user string) ProcessOption
func WithWorkingDir ¶
func WithWorkingDir(workingDir string) ProcessOption
type ProcessOptionFunc ¶
type ProcessOptionFunc func(opts *ProcessOptions)
func (ProcessOptionFunc) Apply ¶
func (fn ProcessOptionFunc) Apply(opts *ProcessOptions)
type ProcessOptions ¶
type ProcessOptions struct {
ExecConfig container.ExecOptions
Reader io.Reader
}
ProcessOptions defines options applicable to the reader processor
func NewProcessOptions ¶
func NewProcessOptions(cmd []string) *ProcessOptions
NewProcessOptions returns a new ProcessOptions instance with the given command and default options: - detach: false - attach stdout: true - attach stderr: true
type SubnetAllocator ¶
type SubnetAllocator struct {
Base net.IP
BaseMask int
SubnetMask int
MaxSubnets int
// contains filtered or unexported fields
}
SubnetAllocator is a helper for allocating subnets from a base CIDR.
It can be used to allocate subnets for testing purposes, and is thread-safe using an in-memory lock, so it can be used in parallel. It also checks for overlaps with existing subnets in the docker network using a docker client, and will retry with a different salt if the subnet is already in use.
func NewDefaultSubnetAllocator ¶
func NewDefaultSubnetAllocator(docker *client.Client) *SubnetAllocator
func NewSubnetAllocator ¶
func NewSubnetAllocator(baseCIDR string, subnetMask int, docker *client.Client) *SubnetAllocator
func (*SubnetAllocator) FindAvailableSubnet ¶
func (*SubnetAllocator) GetSubnetCIDR ¶
func (a *SubnetAllocator) GetSubnetCIDR(testID string, salt int) (string, error)