snapshot

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TitleLabel is the label added to Docker images to track the title of
	// snapshots.
	TitleLabel = "dksnap.title"

	// CreatedLabel is the label added to Docker images to track the creation
	// time of snapshots.
	CreatedLabel = "dksnap.created"

	// DumpPathLabel is the label added to Docker images to track the path
	// within the container of a dump representing the state of the database.
	DumpPathLabel = "dksnap.dump-path"

	// BaseEntrypointLabel is the label added to Docker images to track the
	// original entrypoint of a Docker image. dksnap overwrites the entrypoint
	// to injects its boot logic, so we must keep track of the original
	// entrypoint separately in order for snapshots of snapshots to work.
	BaseEntrypointLabel = "dksnap.base-entrypoint"
)

Variables

This section is empty.

Functions

func Diff

func Diff(ctx context.Context, dockerClient *client.Client, x, y *Snapshot) (string, error)

Diff returns the diff between the dumps of the given snapshots.

Types

type Generic

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

Generic creates snapshots by saving the container's filesystem with `docker commit`, and creating a tarball for each attached volume. The new container's entrypoint is then modified to load the volumes at boot.

func (*Generic) Create

func (c *Generic) Create(ctx context.Context, container types.ContainerJSON, title, imageName string) error

Create creates a new snapshot.

type Mongo

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

Mongo creates snapshots for Mongo containers. It dumps the database using `mongodump`.

func (*Mongo) Create

func (c *Mongo) Create(ctx context.Context, container types.ContainerJSON, title, imageName string) error

Create creates a new snapshot.

type MySQL

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

MySQL creates snapshots for MySQL containers. It dumps the database using `mysqldump`.

func (*MySQL) Create

func (c *MySQL) Create(ctx context.Context, container types.ContainerJSON, title, imageName string) error

Create creates a new snapshot.

type Postgres

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

Postgres creates snapshots for Postgres containers. It dumps the database using pg_dumpall.

func (*Postgres) Create

func (c *Postgres) Create(ctx context.Context, container types.ContainerJSON, title, imageName string) error

Create creates a new snapshot.

type Snapshot

type Snapshot struct {
	// BaseImage represents whether the image is a regular Docker image, and
	// not created by `dksnap`. Title, DumpPath, and Created are not defined
	// BaseImage is true.
	BaseImage bool

	Title      string
	DumpPath   string
	ImageNames []string
	Created    time.Time
	ImageID    string

	Parent   *Snapshot
	Children []*Snapshot
}

Snapshot represents a snapshot of a container. It can be booted by running referenced image.

func List

func List(ctx context.Context, dockerClient *client.Client) ([]*Snapshot, error)

List returns all the snapshots on the local machine.

type Snapshotter

type Snapshotter interface {
	Create(ctx context.Context, container types.ContainerJSON, title, imageName string) error
}

Snapshotter defines the interface for creating snapshots. Implementations may make assumptions about the type of container that is being snapshotted. For example, the Postgres snapshotter shells out to `pg_dumpall`.

func NewGeneric

func NewGeneric(c *client.Client) Snapshotter

NewGeneric creates a new generic snapshotter.

func NewMongo

func NewMongo(c *client.Client) Snapshotter

NewMongo creates a new mongo snapshotter.

func NewMySQL

func NewMySQL(c *client.Client) Snapshotter

NewMySQL creates a new mongo snapshotter.

func NewPostgres

func NewPostgres(c *client.Client, dbUser string) Snapshotter

NewPostgres creates a new Postgres snapshotter.

Jump to

Keyboard shortcuts

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