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

Issue 12034043: names: New package (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+177416, fwereade, rog
Visibility:
Public.

Description

names: New package This introduces a new juju-core/names pacakge, which contains all name and tag related functions shared between state and API: IsUnitName, UnitTag, UnitNameFromTag, MachineTag, MachineIdFromTag, IsServiceName, etc. Because of the pacakge name, some functions were renamed: names.IsUnit, IsService, UnitFromTag, all refer to names. In addition, a change was made to these two functions: UnitNameFromTag and MachineIdFromTag. Both of them now return (string, error), rather than just string. The error return is used in case the passed tag string has an invalid format. Because of this change, some places needed slight refactoring, otherwise no other changes where made. https://code.launchpad.net/~dimitern/juju-core/081-common-names/+merge/177416 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 39

Patch Set 2 : names: New package #

Total comments: 24

Patch Set 3 : names: New package #

Total comments: 2

Patch Set 4 : names: New package #

Unified diffs Side-by-side diffs Delta from patch set Stats (+689 lines, -281 lines) Patch
A [revision details] View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M cmd/juju/addmachine.go View 2 chunks +5 lines, -2 lines 0 comments Download
M cmd/juju/addunit.go View 2 chunks +4 lines, -2 lines 0 comments Download
M cmd/juju/constraints.go View 1 3 chunks +5 lines, -3 lines 0 comments Download
M cmd/juju/deploy.go View 1 2 chunks +5 lines, -3 lines 0 comments Download
M cmd/juju/destroymachine.go View 1 2 2 chunks +3 lines, -2 lines 0 comments Download
M cmd/juju/destroyservice.go View 1 2 chunks +3 lines, -2 lines 0 comments Download
M cmd/juju/destroyunit.go View 1 2 chunks +3 lines, -2 lines 0 comments Download
M cmd/juju/resolved.go View 1 2 chunks +4 lines, -2 lines 0 comments Download
M cmd/juju/ssh.go View 1 2 2 chunks +5 lines, -3 lines 0 comments Download
M cmd/juju/upgradecharm.go View 1 2 chunks +5 lines, -3 lines 0 comments Download
M cmd/jujud/machine.go View 1 2 3 chunks +3 lines, -2 lines 0 comments Download
M cmd/jujud/machine_test.go View 1 2 2 chunks +2 lines, -1 line 0 comments Download
M cmd/jujud/unit.go View 1 2 3 chunks +3 lines, -2 lines 0 comments Download
M cmd/jujud/upgradevalidation.go View 1 2 2 chunks +6 lines, -1 line 0 comments Download
M container/lxc/lxc.go View 2 chunks +2 lines, -1 line 0 comments Download
M environs/azure/customdata_test.go View 2 chunks +3 lines, -2 lines 0 comments Download
M environs/cloudinit/cloudinit.go View 1 2 5 chunks +7 lines, -6 lines 0 comments Download
M environs/dummy/environs.go View 1 2 2 chunks +10 lines, -8 lines 0 comments Download
M environs/local/environ.go View 1 2 3 chunks +3 lines, -2 lines 0 comments Download
M environs/openstack/provider.go View 1 2 3 chunks +8 lines, -5 lines 0 comments Download
M juju/conn.go View 1 2 2 chunks +2 lines, -1 line 0 comments Download
M juju/testing/conn.go View 4 chunks +7 lines, -4 lines 0 comments Download
A names/environ.go View 1 2 1 chunk +9 lines, -0 lines 0 comments Download
A names/machine.go View 1 2 3 1 chunk +52 lines, -0 lines 0 comments Download
A names/machine_test.go View 1 2 1 chunk +115 lines, -0 lines 0 comments Download
A names/service.go View 1 2 1 chunk +25 lines, -0 lines 0 comments Download
A names/service_test.go View 1 1 chunk +37 lines, -0 lines 0 comments Download
A names/tagkind.go View 1 2 1 chunk +47 lines, -0 lines 0 comments Download
A names/tagkind_test.go View 1 2 1 chunk +42 lines, -0 lines 0 comments Download
A names/unit.go View 1 2 1 chunk +37 lines, -0 lines 0 comments Download
A names/unit_test.go View 1 1 chunk +55 lines, -0 lines 0 comments Download
M state/api/deployer/unit.go View 1 2 chunks +4 lines, -16 lines 0 comments Download
M state/apiserver/deployer/deployer.go View 1 2 5 chunks +33 lines, -17 lines 0 comments Download
M state/apiserver/deployer/deployer_test.go View 2 chunks +2 lines, -1 line 0 comments Download
M state/apiserver/machine/agent.go View 1 2 2 chunks +6 lines, -1 line 0 comments Download
M state/apiserver/machine/machiner.go View 1 2 5 chunks +38 lines, -21 lines 0 comments Download
M state/apiserver/upgrader/upgrader.go View 1 2 2 chunks +6 lines, -1 line 0 comments Download
M state/environ.go View 2 chunks +2 lines, -1 line 0 comments Download
M state/machine.go View 2 chunks +2 lines, -26 lines 0 comments Download
M state/machine_test.go View 1 chunk +0 lines, -17 lines 0 comments Download
M state/relationunit.go View 1 2 chunks +2 lines, -1 line 0 comments Download
M state/service.go View 1 3 chunks +3 lines, -2 lines 0 comments Download
M state/state.go View 1 2 10 chunks +35 lines, -57 lines 0 comments Download
M state/state_test.go View 1 2 5 chunks +10 lines, -9 lines 0 comments Download
M state/unit.go View 4 chunks +4 lines, -26 lines 0 comments Download
state/unit_test.go View 2 chunks +0 lines, -10 lines 0 comments Download
state/watcher.go View 2 chunks +2 lines, -1 line 0 comments Download
worker/deployer/deployer.go View 2 chunks +2 lines, -1 line 0 comments Download
M worker/deployer/deployer_test.go View 3 chunks +3 lines, -2 lines 0 comments Download
M worker/deployer/simple.go View 1 5 chunks +6 lines, -6 lines 0 comments Download
M worker/deployer/simple_test.go View 3 chunks +3 lines, -2 lines 0 comments Download
M worker/provisioner/provisioner_task.go View 2 chunks +4 lines, -2 lines 0 comments Download
M worker/provisioner/provisioner_test.go View 2 chunks +3 lines, -1 line 0 comments Download
M worker/upgrader/upgrader.go View 1 2 1 chunk +0 lines, -1 line 0 comments Download

Messages

Total messages: 9
dimitern
Please take a look.
10 years, 9 months ago (2013-07-29 15:26:43 UTC) #1
rog
very nice direction. some comments below. https://codereview.appspot.com/12034043/diff/1/cmd/juju/addmachine.go File cmd/juju/addmachine.go (right): https://codereview.appspot.com/12034043/diff/1/cmd/juju/addmachine.go#newcode64 cmd/juju/addmachine.go:64: c.MachineId = containerSpec[sep+1:] ...
10 years, 9 months ago (2013-07-29 16:28:44 UTC) #2
fwereade
Generally agree with rog's comments, just a couple of my own. https://codereview.appspot.com/12034043/diff/1/names/unit.go File names/unit.go (right): ...
10 years, 9 months ago (2013-07-30 11:29:44 UTC) #3
dimitern
Please take a look. https://codereview.appspot.com/12034043/diff/1/cmd/juju/addmachine.go File cmd/juju/addmachine.go (right): https://codereview.appspot.com/12034043/diff/1/cmd/juju/addmachine.go#newcode64 cmd/juju/addmachine.go:64: c.MachineId = containerSpec[sep+1:] On 2013/07/29 ...
10 years, 9 months ago (2013-07-30 14:38:36 UTC) #4
rog
looking very much better, thanks! one more round of suggestions and then i think we'll ...
10 years, 9 months ago (2013-07-30 15:10:11 UTC) #5
fwereade
LGTM with a few thoughts. https://codereview.appspot.com/12034043/diff/1/cmd/juju/addmachine.go File cmd/juju/addmachine.go (right): https://codereview.appspot.com/12034043/diff/1/cmd/juju/addmachine.go#newcode64 cmd/juju/addmachine.go:64: c.MachineId = containerSpec[sep+1:] On ...
10 years, 9 months ago (2013-07-30 15:22:53 UTC) #6
dimitern
Please take a look. https://codereview.appspot.com/12034043/diff/11001/names/constants.go File names/constants.go (right): https://codereview.appspot.com/12034043/diff/11001/names/constants.go#newcode18 names/constants.go:18: UnitTagPrefix = UnitTagKind + "-" ...
10 years, 9 months ago (2013-07-30 16:47:50 UTC) #7
rog
LGTM with two final suggestions. https://codereview.appspot.com/12034043/diff/1/cmd/juju/addmachine.go File cmd/juju/addmachine.go (right): https://codereview.appspot.com/12034043/diff/1/cmd/juju/addmachine.go#newcode64 cmd/juju/addmachine.go:64: c.MachineId = containerSpec[sep+1:] On ...
10 years, 9 months ago (2013-07-30 17:36:46 UTC) #8
dimitern
10 years, 9 months ago (2013-07-30 18:28:23 UTC) #9
Please take a look.

https://codereview.appspot.com/12034043/diff/1/cmd/juju/addmachine.go
File cmd/juju/addmachine.go (right):

https://codereview.appspot.com/12034043/diff/1/cmd/juju/addmachine.go#newcode64
cmd/juju/addmachine.go:64: c.MachineId = containerSpec[sep+1:]
On 2013/07/30 17:36:47, rog wrote:
> On 2013/07/30 15:22:54, fwereade wrote:
> > On 2013/07/30 15:10:11, rog wrote:
> > > On 2013/07/30 14:38:37, dimitern wrote:
> > > > On 2013/07/29 16:28:44, rog wrote:
> > > > > it seems to me like the above code (with its knowledge
> > > > > of the colon-separated syntax of a container spec)
> > > > > should live in names too.
> > > > 
> > > > Not really, this syntax here is specific to the command: "lxc:<id>"
means
> > > start
> > > > an LXC container in machine <id>.
> > > 
> > > it looks like the names package supports this syntax (e.g.
> > > names.ContainerSpecSnippet) and so the parsing for it
> > > should probably live there too.
> > 
> > Don't think so. In `lxc:0`, "lxc" identifies the (pseudo?) provider, and "0"
> is
> > a provider-specific placement directive that's in here because it's kinda
> > convenient and we haven't formalized the notion of the lxc provider yet. We
> > almost certainly shouldn't pull any more related logic into this particular
> > package.
> 
> I still think that this logic should live in names.
> apart from anything else, this code looks wrong when
> containerSpec is a simple machine spec.
> ParseSupportedContainerType might ensure
> that it can't be, but it looks superficially as if we're calling
> IsMachineOrNewContainer
> and that we're using the fact that's returned true to
> deduce that the containerSpec contains a ":".
> 
> just:
> 
> func SplitContainerSpec(containerSpec string) (containerType string, err
error)
> 
> in names might do the job.

If ":" is not in containerSpec, then c.MachineId will be set to containerSpec
(just a machine id in this case), while before calling
ParseSupportedContainerType the containerSpec[:sep] will panic. There should be
tests for that, but I'm not comfortable mixing this logic in this CL, at least
it deserves a discussion first.

https://codereview.appspot.com/12034043/diff/24001/names/machine.go
File names/machine.go (right):

https://codereview.appspot.com/12034043/diff/24001/names/machine.go#newcode12
names/machine.go:12: ContainerSpecSnippet = "(([a-z])+:)?"
On 2013/07/30 17:36:47, rog wrote:
> please remove the unnecessary brackets - they only serve to confuse.

Done.
Sign in to reply to this message.

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