| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |