No. It just means that the user wants to run the command without an
environment. It is not an error as far as this command is concerned.
> It seems that either we allow to use to say "don't use an environment"
or we
> should fail if we can't open the environment defined by the command.
I'd rather keep the semantics simple for the user. A written, the
command works quite nicely without an environment, so long as all the
parameters are specified. But it does complain if an env name is
specified and the env cannot be opened.
https:/ /codereview. appspot. com/14663043/ diff/4001/ cmd/plugins/ juju-metadata/ imagemetadata. go juju-metadata/ imagemetadata. go (right):
File cmd/plugins/
https:/ /codereview. appspot. com/14663043/ diff/4001/ cmd/plugins/ juju-metadata/ imagemetadata. go#newcode64 juju-metadata/ imagemetadata. go:64: if store, err := Default( ); err == nil {
cmd/plugins/
configstore.
On 2013/10/16 00:47:59, thumper wrote:
> What should we be doing if there is no configstore? Is it an error?
No. It just means that the user wants to run the command without an
environment. It is not an error as far as this command is concerned.
> It seems that either we allow to use to say "don't use an environment"
or we
> should fail if we can't open the environment defined by the command.
I'd rather keep the semantics simple for the user. A written, the
command works quite nicely without an environment, so long as all the
parameters are specified. But it does complain if an env name is
specified and the env cannot be opened.
https:/ /codereview. appspot. com/14663043/ diff/4001/ cmd/plugins/ juju-metadata/ imagemetadata. go#newcode131 juju-metadata/ imagemetadata. go:131: %q
cmd/plugins/
On 2013/10/16 00:47:59, thumper wrote:
> why are the directories quoted?
Seemed like a good idea. I can unquote.
https:/ /codereview. appspot. com/14663043/ diff/4001/ cmd/plugins/ juju-metadata/ imagemetadata_ test.go juju-metadata/ imagemetadata_ test.go (right):
File cmd/plugins/
https:/ /codereview. appspot. com/14663043/ diff/4001/ cmd/plugins/ juju-metadata/ imagemetadata_ test.go# newcode39 juju-metadata/ imagemetadata_ test.go: 39: os.Clearenv()
cmd/plugins/
On 2013/10/16 00:47:59, thumper wrote:
> Why clear the entire environment?
We don't need *any* env vars set for the test and there's so many
combinations of AWS and EC2 env vars it's just easier.
https:/ /codereview. appspot. com/14663043/ diff/4001/ cmd/plugins/ juju-metadata/ imagemetadata_ test.go# newcode42 juju-metadata/ imagemetadata_ test.go: 42: restore := PatchEnvironmen t("AWS_ ACCESS_ KEY_ID" , "access")
cmd/plugins/
testbase.
On 2013/10/16 00:47:59, thumper wrote:
> just use:
> s.PatchEnvironm ent("AWS_ ACCESS_ KEY_ID" , "access")
> This adds the restore cleanup for you.
will do
https:/ /codereview. appspot. com/14663043/ diff/4001/ cmd/plugins/ juju-metadata/ imagemetadata_ test.go# newcode88 juju-metadata/ imagemetadata_ test.go: 88: strings. Contains( content, fmt.Sprintf( `"region" : %q`,
cmd/plugins/
c.Assert(
expected.region)), jc.IsTrue)
On 2013/10/16 00:47:59, thumper wrote:
> Do you realise that we have a checker for Contains?
> c.Assert(content, jc.Contains, fmt.Sprintf( `"region" : %q`,
expected.region))
I do now
https:/ /codereview. appspot. com/14663043/ diff/4001/ cmd/plugins/ juju-metadata/ imagemetadata_ test.go# newcode129 juju-metadata/ imagemetadata_ test.go: 129: errOut := (*bytes. Buffer) .String( )
cmd/plugins/
ctx.Stdout.
On 2013/10/16 00:47:59, thumper wrote:
> there is also testing.Stdout(ctx) which does the horrible cast for
you.
\o/
https:/ /codereview. appspot. com/14663043/ diff/4001/ cmd/plugins/ juju-metadata/ validateimageme tadata_ test.go juju-metadata/ validateimageme tadata_ test.go (right):
File cmd/plugins/
https:/ /codereview. appspot. com/14663043/ diff/4001/ cmd/plugins/ juju-metadata/ validateimageme tadata_ test.go# newcode101 juju-metadata/ validateimageme tadata_ test.go: 101: func(*gc. C) { restore() }) ent("AWS_ ACCESS_ KEY_ID" , "access")
cmd/plugins/
s.AddCleanup(
On 2013/10/16 00:47:59, thumper wrote:
> s.PatchEnvironm
will fix
https:/ /codereview. appspot. com/14663043/ diff/4001/ cmd/plugins/ juju-metadata/ validateimageme tadata_ test.go# newcode133 juju-metadata/ validateimageme tadata_ test.go: 133: PatchEnvironmen t("AWS_ ACCESS_ KEY_ID" , "")
cmd/plugins/
testbase.
On 2013/10/16 00:47:59, thumper wrote:
> s.PatchEnvironment
will fix
https:/ /codereview. appspot. com/14663043/ diff/4001/ environs/ imagemetadata/ generate. go imagemetadata/ generate. go (right):
File environs/
https:/ /codereview. appspot. com/14663043/ diff/4001/ environs/ imagemetadata/ generate. go#newcode27 imagemetadata/ generate. go:27: return err
environs/
On 2013/10/16 00:47:59, thumper wrote:
> Do you think it is worthwhile adding any logging to the failure
conditions?
Could do although the error will be propagated and printed higer up.
https:/ /codereview. appspot. com/14663043/ diff/4001/ environs/ imagemetadata/ generate. go#newcode57 imagemetadata/ generate. go:57: newRecord := im
environs/
On 2013/10/16 00:47:59, thumper wrote:
> Just to be clear, this isn't making a new record, but modifying the
pointer of
> the value passed in. Is that what you want?
> To make sure it is a copy you could do:
> newRecord := *im
> newRecord.blah = blah
> toWrite[i] = &newRecord
Bah, the slice did contain records and it was changed and I missed this.
Good pickup.
https:/ /codereview. appspot. com/14663043/ diff/4001/ environs/ imagemetadata/ generate_ test.go imagemetadata/ generate_ test.go (right):
File environs/
https:/ /codereview. appspot. com/14663043/ diff/4001/ environs/ imagemetadata/ generate_ test.go# newcode20 imagemetadata/ generate_ test.go: 20: type generateSuite struct{} LoggingSuite to capture
environs/
On 2013/10/16 00:47:59, thumper wrote:
> all test suits should contain from testbase.
logging (and
> give cleanup methods)
will fix
https:/ /codereview. appspot. com/14663043/ diff/4001/ environs/ imagemetadata/ generate_ test.go# newcode32 imagemetadata/ generate_ test.go: 32: c.Assert( len(metadata) ,
environs/
gc.Equals, 1)
On 2013/10/16 00:47:59, thumper wrote:
> c.Assert(metadata, gc.HasLen, 1)
will fix
https:/ /codereview. appspot. com/14663043/ diff/4001/ environs/ imagemetadata/ generate_ test.go# newcode54 imagemetadata/ generate_ test.go: 54: c.Assert( len(metadata) ,
environs/
gc.Equals, 1)
On 2013/10/16 00:47:59, thumper wrote:
> gc.HasLen
will fix
https:/ /codereview. appspot. com/14663043/ diff/4001/ environs/ imagemetadata/ generate_ test.go# newcode93 imagemetadata/ generate_ test.go: 93: c.Assert( len(metadata) ,
environs/
gc.Equals, 2)
On 2013/10/16 00:47:59, thumper wrote:
> gc.HasLen
will fix
https:/ /codereview. appspot. com/14663043/ diff/4001/ environs/ imagemetadata/ generate_ test.go# newcode135 imagemetadata/ generate_ test.go: 135: c.Assert( len(metadata) ,
environs/
gc.Equals, 3)
On 2013/10/16 00:47:59, thumper wrote:
> and again
ditto
https:/ /codereview. appspot. com/14663043/ diff/4001/ environs/ imagemetadata/ generate_ test.go# newcode184 imagemetadata/ generate_ test.go: 184: c.Assert( len(metadata) ,
environs/
gc.Equals, 3)
On 2013/10/16 00:47:59, thumper wrote:
> last one?
ditto
https:/ /codereview. appspot. com/14663043/ diff/4001/ environs/ imagemetadata/ marshal_ test.go imagemetadata/ marshal_ test.go (right):
File environs/
https:/ /codereview. appspot. com/14663043/ diff/4001/ environs/ imagemetadata/ marshal_ test.go# newcode17 imagemetadata/ marshal_ test.go: 17: type marshalSuite struct{} LoggingSuite
environs/
On 2013/10/16 00:47:59, thumper wrote:
> testbase.
Will fix
https:/ /codereview. appspot. com/14663043/