container

package
v0.0.0-...-d8bc51a Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package container for dealing with containers via dagger

Package container for dealing with containers via dagger

Index

Constants

This section is empty.

Variables

View Source
var ErrParseAddress = errors.New("could not parse address string")

ErrParseAddress is raised when containers IP address could not be parsed

Functions

func GetArtifacts

func GetArtifacts(ctx context.Context, container *dagger.Container, artifacts *[]Artifacts) error

GetArtifacts extracts files from container to host Either both ContainerDir and HostDir must be directories, or both must be files

func OpenSSH

func OpenSSH(
	ctx context.Context,
	client *dagger.Client,
	container *dagger.Container,
	workdir string,
	opts *OptsOpenSSH,
) error

OpenSSH takes a container and starts SSH server with port exposed to the host

func Setup

func Setup(ctx context.Context, client *dagger.Client, opts *SetupOpts, dockerfileDirectoryPath string) (*dagger.Container, error)

Setup for setting up a Docker container via dagger

Types

type Artifacts

type Artifacts struct {
	ContainerPath string // Path inside container
	ContainerDir  bool   // Is ^^^ path directory?
	HostPath      string // Path inside host
	HostDir       bool   // Is ^^^ path directory?
}

Artifacts is passes to GetArtifacts as argument, and specifies extraction of files form container at containerDir to host at hostDir

type OptsOpenSSH

type OptsOpenSSH struct {
	WaitFunc  func()      // Waiting function holding container with SSH running
	Password  string      // Filled in by OpenSSH function
	IPv4      string      // Filled in by OpenSSH function
	Port      string      // Filled in by OpenSSH function
	MutexData *sync.Mutex // Mutex for modifying data in this struct

	// We could do with single channel here, but for clarity and less mental overhead there are 2
	TunnelClose chan (bool) // Channel to signal that SSH tunnel is ready
	TunnelReady chan (bool) // Channel to signal that SSH tunnel is not longer needed and can be closed
}

OptsOpenSSH stores options for SSH tunnel for OpenSSH function

func NewSettingsSSH

func NewSettingsSSH(opts ...SettingsSSH) *OptsOpenSSH

NewSettingsSSH returns a SettingsSSH

func (*OptsOpenSSH) Address

func (s *OptsOpenSSH) Address(address string) error

Address function parses provided string and populates IPv4 and Port (port defaults to 22 if not found)

func (OptsOpenSSH) Wait

func (s OptsOpenSSH) Wait()

Wait calls WaitFunc

type SettingsSSH

type SettingsSSH func(*OptsOpenSSH)

SettingsSSH is for functional option pattern

func WithWaitNone

func WithWaitNone() SettingsSSH

WithWaitNone is one possible function to pass into OpenSSH It will not wait

func WithWaitPressEnter

func WithWaitPressEnter() SettingsSSH

WithWaitPressEnter is one possible function to pass into OpenSSH It will wait until user presses ENTER key to shutdown the container

type SetupOpts

type SetupOpts struct {
	ContainerURL      string // URL or name of docker container
	MountHostDir      string // Directory from host to mount into container
	MountContainerDir string // Where to mount ^^^ host directory inside container
	WorkdirContainer  string // Workdir of the container, specified by GITHUB_WORKSPACE environment variable
}

SetupOpts congregates options for Setup function None of the values can be empty string, and mountContainerDir cannot be '.' or '/'

func (SetupOpts) Validate

func (opts SetupOpts) Validate() error

Validate the data in struct

Jump to

Keyboard shortcuts

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