Merge lp:~jtv/gwacl/name-factory into lp:gwacl
Proposed by
Jeroen T. Vermeulen
Status: | Merged |
---|---|
Approved by: | Jeroen T. Vermeulen |
Approved revision: | 166 |
Merged at revision: | 165 |
Proposed branch: | lp:~jtv/gwacl/name-factory |
Merge into: | lp:gwacl |
Diff against target: |
160 lines (+130/-3) 3 files modified
example/management/run.go (+2/-3) names.go (+74/-0) names_test.go (+54/-0) |
To merge this branch: | bzr merge lp:~jtv/gwacl/name-factory |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raphaël Badin (community) | Approve | ||
Review via email: mp+173178@code.launchpad.net |
Commit message
Export some factories for generating random names.
Description of the change
As discussed with rvba. This encodes knowledge about what exactly can be in the identifier Azure needs for a given type.
The driving use-case is not testing, so much as the need to come up with unique names when working against the real Azure. That's why I didn't go all-out. Of course with this in place, a logical next step would be to export similar factories for other types of identifiers.
Jeroen
To post a comment you must log in.
Looks good.
[0]
9 - hostServiceName := makeRandomIdent ifier(" gwacl", 24) mHostedServiceN ame("gwacl" )
10 + hostServiceName := gwacl.MakeRando
You can probably get rid of the version of makeRandomIdent ifier that is in example/ management/ run.go and use the one from names.go when it's still used directly in run.go.
[1]
79 +// Be sure your random generator is initialized, or this will always produce
80 +// the same sequence!
Why don't we initialize the generator in names.go? This is, I think, so easily forgotten that it's worth not letting that up to the caller.
[2]
56 + if len(prefix) > length { Errorf( "prefix '%s' is more than the requested %d characters long", prefix, length))
57 + panic(fmt.
58 + }
I think we're missing a test for that code path.
[3]
75 +// The prefix must be as short as possible, be entirely in ASCII, start with
76 +// a lower-case letter, and contain only lower-case letters and digits after
77 +// that.
Maybe it's me but it's not very clear what "must" means here: is it something that the method checks? I'd add something like "For the prefix to be compatible with Azure's constraints, the prefix must be…" or something.
[4]
81 +func MakeRandomHoste dServiceName( prefix string) string { ifier(prefix, 24)
82 + // A hosted-service name must be between 3 and 24 letters long.
83 + return makeRandomIdent
84 +}
Could you add links to the relevant piece of documentation please. I'm reading http:// msdn.microsoft. com/en- us/library/ windowsazure/ gg441304. aspx and there is something odd in there: ServiceName. cloudapp. net//
"""
ServiceName
Required. A name for the cloud service that is unique within Windows Azure. This name is the DNS prefix name and can be used to access the service.
For example: http://
"""
This, AFAIK, is just plain wrong :/