| | state/*: login to /ENVUUID/api URLs This is an evolution of: https://codereview.appspot.com/101760046/ https://code.launchpad.net/~jameinel/juju-core/login-returns-env-tag/+merge/221021 Instead of having Login itself take an Environment Tag, it changes our API so that we connect to a different URL. Instead of "wss://address:host/" we now will try to connect to "wss://address:host/ENVUUID/api". The change itself involves a few variables: 1) A new dependency "github.com/bmizerany/pat", which is a reasonably simple library that lets you put in patterns to your http.Mux, which will then transform "/:path/foo" as matching anything in ":path" and adding that as a Query argument instead. 2) Using that library to expose /:environ/api and .../log, .../charms, .../tools. This patch itself doesn't make use of the new URLs, because it is not backwards compatible, and I didn't want to quite sort out how to do the backwards compatibility yet. 3) We do use the environ/api one when we know the Environment UUID, which Login will return for us (and we will cache). I did test that this still works against a 1.18 server (it connects to the /ENVUUID/api address, but as that is a child of / it still works). I also ran into something a bit surprising, but probably ok. If you actually force the environ-uuid to be invalid in your .jenv file, the code will try to connect, and fail with InvalidEnviron. However, our connection code has lots of resilience built in, so we end up just falling back to the Config fallback open, which naturally logs in as just environUUID="", which then finds the right environment UUID and caches it. So this code doesn't fix all possible paths, but I think it improves the state of the world that I'd like to land it and get back to API versioning. https://code.launchpad.net/~jameinel/juju-core/login-env-urls/+merge/221632 (do not edit description out of merge proposal) Total comments: 18 | Unified diffs | Side-by-side diffs | Delta from patch set | Stats (+801 lines, -94 lines) | Patch |  | A | [revision details] | View | 1 | 1 chunk | +2 lines, -0 lines | 0 comments | Download |  | M | dependencies.tsv | View | 1 | 1 chunk | +1 line, -0 lines | 0 comments | Download |  | M | environs/configstore/disk.go | View | | 3 chunks | +5 lines, -2 lines | 0 comments | Download |  | M | environs/configstore/interface.go | View | | 1 chunk | +4 lines, -0 lines | 2 comments | Download |  | M | environs/configstore/interface_test.go | View | | 2 chunks | +6 lines, -4 lines | 0 comments | Download |  | M | juju/api.go | View | 1 | 7 chunks | +42 lines, -14 lines | 0 comments | Download |  | M | juju/apiconn_test.go | View | | 8 chunks | +139 lines, -3 lines | 0 comments | Download |  | M | juju/mock_test.go | View | | 2 chunks | +5 lines, -0 lines | 0 comments | Download |  | M | state/api/apiclient.go | View | 1 | 9 chunks | +41 lines, -6 lines | 2 comments | Download |  | M | state/api/apiclient_test.go | View | 1 | 4 chunks | +49 lines, -1 line | 0 comments | Download |  | M | state/api/client_test.go | View | | 3 chunks | +69 lines, -6 lines | 0 comments | Download |  | M | state/api/export_test.go | View | | 1 chunk | +1 line, -0 lines | 2 comments | Download |  | M | state/api/params/params.go | View | 1 | 1 chunk | +2 lines, -1 line | 0 comments | Download |  | M | state/api/state.go | View | | 1 chunk | +1 line, -0 lines | 0 comments | Download |  | M | state/api/state_test.go | View | | 2 chunks | +21 lines, -0 lines | 0 comments | Download |  | M | state/apiserver/admin.go | View | | 2 chunks | +21 lines, -1 line | 0 comments | Download |  | M | state/apiserver/apiserver.go | View | 1 | 6 chunks | +73 lines, -15 lines | 8 comments | Download |  | M | state/apiserver/charms.go | View | | 1 chunk | +4 lines, -0 lines | 0 comments | Download |  | M | state/apiserver/charms_test.go | View | | 4 chunks | +93 lines, -3 lines | 0 comments | Download |  | M | state/apiserver/common/errors.go | View | | 2 chunks | +2 lines, -0 lines | 2 comments | Download |  | M | state/apiserver/debuglog.go | View | | 1 chunk | +5 lines, -0 lines | 0 comments | Download |  | M | state/apiserver/debuglog_test.go | View | | 5 chunks | +54 lines, -13 lines | 0 comments | Download |  | M | state/apiserver/export_test.go | View | | 1 chunk | +4 lines, -0 lines | 0 comments | Download |  | M | state/apiserver/httphandler.go | View | | 1 chunk | +25 lines, -0 lines | 2 comments | Download |  | M | state/apiserver/login_test.go | View | | 3 chunks | +30 lines, -5 lines | 0 comments | Download |  | M | state/apiserver/root_test.go | View | | 2 chunks | +28 lines, -0 lines | 0 comments | Download |  | M | state/apiserver/tools.go | View | | 1 chunk | +4 lines, -0 lines | 0 comments | Download |  | M | state/apiserver/tools_test.go | View | | 4 chunks | +70 lines, -20 lines | 0 comments | Download | Total messages: 6 |