Skip to content

Commit

Permalink
Merge pull request #168 from Desiki-high/feat-labels
Browse files Browse the repository at this point in the history
feat: add localWriter
  • Loading branch information
imeoer authored Aug 7, 2023
2 parents 7bece14 + 9a17d23 commit 6493dc1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/content/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ func (content *Content) Info(ctx context.Context, dgst digest.Digest) (content.I
}

func (content *Content) Update(ctx context.Context, info content.Info, fieldpaths ...string) (content.Info, error) {
if info.Labels != nil {
info.Labels = nil
}
return content.store.Update(ctx, info, fieldpaths...)
}

Expand Down Expand Up @@ -158,5 +161,16 @@ func (content *Content) Abort(ctx context.Context, ref string) error {
}

func (content *Content) Writer(ctx context.Context, opts ...content.WriterOpt) (content.Writer, error) {
return content.store.Writer(ctx, opts...)
writer, err := content.store.Writer(ctx, opts...)
return &localWriter{writer}, err
}

// localWriter wrap the content.Writer
type localWriter struct {
content.Writer
}

func (localWriter localWriter) Commit(ctx context.Context, size int64, expected digest.Digest, opts ...content.Opt) error {
// we don't write any lables, drop the opts
return localWriter.Writer.Commit(ctx, size, expected)
}

0 comments on commit 6493dc1

Please sign in to comment.