Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(460)

Delta Between Two Patch Sets: names/tag.go

Issue 12551043: state: implement the single FindEntity method
Left Patch Set: state: implement the single FindEntity method Created 10 years, 7 months ago
Right Patch Set: state: implement the single FindEntity method Created 10 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « cmd/jujud/agent_test.go ('k') | names/tag_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2013 Canonical Ltd. 1 // Copyright 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package names 4 package names
5 5
6 import ( 6 import (
7 "fmt" 7 "fmt"
8 "strings" 8 "strings"
9 ) 9 )
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if err != nil { 68 if err != nil {
69 return "", "", invalidTagError(tag, expectKind) 69 return "", "", invalidTagError(tag, expectKind)
70 } 70 }
71 if expectKind != "" && kind != expectKind { 71 if expectKind != "" && kind != expectKind {
72 return "", "", invalidTagError(tag, expectKind) 72 return "", "", invalidTagError(tag, expectKind)
73 } 73 }
74 if toId := tagSuffixToId[kind]; toId != nil { 74 if toId := tagSuffixToId[kind]; toId != nil {
75 id = toId(id) 75 id = toId(id)
76 } 76 }
77 if verify := verifyId[kind]; verify != nil && !verify(id) { 77 if verify := verifyId[kind]; verify != nil && !verify(id) {
78 » » return "", "", invalidTagError(tag, expectKind) 78 » » return "", "", invalidTagError(tag, kind)
79 } 79 }
80 return kind, id, nil 80 return kind, id, nil
81 } 81 }
82 82
83 func invalidTagError(tag, kind string) error { 83 func invalidTagError(tag, kind string) error {
84 if kind != "" { 84 if kind != "" {
85 return fmt.Errorf("%q is not a valid %s tag", tag, kind) 85 return fmt.Errorf("%q is not a valid %s tag", tag, kind)
86 } 86 }
87 return fmt.Errorf("%q is not a valid tag", tag) 87 return fmt.Errorf("%q is not a valid tag", tag)
88 } 88 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b