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

Side by Side Diff: cipd/client/cipd/client.go

Issue 2951393002: [errors] de-specialize Transient in favor of Tags. (Closed)
Patch Set: more refactor Created 3 years, 5 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
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 // Package cipd implements client side of Chrome Infra Package Deployer. 5 // Package cipd implements client side of Chrome Infra Package Deployer.
6 // 6 //
7 // Binary package file format (in free form representation): 7 // Binary package file format (in free form representation):
8 // <binary package> := <zipped data> 8 // <binary package> := <zipped data>
9 // <zipped data> := DeterministicZip(<all input files> + <manifest json>) 9 // <zipped data> := DeterministicZip(<all input files> + <manifest json>)
10 // <manifest json> := File{ 10 // <manifest json> := File{
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 "sort" 45 "sort"
46 "sync" 46 "sync"
47 "time" 47 "time"
48 48
49 "golang.org/x/net/context" 49 "golang.org/x/net/context"
50 50
51 "github.com/luci/luci-go/common/clock" 51 "github.com/luci/luci-go/common/clock"
52 "github.com/luci/luci-go/common/data/stringset" 52 "github.com/luci/luci-go/common/data/stringset"
53 "github.com/luci/luci-go/common/errors" 53 "github.com/luci/luci-go/common/errors"
54 "github.com/luci/luci-go/common/logging" 54 "github.com/luci/luci-go/common/logging"
55 "github.com/luci/luci-go/common/retry/transient"
55 56
56 "github.com/luci/luci-go/cipd/client/cipd/common" 57 "github.com/luci/luci-go/cipd/client/cipd/common"
57 "github.com/luci/luci-go/cipd/client/cipd/internal" 58 "github.com/luci/luci-go/cipd/client/cipd/internal"
58 "github.com/luci/luci-go/cipd/client/cipd/local" 59 "github.com/luci/luci-go/cipd/client/cipd/local"
59 "github.com/luci/luci-go/cipd/version" 60 "github.com/luci/luci-go/cipd/version"
60 ) 61 )
61 62
62 // PackageACLChangeAction defines a flavor of PackageACLChange. 63 // PackageACLChangeAction defines a flavor of PackageACLChange.
63 type PackageACLChangeAction string 64 type PackageACLChangeAction string
64 65
(...skipping 12 matching lines...) Expand all
77 ) 78 )
78 79
79 // Environment variable definitions 80 // Environment variable definitions
80 const ( 81 const (
81 EnvCacheDir = "CIPD_CACHE_DIR" 82 EnvCacheDir = "CIPD_CACHE_DIR"
82 EnvHTTPUserAgentPrefix = "CIPD_HTTP_USER_AGENT_PREFIX" 83 EnvHTTPUserAgentPrefix = "CIPD_HTTP_USER_AGENT_PREFIX"
83 ) 84 )
84 85
85 var ( 86 var (
86 // ErrFinalizationTimeout is returned if CAS service can not finalize up load fast enough. 87 // ErrFinalizationTimeout is returned if CAS service can not finalize up load fast enough.
87 » ErrFinalizationTimeout = errors.WrapTransient(errors.New("timeout while waiting for CAS service to finalize the upload")) 88 » ErrFinalizationTimeout = errors.New("timeout while waiting for CAS servi ce to finalize the upload", transient.Tag)
88 // ErrBadUpload is returned when a package file is uploaded, but servers asks us to upload it again. 89 // ErrBadUpload is returned when a package file is uploaded, but servers asks us to upload it again.
89 » ErrBadUpload = errors.WrapTransient(errors.New("package file is uploaded , but servers asks us to upload it again")) 90 » ErrBadUpload = errors.New("package file is uploaded, but servers asks us to upload it again", transient.Tag)
90 // ErrBadUploadSession is returned by UploadToCAS if provided UploadSess ion is not valid. 91 // ErrBadUploadSession is returned by UploadToCAS if provided UploadSess ion is not valid.
91 ErrBadUploadSession = errors.New("uploadURL must be set if UploadSession ID is used") 92 ErrBadUploadSession = errors.New("uploadURL must be set if UploadSession ID is used")
92 // ErrUploadSessionDied is returned by UploadToCAS if upload session sud denly disappeared. 93 // ErrUploadSessionDied is returned by UploadToCAS if upload session sud denly disappeared.
93 » ErrUploadSessionDied = errors.WrapTransient(errors.New("upload session i s unexpectedly missing")) 94 » ErrUploadSessionDied = errors.New("upload session is unexpectedly missin g", transient.Tag)
94 // ErrNoUploadSessionID is returned by UploadToCAS if server didn't prov ide upload session ID. 95 // ErrNoUploadSessionID is returned by UploadToCAS if server didn't prov ide upload session ID.
95 ErrNoUploadSessionID = errors.New("server didn't provide upload session ID") 96 ErrNoUploadSessionID = errors.New("server didn't provide upload session ID")
96 // ErrSetRefTimeout is returned when service refuses to move a ref for a long time. 97 // ErrSetRefTimeout is returned when service refuses to move a ref for a long time.
97 » ErrSetRefTimeout = errors.WrapTransient(errors.New("timeout while moving a ref")) 98 » ErrSetRefTimeout = errors.New("timeout while moving a ref", transient.Ta g)
98 // ErrAttachTagsTimeout is returned when service refuses to accept tags for a long time. 99 // ErrAttachTagsTimeout is returned when service refuses to accept tags for a long time.
99 » ErrAttachTagsTimeout = errors.WrapTransient(errors.New("timeout while at taching tags")) 100 » ErrAttachTagsTimeout = errors.New("timeout while attaching tags", transi ent.Tag)
100 // ErrDownloadError is returned by FetchInstance on download errors. 101 // ErrDownloadError is returned by FetchInstance on download errors.
101 » ErrDownloadError = errors.WrapTransient(errors.New("failed to download t he package file after multiple attempts")) 102 » ErrDownloadError = errors.New("failed to download the package file after multiple attempts", transient.Tag)
102 // ErrUploadError is returned by RegisterInstance and UploadToCAS on upl oad errors. 103 // ErrUploadError is returned by RegisterInstance and UploadToCAS on upl oad errors.
103 » ErrUploadError = errors.WrapTransient(errors.New("failed to upload the p ackage file after multiple attempts")) 104 » ErrUploadError = errors.New("failed to upload the package file after mul tiple attempts", transient.Tag)
104 // ErrAccessDenined is returned by calls talking to backend on 401 or 40 3 HTTP errors. 105 // ErrAccessDenined is returned by calls talking to backend on 401 or 40 3 HTTP errors.
105 ErrAccessDenined = errors.New("access denied (not authenticated or not e nough permissions)") 106 ErrAccessDenined = errors.New("access denied (not authenticated or not e nough permissions)")
106 // ErrBackendInaccessible is returned by calls talking to backed if it d oesn't response. 107 // ErrBackendInaccessible is returned by calls talking to backed if it d oesn't response.
107 » ErrBackendInaccessible = errors.WrapTransient(errors.New("request to the backend failed after multiple attempts")) 108 » ErrBackendInaccessible = errors.New("request to the backend failed after multiple attempts", transient.Tag)
108 // ErrEnsurePackagesFailed is returned by EnsurePackages if something is not right. 109 // ErrEnsurePackagesFailed is returned by EnsurePackages if something is not right.
109 ErrEnsurePackagesFailed = errors.New("failed to update packages, see the log") 110 ErrEnsurePackagesFailed = errors.New("failed to update packages, see the log")
110 // ErrPackageNotFound is returned by DeletePackage if the package doesn' t exist. 111 // ErrPackageNotFound is returned by DeletePackage if the package doesn' t exist.
111 ErrPackageNotFound = errors.New("no such package") 112 ErrPackageNotFound = errors.New("no such package")
112 ) 113 )
113 114
114 var ( 115 var (
115 // UserAgent is HTTP user agent string for CIPD client. 116 // UserAgent is HTTP user agent string for CIPD client.
116 UserAgent = "cipd 1.7.0" 117 UserAgent = "cipd 1.7.0"
117 ) 118 )
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 aMap[subdir] = &a 1527 aMap[subdir] = &a
1527 } 1528 }
1528 return true 1529 return true
1529 }) 1530 })
1530 1531
1531 if len(aMap) == 0 { 1532 if len(aMap) == 0 {
1532 return nil 1533 return nil
1533 } 1534 }
1534 return 1535 return
1535 } 1536 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698