Documentation
¶
Index ¶
- func Connect(dockerEndpoint string, cfg *Config) (*Builder, *ContainerBackend, error)
- type Builder
- func (b *Builder) BuildClientImage(ctx context.Context, client libhive.ClientDesignator) (string, error)
- func (b *Builder) BuildImage(ctx context.Context, name string, fsys fs.FS) error
- func (b *Builder) BuildSimulatorImage(ctx context.Context, name string, buildArgs map[string]string) (string, error)
- func (b *Builder) ReadFile(ctx context.Context, image, path string) ([]byte, error)
- type Config
- type ContainerBackend
- func (cb *ContainerBackend) Build(ctx context.Context, b libhive.Builder) error
- func (b *ContainerBackend) ConnectContainer(containerID, networkID string) error
- func (b *ContainerBackend) ContainerIP(containerID, networkID string) (net.IP, error)
- func (b *ContainerBackend) CreateContainer(ctx context.Context, imageName string, opt libhive.ContainerOptions) (string, error)
- func (b *ContainerBackend) CreateNetwork(name string) (string, error)
- func (b *ContainerBackend) DeleteContainer(containerID string) error
- func (b *ContainerBackend) DisconnectContainer(containerID, networkID string) error
- func (b *ContainerBackend) GetDockerClient() interface{}
- func (b *ContainerBackend) NetworkNameToID(name string) (string, error)
- func (b *ContainerBackend) PauseContainer(containerID string) error
- func (b *ContainerBackend) RemoveNetwork(id string) error
- func (b *ContainerBackend) RunProgram(ctx context.Context, containerID string, cmd []string) (*libhive.ExecInfo, error)
- func (cb *ContainerBackend) ServeAPI(ctx context.Context, h http.Handler) (libhive.APIServer, error)
- func (b *ContainerBackend) SetHiveInstanceInfo(instanceID, version string)
- func (b *ContainerBackend) StartContainer(ctx context.Context, containerID string, opt libhive.ContainerOptions) (*libhive.ContainerInfo, error)
- func (b *ContainerBackend) UnpauseContainer(containerID string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder takes care of building docker images.
func NewBuilder ¶
func (*Builder) BuildClientImage ¶
func (b *Builder) BuildClientImage(ctx context.Context, client libhive.ClientDesignator) (string, error)
BuildClientImage builds a docker image of the given client.
func (*Builder) BuildImage ¶
BuildImage creates a container by archiving the given file system, which must contain a file called "Dockerfile".
type Config ¶
type Config struct { Inventory libhive.Inventory Logger *slog.Logger // When building containers, any client or simulator image build matching the pattern // will avoid the docker cache. NoCachePattern *regexp.Regexp // This forces pulling of base images when building clients and simulators. PullEnabled bool // These two are log destinations for output from docker. ContainerOutput io.Writer BuildOutput io.Writer // This tells the docker client whether to authenticate requests UseAuthentication bool }
Config is the configuration of the docker backend.
type ContainerBackend ¶
type ContainerBackend struct {
// contains filtered or unexported fields
}
func NewContainerBackend ¶
func NewContainerBackend(c *docker.Client, cfg *Config) *ContainerBackend
func (*ContainerBackend) ConnectContainer ¶
func (b *ContainerBackend) ConnectContainer(containerID, networkID string) error
ConnectContainer connects the given container to a network.
func (*ContainerBackend) ContainerIP ¶
func (b *ContainerBackend) ContainerIP(containerID, networkID string) (net.IP, error)
ContainerIP finds the IP of a container in the given network.
func (*ContainerBackend) CreateContainer ¶
func (b *ContainerBackend) CreateContainer(ctx context.Context, imageName string, opt libhive.ContainerOptions) (string, error)
CreateContainer creates a docker container.
func (*ContainerBackend) CreateNetwork ¶
func (b *ContainerBackend) CreateNetwork(name string) (string, error)
CreateNetwork creates a docker network.
func (*ContainerBackend) DeleteContainer ¶
func (b *ContainerBackend) DeleteContainer(containerID string) error
DeleteContainer removes the given container. If the container is running, it is stopped.
func (*ContainerBackend) DisconnectContainer ¶
func (b *ContainerBackend) DisconnectContainer(containerID, networkID string) error
DisconnectContainer disconnects the given container from a network.
func (*ContainerBackend) GetDockerClient ¶
func (b *ContainerBackend) GetDockerClient() interface{}
GetDockerClient returns the underlying Docker client for cleanup operations.
func (*ContainerBackend) NetworkNameToID ¶
func (b *ContainerBackend) NetworkNameToID(name string) (string, error)
NetworkNameToID finds the network ID of network by the given name.
func (*ContainerBackend) PauseContainer ¶
func (b *ContainerBackend) PauseContainer(containerID string) error
PauseContainer pauses the given container.
func (*ContainerBackend) RemoveNetwork ¶
func (b *ContainerBackend) RemoveNetwork(id string) error
RemoveNetwork deletes a docker network.
func (*ContainerBackend) RunProgram ¶
func (b *ContainerBackend) RunProgram(ctx context.Context, containerID string, cmd []string) (*libhive.ExecInfo, error)
RunProgram runs a /hive-bin script in a container.
func (*ContainerBackend) ServeAPI ¶
func (cb *ContainerBackend) ServeAPI(ctx context.Context, h http.Handler) (libhive.APIServer, error)
ServeAPI starts the API server.
func (*ContainerBackend) SetHiveInstanceInfo ¶
func (b *ContainerBackend) SetHiveInstanceInfo(instanceID, version string)
SetHiveInstanceInfo sets the hive instance information for container labeling.
func (*ContainerBackend) StartContainer ¶
func (b *ContainerBackend) StartContainer(ctx context.Context, containerID string, opt libhive.ContainerOptions) (*libhive.ContainerInfo, error)
StartContainer starts a docker container.
func (*ContainerBackend) UnpauseContainer ¶
func (b *ContainerBackend) UnpauseContainer(containerID string) error
UnpauseContainer unpauses the given container.