resources

package
v0.8.0-dev.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotAttachedToNetwork = errors.New("container is not attached to network")
View Source
var ErrResourceRemoved = errors.New("resource has been removed")

Functions

This section is empty.

Types

type CapabilitySpec

type CapabilitySpec struct {
	Add  []string `json:"add"`
	Drop []string `json:"drop"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiClient api.ClientWrapper, opts ...Opt) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) CreateContainer

func (c *Client) CreateContainer(
	ctx context.Context, name string, labels ResourceLabels, spec ContainerSpec,
) (*Container, error)

func (*Client) CreateNetwork

func (c *Client) CreateNetwork(
	ctx context.Context, labels ResourceLabels, name string, options network.CreateOptions,
) (*Network, error)

func (*Client) CreateVolume

func (c *Client) CreateVolume(ctx context.Context, labels ResourceLabels, name string) (*Volume, error)

func (*Client) GetOrCreateLoggingStack

func (c *Client) GetOrCreateLoggingStack(
	ctx context.Context, scrapeLabels map[string]*string, quiet bool,
) (*LoggingStack, error)

func (*Client) ImportContainer

func (c *Client) ImportContainer(ctx context.Context, id string) (*Container, error)

func (*Client) ImportNetwork

func (c *Client) ImportNetwork(ctx context.Context, id string) (*Network, error)

func (*Client) ImportVolume

func (c *Client) ImportVolume(ctx context.Context, name string) (*Volume, error)

type Container

type Container struct {
	// contains filtered or unexported fields
}

func (*Container) Client

func (c *Container) Client() api.ClientWrapper

func (*Container) Connect

func (c *Container) Connect(ctx context.Context, n *Network, config *network.EndpointSettings) error

func (*Container) Disconnect

func (c *Container) Disconnect(ctx context.Context, n *Network, force bool) error

func (*Container) Exec

func (c *Container) Exec(
	ctx context.Context,
	cmd []string, env map[string]string,
	workingDir *string, user *string,
) (*stream.MultiplexedStream, error)

func (*Container) GetEndpoint

func (c *Container) GetEndpoint(ctx context.Context, network *Network) (*network.EndpointSettings, error)

func (*Container) Id

func (c *Container) Id() string

func (*Container) IsRestartInProgress

func (c *Container) IsRestartInProgress() bool

func (*Container) IsRunning

func (c *Container) IsRunning(ctx context.Context) (bool, error)

func (*Container) Kill

func (c *Container) Kill(ctx context.Context, signal string) error

func (*Container) Logs

func (c *Container) Logs(ctx context.Context, follow bool) (*stream.MultiplexedStream, error)

func (*Container) Name

func (c *Container) Name() string

func (*Container) Remove

func (c *Container) Remove(ctx context.Context, options container.RemoveOptions) error

func (*Container) Restart

func (c *Container) Restart(ctx context.Context, options container.StopOptions) error

func (*Container) Start

func (c *Container) Start(ctx context.Context, options container.StartOptions) error

func (*Container) Stop

func (c *Container) Stop(ctx context.Context, options container.StopOptions) error

type ContainerSpec

type ContainerSpec struct {
	Labels        map[string]string                     `json:"labels,omitempty"`
	Image         string                                `json:"image,omitempty"`
	Command       []string                              `json:"command,omitempty"`
	Entrypoint    []string                              `json:"entrypoint,omitempty"`
	WorkingDir    string                                `json:"workingdir,omitempty"`
	AutoRemove    bool                                  `json:"autoremove,omitempty"`
	Env           map[string]string                     `json:"env,omitempty"`
	MappedPorts   []PortMapping                         `json:"mappedports,omitempty"`
	ExposedPorts  []nat.Port                            `json:"exposedports,omitempty"`
	Networks      map[*Network]network.EndpointSettings `json:"networks,omitempty"`
	Mounts        []mount.Mount                         `json:"mounts,omitempty"`
	Tty           bool                                  `json:"tty,omitempty"`
	Stdin         bool                                  `json:"stdin,omitempty"`
	Dns           DnsSpec                               `json:"dns,omitempty"`
	Capabilities  CapabilitySpec                        `json:"capabilities,omitempty"`
	ExtraHosts    []string                              `json:"extrahosts,omitempty"`
	HealthCheck   *container.HealthConfig               `json:"healthcheck,omitempty"`
	StopSignal    string                                `json:"stopsignal,omitempty"`
	RestartPolicy container.RestartPolicy               `json:"restartpolicy,omitempty"`
	UsernsMode    container.UsernsMode                  `json:"usernsmode,omitempty"`
	Privileged    bool                                  `json:"privileged,omitempty"`
	LogConfig     container.LogConfig                   `json:"logconfig,omitempty"`
	User          string                                `json:"user,omitempty"`
}

type DnsSpec

type DnsSpec struct {
	Servers []net.IP `json:"Servers"`
	Search  []string `json:"Search"`
	Options []string `json:"Options"`
}

type HostPortBinding

type HostPortBinding struct {
	HostIP   string  `json:"HostIp"`
	HostPort *uint16 `json:"HostPort"`
}

type ImageProvider

type ImageProvider interface {
	GetGrafanaImage() string
	GetLokiImage() string
	GetAlloyImage() string
	GetVolumeAccessImage() string
}

func DefaultImageProvider

func DefaultImageProvider() ImageProvider

type LoggingStack

type LoggingStack struct {
	// contains filtered or unexported fields
}

func (*LoggingStack) Remove

func (l *LoggingStack) Remove(ctx context.Context, options api.DownOptions) error

type MountPoint

type MountPoint struct {
	Destination string `json:"destination"`
	Mode        string `json:"mode"`
	RW          bool   `json:"rw"`
}

type Network

type Network struct {
	// contains filtered or unexported fields
}

func (*Network) Client

func (n *Network) Client() api.ClientWrapper

func (*Network) Connect

func (n *Network) Connect(ctx context.Context, container *Container, config *network.EndpointSettings) error

func (*Network) Disconnect

func (n *Network) Disconnect(ctx context.Context, container *Container, force bool) error

func (*Network) HostIP

func (n *Network) HostIP(ctx context.Context) (net.IP, error)

func (*Network) Id

func (n *Network) Id() string

func (*Network) Name

func (n *Network) Name() string

func (*Network) Remove

func (n *Network) Remove(ctx context.Context) error

type Opt

type Opt func(*Client) error

func WithImageProvider

func WithImageProvider(imageProvider ImageProvider) Opt

type PortMapping

type PortMapping struct {
	ContainerPort uint16   `json:"ContainerPort"`
	Protocol      Protocol `json:"Protocol"`
	HostBindings  []HostPortBinding
}

type Protocol

type Protocol string
const (
	ProtocolTCP Protocol = "tcp"
	ProtocolUDP Protocol = "udp"
)

type ResourceLabels

type ResourceLabels interface {
	ToMap() map[string]string
	ToFilter() filters.Args
	// FullName adds an eventual prefix and/or suffix to the name
	FullName(name string) string
	// TrimName returns the name without any prefix or suffix
	TrimName(name string) string
}

type Volume

type Volume struct {
	// contains filtered or unexported fields
}

func (*Volume) AddFS

func (v *Volume) AddFS(ctx context.Context, fs fs.FS, options container.CopyToContainerOptions) error

func (*Volume) AddFiles

func (v *Volume) AddFiles(
	ctx context.Context, files map[string]*fstest.MapFile, options container.CopyToContainerOptions,
) error

func (*Volume) Client

func (v *Volume) Client() api.ClientWrapper

func (*Volume) Name

func (v *Volume) Name() string

func (*Volume) ReadFile

func (v *Volume) ReadFile(ctx context.Context, path string) (io.ReadCloser, container.PathStat, error)

func (*Volume) Remove

func (v *Volume) Remove(ctx context.Context) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL