Merge lp:~axwalk/juju-core/api-push-env-secrets-take2 into lp:~go-bot/juju-core/trunk
Status: | Merged |
---|---|
Approved by: | Andrew Wilkins |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2038 |
Proposed branch: | lp:~axwalk/juju-core/api-push-env-secrets-take2 |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
165 lines (+61/-5) 5 files modified
juju/api.go (+30/-2) juju/apiconn_test.go (+19/-1) juju/export_test.go (+1/-0) state/apiserver/client/client.go (+5/-2) state/apiserver/client/client_test.go (+6/-0) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/api-push-env-secrets-take2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+194288@code.launchpad.net |
Commit message
Push environment secrets after connecting API
This is a much simpler alternative to
https:/
implementing the same logic as is present
for the straight-to-state juju.NewConn.
As secrets-pushing will be obsoleted by
synchronous bootstrapping, which is slated
for introduction soon, I have a strong
preference for this option.
There's a drive-by-fix to the EnvironmentSet
API which simplifies testing: allow agent-version
in the parameters as long as it matches the
existing value.
Description of the change
Push environment secrets after connecting API
This is a much simpler alternative to
https:/
implementing the same logic as is present
for the straight-to-state juju.NewConn.
As secrets-pushing will be obsoleted by
synchronous bootstrapping, which is slated
for introduction soon, I have a strong
preference for this option.
There's a drive-by-fix to the EnvironmentSet
API which simplifies testing: allow agent-version
in the parameters as long as it matches the
existing value.
Reviewers: mp+194288_ code.launchpad. net,
Message:
Please take a look.
Description:
Push environment secrets after connecting API
This is a much simpler alternative to /codereview. appspot. com/22080044/,
https:/
implementing the same logic as is present
for the straight-to-state juju.NewConn.
As secrets-pushing will be obsoleted by
synchronous bootstrapping, which is slated
for introduction soon, I have a strong
preference for this option.
There's a drive-by-fix to the EnvironmentSet
API which simplifies testing: allow agent-version
in the parameters as long as it matches the
existing value.
https:/ /code.launchpad .net/~axwalk/ juju-core/ api-push- env-secrets- take2/+ merge/194288
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/22720043/
Affected files (+61, -4 lines): test.go /client/ client. go /client/ client_ test.go
A [revision details]
M juju/api.go
M juju/apiconn_
M juju/export_test.go
M state/apiserver
M state/apiserver
Index: [revision details] 20131106165607- vwv921qmnm416g1 0
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: juju/api.go environ, st); err != nil {
=== modified file 'juju/api.go'
--- juju/api.go 2013-10-24 18:44:46 +0000
+++ juju/api.go 2013-11-07 06:48:00 +0000
@@ -55,13 +55,40 @@
if err != nil {
return nil, err
}
- // TODO(rog): implement updateSecrets (see Conn.updateSecrets)
+ // TODO(axw) remove this once we have synchronous bootstrap.
+ if err := updateSecrets(
+ return nil, err
+ }
return &APIConn{
Environ: environ,
State: st,
}, nil
}
+// updateSecrets pushes environment secrets to the API server. Provider( ).SecretAttrs( environ. Config( )) EnvironmentGet( ) EnvironmentSet( cfg)
+// NOTE: this is a temporary hack, and will disappear when we
+// have synchronous bootstrap.
+var updateSecrets = func(environ environs.Environ, st *api.State) error {
+ secrets, err := environ.
+ if err != nil {
+ return err
+ }
+ client := st.Client()
+ cfg, err := client.
+ if err != nil {
+ return err
+ }
+ for k, v := range secrets {
+ if _, exists := cfg[k]; exists {
+ // Environment already has secrets. Won't send again.
+ return nil
+ } else {
+ cfg[k] = v
+ }
+ }
+ return client.
+}
+
// Close terminates the connection to the environment and releases
// any associated resources.
func (c *APIConn) Close() error {
Index: juju/apiconn_ test.go test.go' test.go 2013-10-24 19:01:23 +0000 test.go 2013-11-07 06:48:00 +0000 Bootstrap( env, constraints. Value{} )
=== modified file 'juju/apiconn_
--- juju/apiconn_
+++ juju/apiconn_
@@ -52,12 +52,22 @@
err = bootstrap.
c.Assert(err, gc.IsNil)
+ cfg = env.Config() map[string] interface{ }{ (env, api.DefaultDial Opts()) conn.Environ, gc.Equals, env) conn.State, gc.NotNil)
+ cfg, err = cfg.Apply(
+ "secret": "fnord",
+ })
+ c.Assert(err, gc.IsNil)
+ err = env.SetConfig(cfg)
+ c.Assert(err, gc.IsNil)
+
conn, err := juju.NewAPIConn
c.Assert(err, gc.IsNil)
-
c.Assert(
c.Assert(
...