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

Issue 12165043: names: Fix lp:1206628 (unit-name-to-tag issues) (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 9 months ago by dimitern
Modified:
10 years, 9 months ago
Reviewers:
mp+177850, fwereade, rog
Visibility:
Public.

Description

names: Fix lp:1206628 (unit-name-to-tag issues) This fixes the conversions from a unit name to a tag and vice versa, which caused incorrect behavior with services with dashes in the name, like "rabbitmq-server". https://code.launchpad.net/~dimitern/juju-core/082-bug-1206628-unit-name-from-tag/+merge/177850 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 9

Patch Set 2 : names: Fix lp:1206628 (unit-name-to-tag issues) #

Unified diffs Side-by-side diffs Delta from patch set Stats (+38 lines, -8 lines) Patch
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M names/machine_test.go View 1 2 chunks +2 lines, -2 lines 0 comments Download
M names/service_test.go View 1 1 chunk +1 line, -1 line 0 comments Download
M names/tagkind_test.go View 1 1 chunk +1 line, -1 line 0 comments Download
M names/unit.go View 1 2 chunks +13 lines, -3 lines 0 comments Download
M names/unit_test.go View 1 4 chunks +19 lines, -1 line 0 comments Download

Messages

Total messages: 4
dimitern
Please take a look.
10 years, 9 months ago (2013-07-31 14:05:30 UTC) #1
fwereade
LGTM https://codereview.appspot.com/12165043/diff/1/names/unit_test.go File names/unit_test.go (right): https://codereview.appspot.com/12165043/diff/1/names/unit_test.go#newcode67 names/unit_test.go:67: c.Logf("%d. %q", i, test.pattern) The "test %d: %s" ...
10 years, 9 months ago (2013-07-31 14:10:49 UTC) #2
rog
LGTM with some minor remarks. https://codereview.appspot.com/12165043/diff/1/names/unit.go File names/unit.go (right): https://codereview.appspot.com/12165043/diff/1/names/unit.go#newcode17 names/unit.go:17: // Replace only the ...
10 years, 9 months ago (2013-07-31 14:18:14 UTC) #3
dimitern
10 years, 9 months ago (2013-07-31 14:22:59 UTC) #4
Please take a look.

https://codereview.appspot.com/12165043/diff/1/names/unit.go
File names/unit.go (right):

https://codereview.appspot.com/12165043/diff/1/names/unit.go#newcode17
names/unit.go:17: // Replace only the last "/" with "-".
On 2013/07/31 14:18:14, rog wrote:
> i think this was ok as it was before - if we've got a slash in a service name,
> then we're already screwed (and we *really* don't want slashes creeping into
> tags).
> 
> perhaps just
> 
>    if !IsUnit(unitName) { 
>        panic(...not valid name)
>    }
>    return makeTag(UnitTagKind, strings.Replace(unitName, "/", "-", -1))

The code assumed too much, so I decided to fix both places.

https://codereview.appspot.com/12165043/diff/1/names/unit.go#newcode33
names/unit.go:33: // Replace only the last "-" with "/".
On 2013/07/31 14:18:14, rog wrote:
> s/./, as it is valid for service names to contain hyphens./
> ?

Done.

https://codereview.appspot.com/12165043/diff/1/names/unit_test.go
File names/unit_test.go (right):

https://codereview.appspot.com/12165043/diff/1/names/unit_test.go#newcode67
names/unit_test.go:67: c.Logf("%d. %q", i, test.pattern)
On 2013/07/31 14:10:49, fwereade wrote:
> The "test %d: %s" spelling is pretty common, and my eye at least is used to
> picking it out of noisy output

Done. Will also change other similar c.Logf calls in the same package.

https://codereview.appspot.com/12165043/diff/1/names/unit_test.go#newcode70
names/unit_test.go:70: return names.UnitTag(test.pattern)
On 2013/07/31 14:10:49, fwereade wrote:
> testUnitTag := func() { names.UnitTag(pattern) }

Done.
Sign in to reply to this message.

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