Code review comment for lp:~dimitern/juju-core/330-general-improvements

Revision history for this message
Roger Peppe (rogpeppe) wrote :

A few more suggestions. It's great that we've lost the testing
dependencies from the code, but there are a few pieces I'm concerned
about.

https://codereview.appspot.com/72860045/diff/2/environs/manual/init.go
File environs/manual/init.go (right):

https://codereview.appspot.com/72860045/diff/2/environs/manual/init.go#newcode21
environs/manual/init.go:21: const DetectionScript = `#!/bin/bash
I don't quite see why this and CheckProvisionedScript now need to be
exported.

The only reason that I can see is that manual/testing is a separate
package. Given that it's only imported from environs/manual, I don't see
what value that adds. I'd prefer to avoid unnecessary twisty
dependencies.

https://codereview.appspot.com/72860045/diff/2/environs/open.go
File environs/open.go (right):

https://codereview.appspot.com/72860045/diff/2/environs/open.go#newcode93
environs/open.go:93: if source != ConfigFromInfo {
I think andrew has a point here - if ConfigForName returns a useful
error message, it will be lost.

If we're going to deprecate reading config from environments.yaml,
that deserves its own CL, as there is a substantial amount
of cleanup that can and should happen then.

https://codereview.appspot.com/72860045/diff/2/errors/errors.go
File errors/errors.go (right):

https://codereview.appspot.com/72860045/diff/2/errors/errors.go#newcode6
errors/errors.go:6: import "fmt"
On 2014/03/11 10:06:33, jameinel wrote:
> I actually prefer the other form.
> Because as soon as we need 2 imports, we want to do it anyway, and
that avoids
> having the noise of what actually changed confused with the extra
lines.

> Certainly not worth going around again, just wanted to give my feeling
that
> multiline imports are still reasonable to use when you only have one.

I think we shouldn't care too much. If goimports inserts a single
import, it does so without the ( ), and that's a useful enough tool that
I think it's reasonable to allow its default output through.

https://codereview.appspot.com/72860045/diff/2/juju/api.go
File juju/api.go (right):

https://codereview.appspot.com/72860045/diff/2/juju/api.go#newcode104
juju/api.go:104: if !configstore.Exists(envName) {
As I mentioned in earlier comments, I don't think this is right.

If we want to make it so that we can't open the API without a .jenv
file, that should be a deeper change in this file - there is a fair
amount of logic that can be simplified here.

https://codereview.appspot.com/72860045/diff/2/juju/apiconn_test.go
File juju/apiconn_test.go (right):

https://codereview.appspot.com/72860045/diff/2/juju/apiconn_test.go#newcode257
juju/apiconn_test.go:257: bootstrapEnv(c, &cs.CleanupSuite,
coretesting.SampleEnvName, store)
This is changed only because of the unnecessary Exists patching AFAICS.

https://codereview.appspot.com/72860045/diff/2/juju/conn_test.go
File juju/conn_test.go (right):

https://codereview.appspot.com/72860045/diff/2/juju/conn_test.go#newcode88
juju/conn_test.go:88: s.PatchValue(&configstore.Exists, func(name
string) bool {
This seems wrong, as I've mentioned earlier.
It is not at all clear how patching this value will
affect any of the lines of code below - it's truly
action-at-a-distance, and hinges crucially on the
fact that the code calls Exists rather than using
the ReadInfo method to infer non-existence of an environment
info (which is a perfectly reasonable implementation).

https://codereview.appspot.com/72860045/diff/2/juju/osenv/home.go
File juju/osenv/home.go (right):

https://codereview.appspot.com/72860045/diff/2/juju/osenv/home.go#newcode35
juju/osenv/home.go:35: func HaveJujuHome() bool {
Why do we have this?
Any client must call InitJujuHome. If they do not,
it is right to panic.

https://codereview.appspot.com/72860045/diff/2/provider/joyent/config.go
File provider/joyent/config.go (right):

https://codereview.appspot.com/72860045/diff/2/provider/joyent/config.go#newcode23
provider/joyent/config.go:23: # Can be set via env variables, or
specified here
We should be consistent in the juju init output. Both ec2 and azure have
the descriptions as full sentences. Something like this would seem
better to me (we should really mention the actual environment variables
used too):

# sdc-user holds the SDC user. It can also be specified in
# the SDC_ACCOUNT environment variable.
#
# sdc-user: <username>

https://codereview.appspot.com/72860045/diff/2/provider/local/environprovider.go
File provider/local/environprovider.go (right):

https://codereview.appspot.com/72860045/diff/2/provider/local/environprovider.go#newcode232
provider/local/environprovider.go:232: # Override the directory that is
used for the storage files and
# root-dir overrides the directory...

and below.

https://codereview.appspot.com/72860045/diff/2/state/apiserver/charms.go
File state/apiserver/charms.go (right):

https://codereview.appspot.com/72860045/diff/2/state/apiserver/charms.go#newcode32
state/apiserver/charms.go:32: utilsstorage
"launchpad.net/juju-core/utils/storage"
Why not just "storage" ?

https://codereview.appspot.com/72860045/diff/2/state/apiserver/charms_test.go
File state/apiserver/charms_test.go (right):

https://codereview.appspot.com/72860045/diff/2/state/apiserver/charms_test.go#newcode27
state/apiserver/charms_test.go:27: utilsstorage
"launchpad.net/juju-core/utils/storage"
s/utilsstorage/storage/ ?

https://codereview.appspot.com/72860045/diff/2/state/apiserver/client/client_test.go
File state/apiserver/client/client_test.go (right):

https://codereview.appspot.com/72860045/diff/2/state/apiserver/client/client_test.go#newcode1802
state/apiserver/client/client_test.go:1802: theStorage :=
s.Conn.Environ.Storage()
please not the dreaded "the" convention!

Given that you've aliased both imports, you can
continue to use just "storage".

https://codereview.appspot.com/72860045/diff/2/utils/http.go
File utils/http.go (right):

https://codereview.appspot.com/72860045/diff/2/utils/http.go#newcode41
utils/http.go:41: registerFileProto(transport)
Why are we doing this?

It seems like a potential security hole to me - there's nothing in the
function documentation to state that the transport also serves files
from /.

https://codereview.appspot.com/72860045/diff/2/utils/storage/storage.go
File utils/storage/storage.go (right):

https://codereview.appspot.com/72860045/diff/2/utils/storage/storage.go#newcode16
utils/storage/storage.go:16: func GetEnvironStorage(st *state.State)
(storage.Storage, error) {
I don't think this package is justified for this trivial utility
function.
Why not just put the function inside environs?

https://codereview.appspot.com/72860045/

« Back to merge proposal