composer

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RecreateNever specifies never recreating existing service containers
	RecreateNever = "never"
	// RecreateForce specifies always force-recreating service containers
	RecreateForce = "force"
	// RecreateDiverged specifies only recreating service containers which diverges from compose model.
	// (Unimplemented, currently equal to `RecreateNever`) In docker-compose,
	// service config is hashed and stored in a label.
	// FYI: https://github.com/docker/compose/blob/v2.14.1/pkg/compose/convergence.go#L244
	RecreateDiverged = "diverged"
)

FYI: https://github.com/docker/compose/blob/v2.14.1/pkg/api/api.go#L423

Variables

This section is empty.

Functions

Types

type BuildOptions

type BuildOptions struct {
	Args     []string // --build-arg strings
	NoCache  bool
	Progress string
}

type Composer

type Composer struct {
	Options
	// contains filtered or unexported fields
}

func New

func New(o Options, client *containerd.Client) (*Composer, error)

func (*Composer) Build

func (c *Composer) Build(ctx context.Context, bo BuildOptions, services []string) error

func (*Composer) Config added in v0.15.0

func (c *Composer) Config(ctx context.Context, w io.Writer, co ConfigOptions) error

func (*Composer) Containers added in v0.15.0

func (c *Composer) Containers(ctx context.Context, services ...string) ([]containerd.Container, error)

func (*Composer) Copy added in v1.6.0

func (c *Composer) Copy(ctx context.Context, co CopyOptions) error

func (*Composer) Create added in v1.2.0

func (c *Composer) Create(ctx context.Context, opt CreateOptions, services []string) error

Create creates containers for given services.

func (*Composer) Down

func (c *Composer) Down(ctx context.Context, downOptions DownOptions) error

func (*Composer) Exec added in v1.1.0

func (c *Composer) Exec(ctx context.Context, eo ExecOptions) error

Exec executes a given command on a running container specified by `ServiceName` (and `Index` if it has multiple instances).

func (*Composer) Kill added in v0.16.0

func (c *Composer) Kill(ctx context.Context, opts KillOptions, services []string) error

func (*Composer) Logs

func (c *Composer) Logs(ctx context.Context, lo LogsOptions, services []string) error

func (*Composer) Pause added in v1.2.1

func (c *Composer) Pause(ctx context.Context, services []string, writer io.Writer) error

Pause pauses service containers belonging to `services`.

func (*Composer) Port added in v1.1.0

func (c *Composer) Port(ctx context.Context, writer io.Writer, po PortOptions) error

Port gets the corresponding public port of a given private port/protocol on a service container.

func (*Composer) Pull added in v0.14.0

func (c *Composer) Pull(ctx context.Context, po PullOptions, services []string) error

func (*Composer) Push added in v0.14.0

func (c *Composer) Push(ctx context.Context, po PushOptions, services []string) error

func (*Composer) Remove added in v1.1.0

func (c *Composer) Remove(ctx context.Context, opt RemoveOptions, services []string) error

Remove removes stopped containers in `services`.

func (*Composer) Restart added in v1.1.0

func (c *Composer) Restart(ctx context.Context, opt RestartOptions, services []string) error

Restart restarts running/stopped containers in `services`. It calls `nerdctl restart CONTAINER_ID` to do the actual job.

func (*Composer) Run added in v0.23.0

func (c *Composer) Run(ctx context.Context, ro RunOptions) error

func (*Composer) ServiceNames added in v0.15.0

func (c *Composer) ServiceNames(svcs ...string) ([]string, error)

ServiceNames returns service names in dependency order.

func (*Composer) Services added in v0.13.0

func (c *Composer) Services(ctx context.Context, svcs ...string) ([]*serviceparser.Service, error)

Services returns the parsed Service objects in dependency order.

func (*Composer) Stop added in v1.1.0

func (c *Composer) Stop(ctx context.Context, opt StopOptions, services []string) error

Stop stops containers in `services` without removing them. It calls `nerdctl stop CONTAINER_ID` to do the actual job.

func (*Composer) Unpause added in v1.2.1

func (c *Composer) Unpause(ctx context.Context, services []string, writer io.Writer) error

Unpause unpauses service containers belonging to `services`.

func (*Composer) Up

func (c *Composer) Up(ctx context.Context, uo UpOptions, services []string) error

type ConfigOptions added in v0.16.0

type ConfigOptions struct {
	Services bool
	Volumes  bool
	Hash     string
}

type CopyOptions added in v1.6.0

type CopyOptions struct {
	Source      string
	Destination string
	Index       int
	FollowLink  bool
	DryRun      bool
}

type CreateOptions added in v1.2.0

type CreateOptions struct {
	Build         bool
	NoBuild       bool
	ForceRecreate bool
	NoRecreate    bool
	Pull          *string
}

CreateOptions stores all option input from `nerdctl compose create`

type DownOptions

type DownOptions struct {
	RemoveVolumes bool
	RemoveOrphans bool
}

type ExecOptions added in v1.1.0

type ExecOptions struct {
	ServiceName string
	Index       int
	// params to be passed to `nerdctl exec`
	Detach      bool
	Interactive bool
	Tty         bool
	Privileged  bool
	User        string
	WorkDir     string
	Env         []string
	Args        []string
}

ExecOptions stores options passed from users as flags and args.

type KillOptions added in v0.16.0

type KillOptions struct {
	Signal string
}

type LogsOptions

type LogsOptions struct {
	Follow      bool
	Timestamps  bool
	Tail        string
	NoColor     bool
	NoLogPrefix bool
}

type Options

type Options struct {
	Project          string // empty for default
	ProjectDirectory string
	ConfigPaths      []string
	Profiles         []string
	Services         []string
	EnvFile          string
	NerdctlCmd       string
	NerdctlArgs      []string
	NetworkInUse     func(ctx context.Context, netName string) (bool, error)
	NetworkExists    func(string) (bool, error)
	VolumeExists     func(string) (bool, error)
	ImageExists      func(ctx context.Context, imageName string) (bool, error)
	EnsureImage      func(ctx context.Context, imageName, pullMode, platform string, ps *serviceparser.Service, quiet bool) error
	DebugPrintFull   bool // full debug print, may leak secret env var to logs
	Experimental     bool // enable experimental features
	IPFSAddress      string
}

Options groups the command line options recommended for a Compose implementation (ProjectOptions) and extra options for nerdctl

type PortOptions added in v1.1.0

type PortOptions struct {
	ServiceName string
	Index       int
	Port        int
	Protocol    string
}

PortOptions has args for getting the public port of a given private port/protocol in a service container.

type PullOptions added in v0.14.0

type PullOptions struct {
	Quiet bool
}

type PushOptions added in v0.14.0

type PushOptions struct {
}

type RemoveOptions added in v1.1.0

type RemoveOptions struct {
	Stop    bool
	Volumes bool
}

RemoveOptions stores all options when removing compose containers: Stop: if true, remove using `rm -f`; if false, check and skip running containers. Volumes: if remove anonymous volumes associated with the container.

type RestartOptions added in v1.1.0

type RestartOptions struct {
	Timeout *uint
}

RestartOptions stores all option input from `nerdctl compose restart`

type RunOptions added in v0.23.0

type RunOptions struct {
	ServiceName string
	Args        []string

	NoBuild       bool
	NoColor       bool
	NoLogPrefix   bool
	ForceBuild    bool
	QuietPull     bool
	RemoveOrphans bool

	Name         string
	Detach       bool
	NoDeps       bool
	Tty          bool
	Interactive  bool
	Rm           bool
	User         string
	Volume       []string
	Entrypoint   []string
	Env          []string
	Label        []string
	WorkDir      string
	ServicePorts bool
	Publish      []string
}

type StopOptions added in v1.1.0

type StopOptions struct {
	Timeout *uint
}

StopOptions stores all option input from `nerdctl compose stop`

type UpOptions

type UpOptions struct {
	Detach        bool
	NoBuild       bool
	NoColor       bool
	NoLogPrefix   bool
	ForceBuild    bool
	IPFS          bool
	QuietPull     bool
	RemoveOrphans bool
	Scale         map[string]uint64 // map of service name to replicas
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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