Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: milo/appengine/common/model/manifest_link.go

Issue 2949783002: [milo] appengine/* -> * (Closed)
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « milo/appengine/common/model/link.go ('k') | milo/appengine/common/model/patch_info.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package model
6
7 import (
8 "bytes"
9
10 ds "github.com/luci/gae/service/datastore"
11 "github.com/luci/luci-go/common/data/cmpbin"
12 )
13
14 // ManifestLink is an in-MILO link to a named source manifest.
15 type ManifestLink struct {
16 // The name of the manifest as the build annotated it.
17 Name string
18
19 // The manifest ID (sha256).
20 ID []byte
21 }
22
23 var _ ds.PropertyConverter = (*ManifestLink)(nil)
24
25 // FromProperty implements ds.PropertyConverter
26 func (m *ManifestLink) FromProperty(p ds.Property) (err error) {
27 val, err := p.Project(ds.PTBytes)
28 if err != nil {
29 return err
30 }
31 buf := bytes.NewReader(val.([]byte))
32 if m.Name, _, err = cmpbin.ReadString(buf); err != nil {
33 return
34 }
35 m.ID, _, err = cmpbin.ReadBytes(buf)
36 return
37 }
38
39 // ToProperty implements ds.PropertyConverter
40 func (m *ManifestLink) ToProperty() (ds.Property, error) {
41 buf := bytes.NewBuffer(nil)
42 cmpbin.WriteString(buf, m.Name)
43 cmpbin.WriteBytes(buf, m.ID)
44 return ds.MkProperty(buf.Bytes()), nil
45 }
OLDNEW
« no previous file with comments | « milo/appengine/common/model/link.go ('k') | milo/appengine/common/model/patch_info.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698