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

Issue 13619043: Refactor simplestreams to use a DataSource (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 8 months ago by wallyworld
Modified:
10 years, 7 months ago
Reviewers:
mp+184502, fwereade
Visibility:
Public.

Description

Refactor simplestreams to use a DataSource Simplestreams metadata lookup currently assumes a http transport is all that is required, so that all it needs is a URL from which to fetch the data. However, this is no longer valid if we want to load simplestreams data from the environment's private bucket. So this branch introduces a new simplestreams.DataSource interface and implementations which provide for the http and private bucket use cases. https://code.launchpad.net/~wallyworld/juju-core/simplestreams-control-bucket/+merge/184502 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : Refactor simplestreams to use a DataSource #

Total comments: 14
Unified diffs Side-by-side diffs Delta from patch set Stats (+468 lines, -237 lines) Patch
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M cmd/plugins/juju-metadata/toolsmetadata_test.go View 3 chunks +3 lines, -4 lines 2 comments Download
M cmd/plugins/juju-metadata/validateimagemetadata.go View 3 chunks +10 lines, -3 lines 0 comments Download
M cmd/plugins/juju-metadata/validatetoolsmetadata.go View 3 chunks +10 lines, -3 lines 0 comments Download
M environs/imagemetadata/simplestreams.go View 3 chunks +8 lines, -6 lines 0 comments Download
M environs/imagemetadata/simplestreams_test.go View 3 chunks +3 lines, -3 lines 0 comments Download
M environs/imagemetadata/urls.go View 1 chunk +13 lines, -12 lines 0 comments Download
M environs/imagemetadata/urls_test.go View 2 chunks +7 lines, -6 lines 0 comments Download
M environs/imagemetadata/validation.go View 1 chunk +3 lines, -3 lines 0 comments Download
M environs/imagemetadata/validation_test.go View 2 chunks +2 lines, -2 lines 0 comments Download
M environs/instances/image_test.go View 1 chunk +2 lines, -1 line 0 comments Download
A environs/simplestreams/datasource.go View 1 chunk +67 lines, -0 lines 4 comments Download
A environs/simplestreams/datasource_test.go View 1 chunk +40 lines, -0 lines 0 comments Download
M environs/simplestreams/simplestreams.go View 15 chunks +39 lines, -58 lines 0 comments Download
M environs/simplestreams/simplestreams_test.go View 4 chunks +12 lines, -8 lines 0 comments Download
M environs/simplestreams/testing/testing.go View 3 chunks +22 lines, -9 lines 0 comments Download
M environs/simplestreams/validation.go View 1 chunk +1 line, -1 line 0 comments Download
M environs/storage.go View 2 chunks +31 lines, -0 lines 4 comments Download
A environs/storage_test.go View 1 chunk +54 lines, -0 lines 0 comments Download
M environs/tools/simplestreams.go View 4 chunks +15 lines, -16 lines 2 comments Download
M environs/tools/simplestreams_test.go View 3 chunks +6 lines, -4 lines 0 comments Download
M environs/tools/tools.go View 3 chunks +5 lines, -5 lines 0 comments Download
M environs/tools/urls.go View 1 chunk +16 lines, -13 lines 0 comments Download
M environs/tools/urls_test.go View 2 chunks +8 lines, -7 lines 2 comments Download
M environs/tools/validation.go View 2 chunks +3 lines, -3 lines 0 comments Download
M environs/tools/validation_test.go View 4 chunks +4 lines, -4 lines 0 comments Download
M provider/azure/environ.go View 3 chunks +9 lines, -3 lines 0 comments Download
M provider/azure/instancetype.go View 1 chunk +2 lines, -2 lines 0 comments Download
M provider/azure/instancetype_test.go View 2 chunks +2 lines, -1 line 0 comments Download
M provider/dummy/environs.go View 3 chunks +9 lines, -8 lines 0 comments Download
M provider/ec2/ec2.go View 1 chunk +2 lines, -2 lines 0 comments Download
M provider/ec2/image.go View 2 chunks +2 lines, -2 lines 0 comments Download
M provider/ec2/image_test.go View 3 chunks +16 lines, -13 lines 0 comments Download
M provider/ec2/local_test.go View 1 chunk +1 line, -1 line 0 comments Download
M provider/openstack/image.go View 1 chunk +2 lines, -2 lines 0 comments Download
M provider/openstack/local_test.go View 2 chunks +19 lines, -11 lines 0 comments Download
M provider/openstack/provider.go View 1 4 chunks +18 lines, -21 lines 0 comments Download

Messages

Total messages: 4
wallyworld
Please take a look.
10 years, 8 months ago (2013-09-09 03:57:46 UTC) #1
wallyworld
Please take a look.
10 years, 8 months ago (2013-09-09 04:21:13 UTC) #2
fwereade
Thank you, this is fantastic. I don't like the explicit http naming for non-http-handling things, ...
10 years, 7 months ago (2013-09-11 12:27:55 UTC) #3
wallyworld
10 years, 7 months ago (2013-09-12 00:17:04 UTC) #4
Thanks for reviewing. I've fixed the issues

https://codereview.appspot.com/13619043/diff/4001/cmd/plugins/juju-metadata/t...
File cmd/plugins/juju-metadata/toolsmetadata_test.go (right):

https://codereview.appspot.com/13619043/diff/4001/cmd/plugins/juju-metadata/t...
cmd/plugins/juju-metadata/toolsmetadata_test.go:57: source :=
simplestreams.NewHttpDataSource("file://" + metadataDir + "/tools")
On 2013/09/11 12:27:55, fwereade wrote:
> "Http" and "file://" don't mix. Is it maybe a NewURLDataSource? or even just
> `NewDataSource(url string) (DataSource, error)`, leaving open the option to
> switch implementations based on the url?

I called it HttpDataSource because it uses Go's http client to get the data. But
you raise a good point. I'll rename to NewURLDataSource

https://codereview.appspot.com/13619043/diff/4001/environs/simplestreams/data...
File environs/simplestreams/datasource.go (right):

https://codereview.appspot.com/13619043/diff/4001/environs/simplestreams/data...
environs/simplestreams/datasource.go:18: Fetch(path string) (io.ReadCloser,
string, error)
On 2013/09/11 12:27:55, fwereade wrote:
> the returned string is apparently a url, or sometimes a path. Please document
> the expectations -- I suppose it's a best guess at useful flavor for the error
> messages?

The returned result is always a URL. For environs storage instances, it is
obtained by calling storage.URL(). I've added some extra documentation.

https://codereview.appspot.com/13619043/diff/4001/environs/simplestreams/data...
environs/simplestreams/datasource.go:48: resp, err := httpClient.Get(dataURL)
On 2013/09/11 12:27:55, fwereade wrote:
> Yeah, I'm a bit uncomfortable with the "http" naming, when the fundamental
> connection with "http" is that we're registering extra handlers for the global
> client in order to handle things that *aren't* http. I'd prefer to call it
> something more neutral, and clearly document the possibly-surprising
> interaction.

Well, Go's net/http/Client instance is the thing doing the Getting, hence the
variable name. I'll rename the variable.

https://codereview.appspot.com/13619043/diff/4001/environs/storage.go
File environs/storage.go (right):

https://codereview.appspot.com/13619043/diff/4001/environs/storage.go#newcode32
environs/storage.go:32: // A httpDataSource retrieves data from an
environs.StorageReader.
On 2013/09/11 12:27:55, fwereade wrote:
> bad name

Ah ffs. Cut'n'paste fail

https://codereview.appspot.com/13619043/diff/4001/environs/storage.go#newcode37
environs/storage.go:37: // NewHttpDataSource returns a new http datasource
reading from the specified storage.
On 2013/09/11 12:27:55, fwereade wrote:
> bad name

ditto

https://codereview.appspot.com/13619043/diff/4001/environs/tools/simplestream...
File environs/tools/simplestreams.go (right):

https://codereview.appspot.com/13619043/diff/4001/environs/tools/simplestream...
environs/tools/simplestreams.go:91: if !strings.HasPrefix(url,
"http://juju.canonical.com/tools") {
On 2013/09/11 12:27:55, fwereade wrote:
> Hmm, shouldn't this be https?

Done.

https://codereview.appspot.com/13619043/diff/4001/environs/tools/urls_test.go
File environs/tools/urls_test.go (right):

https://codereview.appspot.com/13619043/diff/4001/environs/tools/urls_test.go...
environs/tools/urls_test.go:57: "config-tools-url/", "dummy-tools-url/",
"http://juju.canonical.com/tools/"})
On 2013/09/11 12:27:55, fwereade wrote:
> again, surely https?

Done.
Sign in to reply to this message.

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