https://codereview.appspot.com/70190050/diff/80001/juju/conn_test.go#newcode154
juju/conn_test.go:154: // setting.
In normal circumstances it shouldn't be possible, but this is
specifically for a test. Not removing it completely misses the point of
the test: that if the attributes *aren't* in state, they will be added.
This is testing compatibility with legacy code.
Please put this back to how it was, using a nil policy to override the
removal prevention.
https://codereview.appspot.com/70190050/diff/80001/state/state.go#newcode283
state/state.go:283: return fmt.Errorf("both updateAttrs and removeAttrs
cannont be empty")
I'd be tempted just to return nil here, since there's nothing to do. It
could be easy to get into the situation where you compute a bunch of
changes to be made (add/modify/remove attributes) and then call
UpdateEnvironConfig. It seems onerous to have to check that you've got
no changes to make in each place.
https://codereview.appspot.com/70190050/diff/80001/state/state_test.go#oldcode1762
state/state_test.go:1762: cfg, err := s.State.EnvironConfig()
Remind me why this was deleted please? It's still possible for someone
to come along and muck up the attributes in Mongo (e.g. with an buggy
script that modified the db directly), just not from within Juju.
https://codereview.appspot.com/70190050/diff/80001/state/state_test.go#newcode1261
state/state_test.go:1261: for k, v := range attrs {
You've changed the test a bit. It's now checking that the modified
attributes are modified, but no longer checking that the existing
attributes are unmodified, and that no additional attributes were added.
I think what you should do is get the config first, do an
UpdateEnvironConfig, merge the modified attributes with the existing
config and then ensure that EnvironConfig() DeepEquals the merged
config.
Getting there.
https:/ /codereview. appspot. com/70190050/ diff/60001/ state/apiserver /keymanager/ keymanager. go /keymanager/ keymanager. go (left):
File state/apiserver
https:/ /codereview. appspot. com/70190050/ diff/60001/ state/apiserver /keymanager/ keymanager. go#oldcode311 /keymanager/ keymanager. go:311: // For now, authorised
state/apiserver
keys are global, common to all users.
On 2014/03/13 01:02:03, waigani wrote:
> On 2014/03/10 03:41:54, axw wrote:
> > This comment didn't need to be deleted
> I'm confused. The comment is still there on line 312?
Huh, I must've been on crack. Never mind.
https:/ /codereview. appspot. com/70190050/ diff/60001/ worker/ environ_ test.go environ_ test.go (left):
File worker/
https:/ /codereview. appspot. com/70190050/ diff/60001/ worker/ environ_ test.go# oldcode49 environ_ test.go: 49: // Create an invalid config by taking the
worker/
current config and
On 2014/03/13 01:02:03, waigani wrote:
> On 2014/03/10 03:41:54, axw wrote:
> > This shouldn't go until UpdateEnvironConfig is completely fixed.
> I see that TestInvalidConfig is no longer in trunk, so I assume to is
fine to
> leave this deleted?
I just pulled trunk and it is still there. Not sure what you're looking bazaar. launchpad. net/~go- bot/juju- core/trunk/ view/head: /worker/ environ_ test.go# L48
at...
http://
https:/ /codereview. appspot. com/70190050/ diff/60001/ worker/ machineenvironm entworker/ machineenvironm entworker_ test.go machineenvironm entworker/ machineenvironm entworker_ test.go
File worker/
(right):
https:/ /codereview. appspot. com/70190050/ diff/60001/ worker/ machineenvironm entworker/ machineenvironm entworker_ test.go# newcode128 machineenvironm entworker/ machineenvironm entworker_ test.go: 128: interface{ }{} string] interface{ })
worker/
attrs := map[string]
On 2014/03/13 01:02:03, waigani wrote:
> On 2014/03/10 03:41:54, axw wrote:
> > The conventional way to write this is
> > attrs := make(map[
> Ah. There are a lot of map[string] interface{ }{} around (from my code
and
> others). Shall I put off changing these to another day/branch?
No problems, just leave them.
https:/ /codereview. appspot. com/70190050/ diff/80001/ cmd/juju/ environment_ test.go environment_ test.go (right):
File cmd/juju/
https:/ /codereview. appspot. com/70190050/ diff/80001/ cmd/juju/ environment_ test.go# newcode14 environment_ test.go: 14: _ net/juju- core/provider/ dummy"
cmd/juju/
"launchpad.
dummy will already be imported by the base test suite, but you should
import local here.
https:/ /codereview. appspot. com/70190050/ diff/80001/ environs/ statepolicy. go statepolicy. go (right):
File environs/
https:/ /codereview. appspot. com/70190050/ diff/80001/ environs/ statepolicy. go#newcode43 statepolicy. go:43: if p, ok := (state. ConfigValidator ); ok {
environs/
provider.
No need for the assertion here, this is always going to be true for
Provider. Just go ahead and "return p, nil".
https:/ /codereview. appspot. com/70190050/ diff/80001/ juju/conn. go
File juju/conn.go (right):
https:/ /codereview. appspot. com/70190050/ diff/80001/ juju/conn. go#newcode146 interface{ } string] interface{ })
juju/conn.go:146: var secretAttrs map[string]
You need to initialise the map, like so:
secretAttrs := make(map[
https:/ /codereview. appspot. com/70190050/ diff/80001/ juju/conn. go#newcode153
juju/conn.go:153: secretAttrs[k] = v
This will panic, since you didn't initialise the map. I guess you didn't
run the tests after this change?
https:/ /codereview. appspot. com/70190050/ diff/80001/ juju/conn_ test.go
File juju/conn_test.go (right):
https:/ /codereview. appspot. com/70190050/ diff/80001/ juju/conn_ test.go# newcode153 test.go: 153: // UpdateEnvironConfig vaidates the config and validates/
juju/conn_
resets the "secret"
s/vaidates/
https:/ /codereview. appspot. com/70190050/ diff/80001/ juju/conn_ test.go# newcode154 test.go: 154: // setting.
juju/conn_
In normal circumstances it shouldn't be possible, but this is
specifically for a test. Not removing it completely misses the point of
the test: that if the attributes *aren't* in state, they will be added.
This is testing compatibility with legacy code.
Please put this back to how it was, using a nil policy to override the
removal prevention.
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/api/ common/ testing/ environwatcher. go common/ testing/ environwatcher. go (right):
File state/api/
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/api/ common/ testing/ environwatcher. go#newcode91 common/ testing/ environwatcher. go:91: // TODO [waigani] test
state/api/
removing an attribute.
^^
Adding the test could actually be useful here.
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/apiserver /keymanager/ keymanager. go /keymanager/ keymanager. go (right):
File state/apiserver
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/apiserver /keymanager/ keymanager. go#newcode151 /keymanager/ keymanager. go:151: err := UpdateEnvironCo nfig(attrs, nil, nil)
state/apiserver
api.state.
Can you please add a TODO to pass a validator that ensures the keys
haven't changed underfoot? This should have a sort of higher-level
transaction loop.
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/state. go
File state/state.go (left):
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/state. go#oldcode265
state/state.go:265: // TODO(axw) 2013-12-6 #1167616
Still not reinstated... did you forget to commit something?
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/state. go
File state/state.go (right):
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/state. go#newcode283 nfig. It seems onerous to have to check that you've got
state/state.go:283: return fmt.Errorf("both updateAttrs and removeAttrs
cannont be empty")
I'd be tempted just to return nil here, since there's nothing to do. It
could be easy to get into the situation where you compute a bunch of
changes to be made (add/modify/remove attributes) and then call
UpdateEnvironCo
no changes to make in each place.
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/state_ test.go
File state/state_test.go (left):
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/state_ test.go# oldcode1266 test.go: 1266: dation" function nfig.
state/state_
Please add a test that exercises the new "additionalVali
of UpdateEnvironCo
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/state_ test.go# oldcode1762 test.go: 1762: cfg, err := s.State. EnvironConfig( )
state/state_
Remind me why this was deleted please? It's still possible for someone
to come along and muck up the attributes in Mongo (e.g. with an buggy
script that modified the db directly), just not from within Juju.
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/state_ test.go
File state/state_test.go (right):
https:/ /codereview. appspot. com/70190050/ diff/80001/ state/state_ test.go# newcode1261 test.go: 1261: for k, v := range attrs {
state/state_
You've changed the test a bit. It's now checking that the modified
attributes are modified, but no longer checking that the existing
attributes are unmodified, and that no additional attributes were added.
I think what you should do is get the config first, do an nfig, merge the modified attributes with the existing
UpdateEnvironCo
config and then ensure that EnvironConfig() DeepEquals the merged
config.
https:/ /codereview. appspot. com/70190050/ diff/80001/ worker/ provisioner/ provisioner_ test.go provisioner/ provisioner_ test.go (left):
File worker/
https:/ /codereview. appspot. com/70190050/ diff/80001/ worker/ provisioner/ provisioner_ test.go# oldcode460 provisioner/ provisioner_ test.go: 460: defer stop(c, p)
worker/
Why are all these tests deleted? We can still have an invalid config at
the moment.
https:/ /codereview. appspot. com/70190050/ diff/80001/ worker/ provisioner/ provisioner_ test.go provisioner/ provisioner_ test.go (right):
File worker/
https:/ /codereview. appspot. com/70190050/ diff/80001/ worker/ provisioner/ provisioner_ test.go# newcode123 provisioner/ provisioner_ test.go: 123: c.Assert(err,
worker/
gc.ErrorMatches, `no registered provider for "unknown"`)
This needs to do what it was doing before. Nil policy.
https:/ /codereview. appspot. com/70190050/