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

Side by Side Diff: common/config/impl/filesystem/paths.go

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: fix nits 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
« no previous file with comments | « common/config/impl/filesystem/fs.go ('k') | common/config/validation/validation.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 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 filesystem 5 package filesystem
6 6
7 import ( 7 import (
8 "io/ioutil" 8 "io/ioutil"
9 "os" 9 "os"
10 "path" 10 "path"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 func (c configSet) hasPrefix(prefix luciPath) bool { 50 func (c configSet) hasPrefix(prefix luciPath) bool {
51 return strings.HasPrefix(c.s(), prefix.s()) 51 return strings.HasPrefix(c.s(), prefix.s())
52 } 52 }
53 53
54 func (c configSet) id() string { 54 func (c configSet) id() string {
55 return strings.Split(c.s(), "/")[1] 55 return strings.Split(c.s(), "/")[1]
56 } 56 }
57 57
58 func (c configSet) validate() error { 58 func (c configSet) validate() error {
59 if !c.hasPrefix("projects/") && !c.hasPrefix("services/") { 59 if !c.hasPrefix("projects/") && !c.hasPrefix("services/") {
60 » » return errors.Reason("configSet.validate: bad prefix %(cs)q").D( "cs", c.s()).Err() 60 » » return errors.Reason("configSet.validate: bad prefix %q", c.s()) .Err()
61 } 61 }
62 return nil 62 return nil
63 } 63 }
64 64
65 type nativePath string 65 type nativePath string
66 66
67 func (n nativePath) explode() []string { 67 func (n nativePath) explode() []string {
68 return strings.Split(n.s(), string(filepath.Separator)) 68 return strings.Split(n.s(), string(filepath.Separator))
69 } 69 }
70 70
(...skipping 14 matching lines...) Expand all
85 return ioutil.ReadFile(n.s()) 85 return ioutil.ReadFile(n.s())
86 } 86 }
87 87
88 func (n nativePath) toLUCI() luciPath { 88 func (n nativePath) toLUCI() luciPath {
89 return luciPath(filepath.ToSlash(n.s())) 89 return luciPath(filepath.ToSlash(n.s()))
90 } 90 }
91 91
92 func (n nativePath) s() string { 92 func (n nativePath) s() string {
93 return string(n) 93 return string(n)
94 } 94 }
OLDNEW
« no previous file with comments | « common/config/impl/filesystem/fs.go ('k') | common/config/validation/validation.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698