OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 Package common defines structures and functions used by all other cipd/ packages . | 6 Package common defines structures and functions used by all other cipd/ packages . |
7 */ | 7 */ |
8 package common | 8 package common |
9 | 9 |
10 import ( | 10 import ( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 return fmt.Errorf("The string %q doesn't look like a tag (a key: value pair)", t) | 71 return fmt.Errorf("The string %q doesn't look like a tag (a key: value pair)", t) |
72 } | 72 } |
73 if len(t) > 400 { | 73 if len(t) > 400 { |
74 return fmt.Errorf("The tag is too long: %q", t) | 74 return fmt.Errorf("The tag is too long: %q", t) |
75 } | 75 } |
76 if !instanceTagKeyRe.MatchString(chunks[0]) { | 76 if !instanceTagKeyRe.MatchString(chunks[0]) { |
77 return fmt.Errorf("Invalid tag key in %q. Should be a lowercase word.", t) | 77 return fmt.Errorf("Invalid tag key in %q. Should be a lowercase word.", t) |
78 } | 78 } |
79 return nil | 79 return nil |
80 } | 80 } |
81 | |
82 // ValidateInstanceVersion return error if a string doesn't look like | |
83 // an instance ID or an instance tag. | |
84 func ValidateInstanceVersion(v string) error { | |
85 if err := ValidateInstanceID(v); err == nil { | |
nodir
2015/05/21 17:07:48
if ValidateInstanceID(v) == nil && ValidateInstanc
Vadim Sh.
2015/05/21 18:00:37
:) Done.
| |
86 return nil | |
87 } | |
88 if err := ValidateInstanceTag(v); err == nil { | |
89 return nil | |
90 } | |
91 return fmt.Errorf("Bad version (not an instance ID or a tag): %s", v) | |
92 } | |
OLD | NEW |