Merge lp:~dave-cheney/juju-core/go-juju-update-environment into lp:~juju/juju-core/trunk

Proposed by Dave Cheney
Status: Rejected
Rejected by: Dave Cheney
Proposed branch: lp:~dave-cheney/juju-core/go-juju-update-environment
Merge into: lp:~juju/juju-core/trunk
Diff against target: 80 lines (+40/-1)
2 files modified
environs/open.go (+14/-1)
juju/conn.go (+26/-0)
To merge this branch: bzr merge lp:~dave-cheney/juju-core/go-juju-update-environment
Reviewer Review Type Date Requested Status
The Go Language Gophers Pending
Review via email: mp+116610@code.launchpad.net

Description of the change

juju: add UpdateEnvironConfig

This is not a proposal. This is an aide for the discussion
about pushing the secrets.

https://codereview.appspot.com/6445045/

To post a comment you must log in.
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

https://codereview.appspot.com/6445045/diff/1/environs/open.go
File environs/open.go (right):

https://codereview.appspot.com/6445045/diff/1/environs/open.go#newcode22
environs/open.go:22: // Config returns the *config.Config associated
with the environ
// Config returns the environment configuration with the given name.

https://codereview.appspot.com/6445045/diff/1/environs/open.go#newcode30
environs/open.go:30: }
p, ok := providers[config.Type()]
if !ok {
     return nil, fmt.Errorf("no registered provider for %q",
config.Type())
}
return p.Validate(e.config, nil)

https://codereview.appspot.com/6445045/

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :
328. By Dave Cheney

responding to review feedback

329. By Dave Cheney

gofmt

Unmerged revisions

329. By Dave Cheney

gofmt

328. By Dave Cheney

responding to review feedback

327. By Dave Cheney

proposal

326. By Gustavo Niemeyer

store: fix tests

R=rog
CC=
https://codereview.appspot.com/6419075

325. By William Reade

initial HookQueue implementation

Does not yet support saving/loading/reconciling state, but should correctly
handle all known situations in-memory, assuming a sane stream of added
RelationUnitsChange events.

R=niemeyer
CC=
https://codereview.appspot.com/6422049

324. By Roger Peppe

juju: add NewConnFromAttrs.

It's useful for testing Conns, apart from anything else.

R=TheMue, niemeyer
CC=
https://codereview.appspot.com/6422058

323. By Dave Cheney

cmd/juju: status: gather basic machine properties

This proposal adds the ability to gather basic machine
properties.

% juju status
machines:
  "0":
    dns-name: ec2-50-16-84-143.compute-1.amazonaws.com
    instance-id: i-0ea58c76
services: {}

nb. The key of the machines map is a string, not an int, which
is an incompatability with the current pythonic output. This
will be addressed shortly.

R=fwereade, niemeyer
CC=
https://codereview.appspot.com/6419069

322. By Gustavo Niemeyer

store: separate bzr stderr stream to avoid garbage

R=dfc
CC=
https://codereview.appspot.com/6431060

321. By William Reade

consistency of usage of state.Relations

ie:

(*State) AddRelation(...state.RelationEndpoint) (*Relation, error)
(*State) Relation(...state.RelationEndpoint) (*Relation, error)
(*State) RemoveRelation(*Relation) error

...and, also, RemoveService now:

* removes relations
* checks errors

R=niemeyer
CC=
https://codereview.appspot.com/6351123

320. By William Reade

Add RelationUnit type

This is kinda like the original RelationUnit proposed a few days ago, but
exposes its various bits of functionality separately rather than being a
magical watch-and-join chimera.

Notably, RelationUnitsWatcher is now exported, so the internal tests have
been dropped.

R=niemeyer
CC=
https://codereview.appspot.com/6430055

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/open.go'
2--- environs/open.go 2012-07-20 02:49:03 +0000
3+++ environs/open.go 2012-07-25 11:01:19 +0000
4@@ -14,6 +14,15 @@
5 return nil, fmt.Errorf("no default environment found")
6 }
7 }
8+ config, err := envs.Config(name)
9+ if err != nil {
10+ return nil, err
11+ }
12+ return New(config)
13+}
14+
15+// Config returns the environment configuration with the given name.
16+func (envs *Environs) Config(name string) (*config.Config, error) {
17 e, ok := envs.environs[name]
18 if !ok {
19 return nil, fmt.Errorf("unknown environment %q", name)
20@@ -21,7 +30,11 @@
21 if e.err != nil {
22 return nil, e.err
23 }
24- return New(e.config)
25+ p, ok := providers[e.config.Type()]
26+ if !ok {
27+ return nil, fmt.Errorf("no registered provider for %q", e.config.Type())
28+ }
29+ return p.Validate(e.config, nil)
30 }
31
32 // NewFromAttrs returns a new environment based on the provided configuration
33
34=== modified file 'juju/conn.go'
35--- juju/conn.go 2012-07-23 13:35:59 +0000
36+++ juju/conn.go 2012-07-25 11:01:19 +0000
37@@ -56,6 +56,7 @@
38
39 // State returns the environment state associated with c. Closing the
40 // obtained state will have undefined consequences; Close c instead.
41+// If required, the environment configuration will also be updated.
42 func (c *Conn) State() (*state.State, error) {
43 c.mu.Lock()
44 defer c.mu.Unlock()
45@@ -69,10 +70,35 @@
46 return nil, err
47 }
48 c.state = st
49+ if err := c.updateEnvironConfig(); err != nil {
50+ return nil, err
51+ }
52 }
53 return c.state, nil
54 }
55
56+// updateEnvironConfig updates the environment configuration in the state
57+// from the local configuration.
58+func (c *Conn) updateEnvironConfig() error {
59+ environs, err := environs.ReadEnvirons("")
60+ if err != nil {
61+ return err
62+ }
63+ config, err := environs.Config(c.Environ.Name())
64+ if err != nil {
65+ return err
66+ }
67+ env, err := c.state.EnvironConfig()
68+ if err != nil {
69+ return err
70+ }
71+ env.Update(config.AllAttrs())
72+ if _, err := env.Write(); err != nil {
73+ return err
74+ }
75+ return nil
76+}
77+
78 // Close terminates the connection to the environment and releases
79 // any associated resources.
80 func (c *Conn) Close() error {

Subscribers

People subscribed via source and target branches