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

Unified Diff: cipd/client/cipd/common/common.go

Issue 2663483002: [cipd] Add AssertOnlyDefaultSubdir. (Closed)
Patch Set: Common error Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cipd/client/cmd/cipd/main.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cipd/client/cipd/common/common.go
diff --git a/cipd/client/cipd/common/common.go b/cipd/client/cipd/common/common.go
index 547a91f12a7f931e56a4c78b61d976a65ef1c3e0..af47970e525b360de2636343b0c745a8326ee8b6 100644
--- a/cipd/client/cipd/common/common.go
+++ b/cipd/client/cipd/common/common.go
@@ -6,6 +6,7 @@
package common
import (
+ "errors"
"fmt"
"path"
"regexp"
@@ -249,6 +250,21 @@ func (p PinSliceBySubdir) Validate() error {
return nil
}
+// ErrSubdirsNotYetSupported is a transitionary error which indicates that the
+// invoked method does not yet work with sudbir values other than "".
+var ErrSubdirsNotYetSupported = errors.New(`subdirs other than "" not currently supported`)
+
+// AssertOnlyDefaultSubdir is a transitionary method which returns an error if
+// p contains subdirs other than "".
+func (p PinSliceBySubdir) AssertOnlyDefaultSubdir() error {
+ if _, ok := p[""]; ok && len(p) > 1 {
+ return ErrSubdirsNotYetSupported
+ } else if !ok && len(p) > 0 {
+ return ErrSubdirsNotYetSupported
+ }
+ return nil
+}
+
// ToMap converts this to a PinMapBySubdir
func (p PinSliceBySubdir) ToMap() PinMapBySubdir {
ret := make(PinMapBySubdir, len(p))
« no previous file with comments | « no previous file | cipd/client/cmd/cipd/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698