Add labels and fileters to content

Update list content command to support filters
Add label subcommand to content in dist tool to update labels
Add uncompressed label on unpack

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2017-07-05 17:00:11 -07:00
parent 1a49f5ea79
commit fba7463ed3
14 changed files with 973 additions and 160 deletions

View File

@@ -32,6 +32,8 @@ type Info struct {
Digest digest.Digest
Size int64
CommittedAt time.Time
UpdatedAt time.Time
Labels map[string]string
}
type Status struct {
@@ -53,8 +55,17 @@ type Manager interface {
// If the content is not present, ErrNotFound will be returned.
Info(ctx context.Context, dgst digest.Digest) (Info, error)
// Walk will call fn for each item in the content store.
Walk(ctx context.Context, fn WalkFunc) error
// Update updates mutable information related to content.
// If one or more fieldpaths are provided, only those
// fields will be updated.
// Mutable fields:
// labels.*
Update(ctx context.Context, info Info, fieldpaths ...string) error
// Walk will call fn for each item in the content store which
// match the provided filters. If no filters are given all
// items will be walked.
Walk(ctx context.Context, fn WalkFunc, filters ...string) error
// Delete removes the content from the store.
Delete(ctx context.Context, dgst digest.Digest) error

View File

@@ -55,6 +55,7 @@ func (s *store) info(dgst digest.Digest, fi os.FileInfo) Info {
Digest: dgst,
Size: fi.Size(),
CommittedAt: fi.ModTime(),
UpdatedAt: fi.ModTime(),
}
}
@@ -92,9 +93,13 @@ func (cs *store) Delete(ctx context.Context, dgst digest.Digest) error {
return nil
}
// TODO(stevvooe): Allow querying the set of blobs in the blob store.
func (cs *store) Update(ctx context.Context, info Info, fieldpaths ...string) error {
// TODO: Support persisting and updating mutable content data
return errors.Wrapf(errdefs.ErrFailedPrecondition, "update not supported on immutable content store")
}
func (cs *store) Walk(ctx context.Context, fn WalkFunc) error {
func (cs *store) Walk(ctx context.Context, fn WalkFunc, filters ...string) error {
// TODO: Support filters
root := filepath.Join(cs.root, "blobs")
var alg digest.Algorithm
return filepath.Walk(root, func(path string, fi os.FileInfo, err error) error {