LEFT | RIGHT |
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 "regexp" | 8 "regexp" |
9 "strings" | 9 "strings" |
10 ) | 10 ) |
(...skipping 10 matching lines...) Expand all Loading... |
21 } | 21 } |
22 unitName = unitName[:i] + "-" + unitName[i+1:] | 22 unitName = unitName[:i] + "-" + unitName[i+1:] |
23 return makeTag(UnitTagKind, unitName) | 23 return makeTag(UnitTagKind, unitName) |
24 } | 24 } |
25 | 25 |
26 // IsUnit returns whether name is a valid unit name. | 26 // IsUnit returns whether name is a valid unit name. |
27 func IsUnit(name string) bool { | 27 func IsUnit(name string) bool { |
28 return validUnit.MatchString(name) | 28 return validUnit.MatchString(name) |
29 } | 29 } |
30 | 30 |
31 func unitFromTagName(name string) string { | 31 func unitTagSuffixToId(s string) string { |
32 // Replace only the last "-" with "/", as it is valid for service | 32 // Replace only the last "-" with "/", as it is valid for service |
33 // names to contain hyphens. | 33 // names to contain hyphens. |
34 » if i := strings.LastIndex(name, "-"); i > 0 { | 34 » if i := strings.LastIndex(s, "-"); i > 0 { |
35 » » name = name[:i] + "/" + name[i+1:] | 35 » » s = s[:i] + "/" + s[i+1:] |
36 } | 36 } |
37 » return name | 37 » return s |
38 } | 38 } |
LEFT | RIGHT |