Merge lp:~jameinel/juju-core/1.17-set-get-environment-compat-1253625 into lp:~go-bot/juju-core/trunk
Status: | Merged |
---|---|
Approved by: | John A Meinel |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2111 |
Proposed branch: | lp:~jameinel/juju-core/1.17-set-get-environment-compat-1253625 |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
104 lines (+67/-1) 1 file modified
cmd/juju/environment.go (+67/-1) |
To merge this branch: | bzr merge lp:~jameinel/juju-core/1.17-set-get-environment-compat-1253625 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+197059@code.launchpad.net |
Commit message
cmd/juju/
bug #1253625 is about "juju get-environment" and "juju
set-environment" not being compatible with a 1.16 API server because
Client.
So we fall back to direct DB access.
This replaces 'all' of SetEnvironment.Run because it has virtually no
other local logic. For GetEnvironment.Run we only replace the
EnvironmentGet step. (hence the different names for the functions.)
Description of the change
cmd/juju/
bug #1253625 is about "juju get-environment" and "juju
set-environment" not being compatible with a 1.16 API server because
Client.
So we fall back to direct DB access.
This replaces 'all' of SetEnvironment.Run because it has virtually no
other local logic. For GetEnvironment.Run we only replace the
EnvironmentGet step. (hence the different names for the functions.)
Reviewers: mp+197059_ code.launchpad. net,
Message:
Please take a look.
Description: environ. go: restore 1.16 compat
cmd/juju/
bug #1253625 is about "juju get-environment" and "juju EnvironmentGet and Client. EnvironmentSet were not available.
set-environment" not being compatible with a 1.16 API server because
Client.
So we fall back to direct DB access.
This replaces 'all' of SetEnvironment.Run because it has virtually no
other local logic. For GetEnvironment.Run we only replace the
EnvironmentGet step. (hence the different names for the functions.)
https:/ /code.launchpad .net/~jameinel/ juju-core/ 1.17-set- get-environment -compat- 1253625/ +merge/ 197059
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/34750043/
Affected files (+69, -1 lines): environment. go
A [revision details]
M cmd/juju/
Index: [revision details] 20131128093217- llqiq8yepsvtg5p y
=== 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: cmd/juju/ environment. go environment. go' environment. go 2013-11-06 10:51:34 +0000 environment. go 2013-11-28 12:52:51 +0000
=== modified file 'cmd/juju/
--- cmd/juju/
+++ cmd/juju/
@@ -11,6 +11,7 @@
"launchpad. net/juju- core/cmd" net/juju- core/juju" net/juju- core/rpc"
"launchpad.
+ "launchpad.
)
// GetEnvironmentC ommand is able to output either the entire environment or
@@ -53,6 +54,26 @@
return
}
+// environmentGet1 dot16 runs matches client. EnvironmentGet using a direct Command) environmentGet1 dot16() interface{ }, error) { mName(c. EnvName) EnvironConfig( ) Command) Run(ctx *cmd.Context) error { ntFromName( c.EnvName)
DB
+// connection to maintain compatibility with an API server running 1.16 or
+// older (when EnvironmentGet was not available). This fallback can be
removed
+// when we no longer maintain 1.16 compatibility.
+func (c *GetEnvironment
(map[string]
+ conn, err := juju.NewConnFro
+ if err != nil {
+ return nil, err
+ }
+ defer conn.Close()
+
+ // Get the existing environment config from the state.
+ config, err := conn.State.
+ if err != nil {
+ return nil, err
+ }
+ attrs := config.AllAttrs()
+ return attrs, nil
+}
+
func (c *GetEnvironment
client, err := juju.NewAPIClie
if err != nil {
@@ -61,6 +82,11 @@
defer client.Close()
attrs, err := client. EnvironmentGet( ) uest(err) { Infof(" EnvironmentGet not supported by the API server, " + t1dot16( )
+ if rpc.IsNoSuchReq
+ logger.
+ "falling back to 1.16 compatibility mode (direct DB access)")
+ attrs, err = c.environmentGe
+ }
if err != nil {
return err
}
@@ -124,6 +150,40 @@
return nil
}
+// run1dot16 runs matches client. EnvironmentSet using a direct DB ommand. Run in 1.16 Command) run1dot16() error {
+// connection to maintain compatibility with an API server running 1.16 or
+// older (when EnvironmentSet was not available). This fallback can be
removed
+// when we no longer maintain 1.16 compatibility.
+// This content was copied from SetEnvironmentC
+func (c *SetEnvironment
+ conn, err := juju.N...