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

@@ -420,7 +420,11 @@ func (s *Service) Write(session api.Content_WriteServer) (err error) {
}
if req.Action == api.WriteActionCommit {
if err := wr.Commit(total, expected); err != nil {
var opts []content.Opt
if req.Labels != nil {
opts = append(opts, content.WithLabels(req.Labels))
}
if err := wr.Commit(total, expected, opts...); err != nil {
return err
}
}