Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(17)

Side by Side Diff: environs/tools/simplestreams.go

Issue 70770043: all: use errgo instead of fmt.Errorf
Patch Set: all: use errgo instead of fmt.Errorf Created 11 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « environs/tools/build.go ('k') | environs/tools/storage.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 Canonical Ltd. 1 // Copyright 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 // The tools package supports locating, parsing, and filtering Ubuntu tools meta data in simplestreams format. 4 // The tools package supports locating, parsing, and filtering Ubuntu tools meta data in simplestreams format.
5 // See http://launchpad.net/simplestreams and in particular the doc/README file in that project for more information 5 // See http://launchpad.net/simplestreams and in particular the doc/README file in that project for more information
6 // about the file formats. 6 // about the file formats.
7 package tools 7 package tools
8 8
9 import ( 9 import (
10 "bytes" 10 "bytes"
11 "crypto/sha256" 11 "crypto/sha256"
12 "fmt" 12 "fmt"
13 "hash" 13 "hash"
14 "io" 14 "io"
15 "path" 15 "path"
16 "strings" 16 "strings"
17 "time" 17 "time"
18 18
19 errgo "github.com/juju/errgo/errors"
20
19 "launchpad.net/juju-core/environs/simplestreams" 21 "launchpad.net/juju-core/environs/simplestreams"
20 "launchpad.net/juju-core/environs/storage" 22 "launchpad.net/juju-core/environs/storage"
21 "launchpad.net/juju-core/errors" 23 "launchpad.net/juju-core/errors"
22 coretools "launchpad.net/juju-core/tools" 24 coretools "launchpad.net/juju-core/tools"
23 "launchpad.net/juju-core/utils/set" 25 "launchpad.net/juju-core/utils/set"
24 "launchpad.net/juju-core/version" 26 "launchpad.net/juju-core/version"
25 ) 27 )
26 28
27 func init() { 29 func init() {
28 simplestreams.RegisterStructTags(ToolsMetadata{}) 30 simplestreams.RegisterStructTags(ToolsMetadata{})
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 for _, tm := range tmlist1 { 285 for _, tm := range tmlist1 {
284 merged[tm.binary()] = tm 286 merged[tm.binary()] = tm
285 } 287 }
286 for _, tm := range tmlist2 { 288 for _, tm := range tmlist2 {
287 binary := tm.binary() 289 binary := tm.binary()
288 if existing, ok := merged[binary]; ok { 290 if existing, ok := merged[binary]; ok {
289 if tm.Size != 0 { 291 if tm.Size != 0 {
290 if existing.Size == 0 { 292 if existing.Size == 0 {
291 merged[binary] = tm 293 merged[binary] = tm
292 } else if existing.Size != tm.Size || existing.S HA256 != tm.SHA256 { 294 } else if existing.Size != tm.Size || existing.S HA256 != tm.SHA256 {
293 » » » » » return nil, fmt.Errorf( 295 » » » » » return nil, errgo.Newf(
294 "metadata mismatch for %s: sizes =(%v,%v) sha256=(%v,%v)", 296 "metadata mismatch for %s: sizes =(%v,%v) sha256=(%v,%v)",
295 binary.String(), 297 binary.String(),
296 existing.Size, tm.Size, 298 existing.Size, tm.Size,
297 existing.SHA256, tm.SHA256, 299 existing.SHA256, tm.SHA256,
298 ) 300 )
299 } 301 }
300 } 302 }
301 } else { 303 } else {
302 merged[binary] = tm 304 merged[binary] = tm
303 } 305 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 func fetchToolsHash(stor storage.StorageReader, ver version.Binary) (size int64, sha256hash hash.Hash, err error) { 392 func fetchToolsHash(stor storage.StorageReader, ver version.Binary) (size int64, sha256hash hash.Hash, err error) {
391 r, err := storage.Get(stor, StorageName(ver)) 393 r, err := storage.Get(stor, StorageName(ver))
392 if err != nil { 394 if err != nil {
393 return 0, nil, err 395 return 0, nil, err
394 } 396 }
395 defer r.Close() 397 defer r.Close()
396 sha256hash = sha256.New() 398 sha256hash = sha256.New()
397 size, err = io.Copy(sha256hash, r) 399 size, err = io.Copy(sha256hash, r)
398 return size, sha256hash, err 400 return size, sha256hash, err
399 } 401 }
OLDNEW
« no previous file with comments | « environs/tools/build.go ('k') | environs/tools/storage.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b