forked from kelda/dksnap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
53 lines (43 loc) · 1.63 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package snapshot
import (
"context"
"time"
"github.com/docker/docker/api/types"
)
// 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`.
type Snapshotter interface {
Create(ctx context.Context, container types.ContainerJSON, title, imageName string) error
}
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"
)
// Snapshot represents a snapshot of a container. It can be booted by running
// referenced image.
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
}