Add support for content labels on commit

Add commit options which allow for setting labels on commit.
Prevents potential race between garbage collector reading labels
after commit and labels getting set.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2017-08-09 22:34:05 -07:00
parent c4387a159e
commit dee8dc2cda
11 changed files with 336 additions and 76 deletions

View File

@@ -90,7 +90,7 @@ type Writer interface {
// Commit commits the blob (but no roll-back is guaranteed on an error).
// size and expected can be zero-value when unknown.
Commit(size int64, expected digest.Digest) error
Commit(size int64, expected digest.Digest, opts ...Opt) error
// Status returns the current state of write
Status() (Status, error)
@@ -107,3 +107,13 @@ type Store interface {
IngestManager
Ingester
}
// Opt is used to alter the mutable properties of content
type Opt func(*Info) error
func WithLabels(labels map[string]string) Opt {
return func(info *Info) error {
info.Labels = labels
return nil
}
}