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

Side by Side Diff: go/src/infra/tools/cipd/common/common.go

Issue 1145423002: cipd: Client can resolve tags to instance IDs. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: cipd-resolve-version Created 5 years, 7 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 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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698