Merge lp:~fwereade/juju-core/move-hook-context into lp:~juju/juju-core/trunk

Proposed by William Reade
Status: Work in progress
Proposed branch: lp:~fwereade/juju-core/move-hook-context
Merge into: lp:~juju/juju-core/trunk
Diff against target: 1205 lines (+151/-154)
25 files modified
cmd/jujuc/server/server_test.go (+6/-0)
worker/uniter/hook/config-get.go (+4/-4)
worker/uniter/hook/config-get_test.go (+7/-7)
worker/uniter/hook/context.go (+13/-16)
worker/uniter/hook/context_test.go (+14/-14)
worker/uniter/hook/hook_test.go (+3/-2)
worker/uniter/hook/juju-log.go (+4/-4)
worker/uniter/hook/juju-log_test.go (+7/-7)
worker/uniter/hook/ports.go (+8/-8)
worker/uniter/hook/ports_test.go (+5/-5)
worker/uniter/hook/relation-get.go (+4/-4)
worker/uniter/hook/relation-get_test.go (+8/-8)
worker/uniter/hook/relation-ids.go (+4/-4)
worker/uniter/hook/relation-ids_test.go (+9/-9)
worker/uniter/hook/relation-list.go (+4/-4)
worker/uniter/hook/relation-list_test.go (+7/-7)
worker/uniter/hook/relation-set.go (+4/-4)
worker/uniter/hook/relation-set_test.go (+8/-8)
worker/uniter/hook/unit-get.go (+4/-4)
worker/uniter/hook/unit-get_test.go (+8/-8)
worker/uniter/hook/util_test.go (+11/-17)
worker/uniter/relationer.go (+4/-5)
worker/uniter/tools.go (+2/-2)
worker/uniter/tools_test.go (+2/-2)
worker/uniter/uniter.go (+1/-1)
To merge this branch: bzr merge lp:~fwereade/juju-core/move-hook-context
Reviewer Review Type Date Requested Status
The Go Language Gophers Pending
Review via email: mp+127227@code.launchpad.net

Description of the change

server: move non-servery bits to hook

NOTE: CRACK. Most of it still needs to move, but hook isn't quite the right
place. Working out where it should really go before proposing.

The only remaining bit of server is Server; the contexts and commands have
moved to hook, and HookContext became plain Context, while other names were
left as-is.

I am almost entirely certain that more steps will be required after this
before we hit on the right place/name/shape for everything, but I am also
confident that this is a step in a good direction.

https://codereview.appspot.com/6596048/

To post a comment you must log in.
Revision history for this message
William Reade (fwereade) wrote :

Reviewers: mp+127227_code.launchpad.net,

Message:
Please take a look.

Description:
server: move non-servery bits to hook

The only remaining bit of server is Server; the contexts and commands
have
moved to hook, and HookContext became plain Context, while other names
were
left as-is.

I am almost entirely certain that more steps will be required after this
before we hit on the right place/name/shape for everything, but I am
also
confident that this is a step in a good direction.

https://code.launchpad.net/~fwereade/juju-core/move-hook-context/+merge/127227

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/6596048/

Affected files:
   A [revision details]
   M cmd/jujuc/server/server_test.go
   M worker/uniter/hook/config-get.go
   M worker/uniter/hook/config-get_test.go
   M worker/uniter/hook/context.go
   M worker/uniter/hook/context_test.go
   M worker/uniter/hook/hook_test.go
   M worker/uniter/hook/juju-log.go
   M worker/uniter/hook/juju-log_test.go
   M worker/uniter/hook/ports.go
   M worker/uniter/hook/ports_test.go
   M worker/uniter/hook/relation-get.go
   M worker/uniter/hook/relation-get_test.go
   M worker/uniter/hook/relation-ids.go
   M worker/uniter/hook/relation-ids_test.go
   M worker/uniter/hook/relation-list.go
   M worker/uniter/hook/relation-list_test.go
   M worker/uniter/hook/relation-set.go
   M worker/uniter/hook/relation-set_test.go
   M worker/uniter/hook/unit-get.go
   M worker/uniter/hook/unit-get_test.go
   M worker/uniter/hook/util_test.go
   M worker/uniter/relationer.go
   M worker/uniter/tools.go
   M worker/uniter/tools_test.go
   M worker/uniter/uniter.go

Revision history for this message
Roger Peppe (rogpeppe) wrote :

On 2012/10/01 10:24:34, fwereade wrote:
> Please take a look.

LGTM. hook.Context seems right.

https://codereview.appspot.com/6596048/

Unmerged revisions

605. By William Reade

move most of cmd/jujuc/server to worker/uniter/hook

604. By Dave Cheney

cmd/juju: add scp subcommand

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

603. By William Reade

state: add CharmURL() to Service

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

602. By William Reade

uniter: faster tests

In each case, without regular StartSyncing, the Uniter just hangs around
waiting for events that... well, they come sooner or later, and the timeouts
are long so the tests are reliable. But I think that, in the interests of
sanity, it's better to make the environment unrealistically eager.

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

601. By Gustavo Niemeyer

state,worker: full lifecycle machines watcher

MachinesWatcher now returns a list of ids that have had their
lifecycle changed in any way. It's up to the consumer to work
out details.

R=TheMue, aram
CC=
https://codereview.appspot.com/6566066

600. By Roger Peppe

version: add Build number

This will be used to implement upgrade --bump-version.

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

599. By Roger Peppe

machiner: eat provisioner and firewaller for lunch

Three in one.

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

598. By Roger Peppe

cmd/jujud: allow for a clean exit

When a unit or a machine dies, we want the
unit or machine agent to exit cleanly, so
prepare for the worker to return ErrDead in that
case, and exit cleanly when the unit or machine
is dead to start with.

Reviewed at https://codereview.appspot.com/6567067/.

R=
CC=
https://codereview.appspot.com/6574060

597. By Roger Peppe

cmd/jujud: implement uniter upgrade

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

596. By Roger Peppe

worker/uniter: better error messages

Changed after experiencing difficult-to-understand
messages. Hopefully they're a little more self-explanatory
now.

R=fwereade
CC=
https://codereview.appspot.com/6568064

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmd/jujuc/server/server_test.go'
2--- cmd/jujuc/server/server_test.go 2012-08-18 09:09:37 +0000
3+++ cmd/jujuc/server/server_test.go 2012-10-01 10:27:24 +0000
4@@ -8,13 +8,19 @@
5 . "launchpad.net/gocheck"
6 "launchpad.net/juju-core/cmd"
7 "launchpad.net/juju-core/cmd/jujuc/server"
8+ coretesting "launchpad.net/juju-core/testing"
9 "net/rpc"
10 "os"
11 "path/filepath"
12 "sync"
13+ stdtesting "testing"
14 "time"
15 )
16
17+func TestPackage(t *stdtesting.T) {
18+ coretesting.MgoTestPackage(t)
19+}
20+
21 type RpcCommand struct {
22 Value string
23 Slow bool
24
25=== renamed file 'cmd/jujuc/server/config-get.go' => 'worker/uniter/hook/config-get.go'
26--- cmd/jujuc/server/config-get.go 2012-07-31 21:36:59 +0000
27+++ worker/uniter/hook/config-get.go 2012-10-01 10:27:24 +0000
28@@ -1,4 +1,4 @@
29-package server
30+package hook
31
32 import (
33 "launchpad.net/gnuflag"
34@@ -7,13 +7,13 @@
35
36 // ConfigGetCommand implements the config-get command.
37 type ConfigGetCommand struct {
38- *HookContext
39+ *Context
40 Key string // The key to show. If empty, show all.
41 out cmd.Output
42 }
43
44-func NewConfigGetCommand(ctx *HookContext) (cmd.Command, error) {
45- return &ConfigGetCommand{HookContext: ctx}, nil
46+func NewConfigGetCommand(ctx *Context) (cmd.Command, error) {
47+ return &ConfigGetCommand{Context: ctx}, nil
48 }
49
50 func (c *ConfigGetCommand) Info() *cmd.Info {
51
52=== renamed file 'cmd/jujuc/server/config-get_test.go' => 'worker/uniter/hook/config-get_test.go'
53--- cmd/jujuc/server/config-get_test.go 2012-07-31 21:36:59 +0000
54+++ worker/uniter/hook/config-get_test.go 2012-10-01 10:27:24 +0000
55@@ -1,4 +1,4 @@
56-package server_test
57+package hook_test
58
59 import (
60 "io/ioutil"
61@@ -8,13 +8,13 @@
62 )
63
64 type ConfigGetSuite struct {
65- HookContextSuite
66+ ContextSuite
67 }
68
69 var _ = Suite(&ConfigGetSuite{})
70
71 func (s *ConfigGetSuite) SetUpTest(c *C) {
72- s.HookContextSuite.SetUpTest(c)
73+ s.ContextSuite.SetUpTest(c)
74 conf, err := s.service.Config()
75 c.Assert(err, IsNil)
76 conf.Update(map[string]interface{}{
77@@ -47,7 +47,7 @@
78 func (s *ConfigGetSuite) TestOutputFormat(c *C) {
79 for i, t := range configGetTests {
80 c.Logf("test %d: %#v", i, t.args)
81- hctx := s.GetHookContext(c, -1, "")
82+ hctx := s.GetContext(c, -1, "")
83 com, err := hctx.NewCommand("config-get")
84 c.Assert(err, IsNil)
85 ctx := dummyContext(c)
86@@ -59,7 +59,7 @@
87 }
88
89 func (s *ConfigGetSuite) TestHelp(c *C) {
90- hctx := s.GetHookContext(c, -1, "")
91+ hctx := s.GetContext(c, -1, "")
92 com, err := hctx.NewCommand("config-get")
93 c.Assert(err, IsNil)
94 ctx := dummyContext(c)
95@@ -80,7 +80,7 @@
96 }
97
98 func (s *ConfigGetSuite) TestOutputPath(c *C) {
99- hctx := s.GetHookContext(c, -1, "")
100+ hctx := s.GetContext(c, -1, "")
101 com, err := hctx.NewCommand("config-get")
102 c.Assert(err, IsNil)
103 ctx := dummyContext(c)
104@@ -94,7 +94,7 @@
105 }
106
107 func (s *ConfigGetSuite) TestUnknownArg(c *C) {
108- hctx := s.GetHookContext(c, -1, "")
109+ hctx := s.GetContext(c, -1, "")
110 com, err := hctx.NewCommand("config-get")
111 c.Assert(err, IsNil)
112 err = com.Init(dummyFlagSet(), []string{"multiple", "keys"})
113
114=== renamed file 'cmd/jujuc/server/context.go' => 'worker/uniter/hook/context.go'
115--- cmd/jujuc/server/context.go 2012-09-24 11:59:53 +0000
116+++ worker/uniter/hook/context.go 2012-10-01 10:27:24 +0000
117@@ -1,7 +1,4 @@
118-// The cmd/jujuc/server package implements the server side of the jujuc proxy
119-// tool, which forwards command invocations to the unit agent process so that
120-// they can be executed against specific state.
121-package server
122+package hook
123
124 import (
125 "bufio"
126@@ -20,12 +17,12 @@
127 "time"
128 )
129
130-// HookContext is responsible for the state against which a jujuc-forwarded
131+// Context is responsible for the state against which a jujuc-forwarded
132 // command will execute within a unit agent; it implements the core of the
133 // various jujuc tools, and is involved in constructing a suitable shell
134 // environment in which to execute a hook (which is likely to call jujuc
135-// tools that need this specific HookContext).
136-type HookContext struct {
137+// tools that need this specific Context).
138+type Context struct {
139 Service *state.Service
140 Unit *state.Unit
141
142@@ -48,7 +45,7 @@
143 }
144
145 // newCommands maps Command names to initializers.
146-var newCommands = map[string]func(*HookContext) (cmd.Command, error){
147+var newCommands = map[string]func(*Context) (cmd.Command, error){
148 "close-port": NewClosePortCommand,
149 "config-get": NewConfigGetCommand,
150 "juju-log": NewJujuLogCommand,
151@@ -70,8 +67,8 @@
152 }
153
154 // NewCommand returns an instance of the named Command, initialized to execute
155-// against this HookContext.
156-func (ctx *HookContext) NewCommand(name string) (cmd.Command, error) {
157+// against this Context.
158+func (ctx *Context) NewCommand(name string) (cmd.Command, error) {
159 f := newCommands[name]
160 if f == nil {
161 return nil, fmt.Errorf("unknown command: %s", name)
162@@ -82,7 +79,7 @@
163 // hookVars returns an os.Environ-style list of strings necessary to run a hook
164 // such that it can know what environment it's operating in, and can call back
165 // into ctx.
166-func (ctx *HookContext) hookVars(charmDir, toolsDir, socketPath string) []string {
167+func (ctx *Context) hookVars(charmDir, toolsDir, socketPath string) []string {
168 vars := []string{
169 "APT_LISTCHANGES_FRONTEND=none",
170 "DEBIAN_FRONTEND=noninteractive",
171@@ -104,7 +101,7 @@
172
173 // RunHook executes a hook in an environment which allows it to to call back
174 // into ctx to execute jujuc tools.
175-func (ctx *HookContext) RunHook(hookName, charmDir, toolsDir, socketPath string) error {
176+func (ctx *Context) RunHook(hookName, charmDir, toolsDir, socketPath string) error {
177 ps := exec.Command(filepath.Join(charmDir, "hooks", hookName))
178 ps.Env = ctx.hookVars(charmDir, toolsDir, socketPath)
179 ps.Dir = charmDir
180@@ -194,7 +191,7 @@
181 // envRelation returns the relation name exposed to hooks as JUJU_RELATION.
182 // If the context does not have a relation, it will return an empty string.
183 // Otherwise, it will panic if RelationId is not a key in the Relations map.
184-func (ctx *HookContext) envRelation() string {
185+func (ctx *Context) envRelation() string {
186 if ctx.RelationId == -1 {
187 return ""
188 }
189@@ -204,7 +201,7 @@
190 // envRelationId returns the relation id exposed to hooks as JUJU_RELATION_ID.
191 // If the context does not have a relation, it will return an empty string.
192 // Otherwise, it will panic if RelationId is not a key in the Relations map.
193-func (ctx *HookContext) envRelationId() string {
194+func (ctx *Context) envRelationId() string {
195 if ctx.RelationId == -1 {
196 return ""
197 }
198@@ -322,7 +319,7 @@
199
200 // relationIdValue returns a gnuflag.Value for convenient parsing of relation
201 // ids in context.
202-func (ctx *HookContext) relationIdValue(result *int) *relationIdValue {
203+func (ctx *Context) relationIdValue(result *int) *relationIdValue {
204 *result = ctx.RelationId
205 return &relationIdValue{result: result, ctx: ctx, value: ctx.envRelationId()}
206 }
207@@ -330,7 +327,7 @@
208 // relationIdValue implements gnuflag.Value for use in relation hook commands.
209 type relationIdValue struct {
210 result *int
211- ctx *HookContext
212+ ctx *Context
213 value string
214 }
215
216
217=== renamed file 'cmd/jujuc/server/context_test.go' => 'worker/uniter/hook/context_test.go'
218--- cmd/jujuc/server/context_test.go 2012-09-24 21:19:46 +0000
219+++ worker/uniter/hook/context_test.go 2012-10-01 10:27:24 +0000
220@@ -1,14 +1,14 @@
221-package server_test
222+package hook_test
223
224 import (
225 "fmt"
226 "io/ioutil"
227 . "launchpad.net/gocheck"
228 "launchpad.net/juju-core/charm"
229- "launchpad.net/juju-core/cmd/jujuc/server"
230 "launchpad.net/juju-core/juju/testing"
231 "launchpad.net/juju-core/log"
232 "launchpad.net/juju-core/state"
233+ "launchpad.net/juju-core/worker/uniter/hook"
234 "os"
235 "path/filepath"
236 "strings"
237@@ -16,7 +16,7 @@
238 )
239
240 type GetCommandSuite struct {
241- HookContextSuite
242+ ContextSuite
243 }
244
245 var _ = Suite(&GetCommandSuite{})
246@@ -36,7 +36,7 @@
247 }
248
249 func (s *GetCommandSuite) TestGetCommand(c *C) {
250- ctx := s.GetHookContext(c, 0, "")
251+ ctx := s.GetContext(c, 0, "")
252 for _, t := range getCommandTests {
253 com, err := ctx.NewCommand(t.name)
254 if t.err == "" {
255@@ -52,7 +52,7 @@
256 }
257
258 type RunHookSuite struct {
259- HookContextSuite
260+ ContextSuite
261 }
262
263 var _ = Suite(&RunHookSuite{})
264@@ -244,7 +244,7 @@
265 log.Target = logger
266 for i, t := range runHookTests {
267 c.Logf("test %d: %s; perm %v", i, t.summary, t.spec.perm)
268- ctx := s.GetHookContext(c, t.relid, t.remote)
269+ ctx := s.GetContext(c, t.relid, t.remote)
270 var charmDir, outPath string
271 if t.spec.perm == 0 {
272 charmDir = c.MkDir()
273@@ -299,7 +299,7 @@
274
275 func (s *RunHookSuite) TestRunHookRelationFlushing(c *C) {
276 // Create a charm with a breaking hook.
277- ctx := s.GetHookContext(c, -1, "")
278+ ctx := s.GetContext(c, -1, "")
279 charmDir, _ := makeCharm(c, hookSpec{
280 name: "something-happened",
281 perm: 0700,
282@@ -401,11 +401,11 @@
283 }
284
285 func (s *RelationContextSuite) TestChangeMembers(c *C) {
286- ctx := server.NewRelationContext(s.ru, nil)
287+ ctx := hook.NewRelationContext(s.ru, nil)
288 c.Assert(ctx.Units(), HasLen, 0)
289
290 // Check the units and settings after a simple update.
291- ctx.UpdateMembers(server.SettingsMap{
292+ ctx.UpdateMembers(hook.SettingsMap{
293 "u/2": {"baz": 2},
294 "u/4": {"qux": 4},
295 })
296@@ -419,7 +419,7 @@
297 assertSettings("u/4", map[string]interface{}{"qux": 4})
298
299 // Send a second update; check that members are only added, not removed.
300- ctx.UpdateMembers(server.SettingsMap{
301+ ctx.UpdateMembers(hook.SettingsMap{
302 "u/1": {"foo": 1},
303 "u/2": nil,
304 "u/3": {"bar": 3},
305@@ -452,7 +452,7 @@
306 node.Set("ping", "pong")
307 _, err = node.Write()
308 c.Assert(err, IsNil)
309- ctx := server.NewRelationContext(s.ru, map[string]int64{"u/1": 0})
310+ ctx := hook.NewRelationContext(s.ru, map[string]int64{"u/1": 0})
311
312 // Check that uncached settings are read from state.
313 settings, err := ctx.ReadSettings("u/1")
314@@ -476,7 +476,7 @@
315
316 // Check that updating the context overwrites the cached settings, and
317 // that the contents of state are ignored.
318- ctx.UpdateMembers(server.SettingsMap{"u/1": {"entirely": "different"}})
319+ ctx.UpdateMembers(hook.SettingsMap{"u/1": {"entirely": "different"}})
320 settings, err = ctx.ReadSettings("u/1")
321 c.Assert(err, IsNil)
322 c.Assert(settings, DeepEquals, map[string]interface{}{"entirely": "different"})
323@@ -492,7 +492,7 @@
324 node.Set("ping", "pong")
325 _, err = node.Write()
326 c.Assert(err, IsNil)
327- ctx := server.NewRelationContext(s.ru, nil)
328+ ctx := hook.NewRelationContext(s.ru, nil)
329
330 // Check that settings are read from state.
331 settings, err := ctx.ReadSettings("u/1")
332@@ -517,7 +517,7 @@
333 }
334
335 func (s *RelationContextSuite) TestSettings(c *C) {
336- ctx := server.NewRelationContext(s.ru, nil)
337+ ctx := hook.NewRelationContext(s.ru, nil)
338
339 // Change Settings, then clear cache without writing.
340 node, err := ctx.Settings()
341
342=== modified file 'worker/uniter/hook/hook_test.go'
343--- worker/uniter/hook/hook_test.go 2012-09-05 10:28:06 +0000
344+++ worker/uniter/hook/hook_test.go 2012-10-01 10:27:24 +0000
345@@ -2,12 +2,13 @@
346
347 import (
348 . "launchpad.net/gocheck"
349+ coretesting "launchpad.net/juju-core/testing"
350 "launchpad.net/juju-core/worker/uniter/hook"
351 "testing"
352 )
353
354-func Test(t *testing.T) {
355- TestingT(t)
356+func TestPackage(t *testing.T) {
357+ coretesting.MgoTestPackage(t)
358 }
359
360 type InfoSuite struct{}
361
362=== renamed file 'cmd/jujuc/server/juju-log.go' => 'worker/uniter/hook/juju-log.go'
363--- cmd/jujuc/server/juju-log.go 2012-08-06 16:41:17 +0000
364+++ worker/uniter/hook/juju-log.go 2012-10-01 10:27:24 +0000
365@@ -1,4 +1,4 @@
366-package server
367+package hook
368
369 import (
370 "errors"
371@@ -10,13 +10,13 @@
372
373 // JujuLogCommand implements the juju-log command.
374 type JujuLogCommand struct {
375- *HookContext
376+ *Context
377 Message string
378 Debug bool
379 }
380
381-func NewJujuLogCommand(ctx *HookContext) (cmd.Command, error) {
382- return &JujuLogCommand{HookContext: ctx}, nil
383+func NewJujuLogCommand(ctx *Context) (cmd.Command, error) {
384+ return &JujuLogCommand{Context: ctx}, nil
385 }
386
387 func (c *JujuLogCommand) Info() *cmd.Info {
388
389=== renamed file 'cmd/jujuc/server/juju-log_test.go' => 'worker/uniter/hook/juju-log_test.go'
390--- cmd/jujuc/server/juju-log_test.go 2012-08-01 15:48:38 +0000
391+++ worker/uniter/hook/juju-log_test.go 2012-10-01 10:27:24 +0000
392@@ -1,4 +1,4 @@
393-package server_test
394+package hook_test
395
396 import (
397 "bytes"
398@@ -7,13 +7,13 @@
399 "launchpad.net/gnuflag"
400 . "launchpad.net/gocheck"
401 "launchpad.net/juju-core/cmd"
402- "launchpad.net/juju-core/cmd/jujuc/server"
403 "launchpad.net/juju-core/log"
404+ "launchpad.net/juju-core/worker/uniter/hook"
405 stdlog "log"
406 )
407
408 type JujuLogSuite struct {
409- HookContextSuite
410+ ContextSuite
411 }
412
413 var _ = Suite(&JujuLogSuite{})
414@@ -44,7 +44,7 @@
415 {true, true, "JUJU:DEBUG"},
416 }
417
418-func assertLogs(c *C, ctx *server.HookContext, badge string) {
419+func assertLogs(c *C, ctx *hook.Context, badge string) {
420 msg1 := "the chickens"
421 msg2 := "are 110% AWESOME"
422 com, err := ctx.NewCommand("juju-log")
423@@ -72,14 +72,14 @@
424 }
425
426 func (s *JujuLogSuite) TestBadges(c *C) {
427- hctx := s.GetHookContext(c, -1, "")
428+ hctx := s.GetContext(c, -1, "")
429 assertLogs(c, hctx, "u/0")
430- hctx = s.GetHookContext(c, 1, "u/1")
431+ hctx = s.GetContext(c, 1, "u/1")
432 assertLogs(c, hctx, "u/0 peer1:1")
433 }
434
435 func (s *JujuLogSuite) TestRequiresMessage(c *C) {
436- ctx := &server.HookContext{}
437+ ctx := &hook.Context{}
438 com, err := ctx.NewCommand("juju-log")
439 c.Assert(err, IsNil)
440 err = com.Init(dummyFlagSet(), nil)
441
442=== renamed file 'cmd/jujuc/server/ports.go' => 'worker/uniter/hook/ports.go'
443--- cmd/jujuc/server/ports.go 2012-07-30 14:30:00 +0000
444+++ worker/uniter/hook/ports.go 2012-10-01 10:27:24 +0000
445@@ -1,4 +1,4 @@
446-package server
447+package hook
448
449 import (
450 "errors"
451@@ -13,7 +13,7 @@
452
453 // portCommand implements the open-port and close-port commands.
454 type portCommand struct {
455- *HookContext
456+ *Context
457 info *cmd.Info
458 action func(*portCommand) error
459 Protocol string
460@@ -68,10 +68,10 @@
461 "The port will only be open while the service is exposed.",
462 }
463
464-func NewOpenPortCommand(ctx *HookContext) (cmd.Command, error) {
465+func NewOpenPortCommand(ctx *Context) (cmd.Command, error) {
466 return &portCommand{
467- HookContext: ctx,
468- info: openPortInfo,
469+ Context: ctx,
470+ info: openPortInfo,
471 action: func(c *portCommand) error {
472 return c.Unit.OpenPort(c.Protocol, c.Port)
473 },
474@@ -82,10 +82,10 @@
475 "close-port", portFormat, "ensure a port is always closed", "",
476 }
477
478-func NewClosePortCommand(ctx *HookContext) (cmd.Command, error) {
479+func NewClosePortCommand(ctx *Context) (cmd.Command, error) {
480 return &portCommand{
481- HookContext: ctx,
482- info: closePortInfo,
483+ Context: ctx,
484+ info: closePortInfo,
485 action: func(c *portCommand) error {
486 return c.Unit.ClosePort(c.Protocol, c.Port)
487 },
488
489=== renamed file 'cmd/jujuc/server/ports_test.go' => 'worker/uniter/hook/ports_test.go'
490--- cmd/jujuc/server/ports_test.go 2012-09-21 18:56:01 +0000
491+++ worker/uniter/hook/ports_test.go 2012-10-01 10:27:24 +0000
492@@ -1,4 +1,4 @@
493-package server_test
494+package hook_test
495
496 import (
497 . "launchpad.net/gocheck"
498@@ -7,7 +7,7 @@
499 )
500
501 type PortsSuite struct {
502- HookContextSuite
503+ ContextSuite
504 }
505
506 var _ = Suite(&PortsSuite{})
507@@ -25,7 +25,7 @@
508
509 func (s *PortsSuite) TestOpenClose(c *C) {
510 for _, t := range portsTests {
511- hctx := s.GetHookContext(c, -1, "")
512+ hctx := s.GetContext(c, -1, "")
513 com, err := hctx.NewCommand(t.cmd[0])
514 c.Assert(err, IsNil)
515 ctx := dummyContext(c)
516@@ -54,7 +54,7 @@
517 func (s *PortsSuite) TestBadArgs(c *C) {
518 for _, name := range []string{"open-port", "close-port"} {
519 for _, t := range badPortsTests {
520- hctx := s.GetHookContext(c, -1, "")
521+ hctx := s.GetContext(c, -1, "")
522 com, err := hctx.NewCommand(name)
523 c.Assert(err, IsNil)
524 err = com.Init(dummyFlagSet(), t.args)
525@@ -64,7 +64,7 @@
526 }
527
528 func (s *PortsSuite) TestHelp(c *C) {
529- hctx := s.GetHookContext(c, -1, "")
530+ hctx := s.GetContext(c, -1, "")
531 open, err := hctx.NewCommand("open-port")
532 c.Assert(err, IsNil)
533 c.Assert(string(open.Info().Help(dummyFlagSet())), Equals, `
534
535=== renamed file 'cmd/jujuc/server/relation-get.go' => 'worker/uniter/hook/relation-get.go'
536--- cmd/jujuc/server/relation-get.go 2012-08-07 14:22:28 +0000
537+++ worker/uniter/hook/relation-get.go 2012-10-01 10:27:24 +0000
538@@ -1,4 +1,4 @@
539-package server
540+package hook
541
542 import (
543 "fmt"
544@@ -8,15 +8,15 @@
545
546 // RelationGetCommand implements the relation-get command.
547 type RelationGetCommand struct {
548- *HookContext
549+ *Context
550 RelationId int
551 Key string
552 UnitName string
553 out cmd.Output
554 }
555
556-func NewRelationGetCommand(ctx *HookContext) (cmd.Command, error) {
557- return &RelationGetCommand{HookContext: ctx}, nil
558+func NewRelationGetCommand(ctx *Context) (cmd.Command, error) {
559+ return &RelationGetCommand{Context: ctx}, nil
560 }
561
562 func (c *RelationGetCommand) Info() *cmd.Info {
563
564=== renamed file 'cmd/jujuc/server/relation-get_test.go' => 'worker/uniter/hook/relation-get_test.go'
565--- cmd/jujuc/server/relation-get_test.go 2012-08-10 12:33:38 +0000
566+++ worker/uniter/hook/relation-get_test.go 2012-10-01 10:27:24 +0000
567@@ -1,16 +1,16 @@
568-package server_test
569+package hook_test
570
571 import (
572 "fmt"
573 "io/ioutil"
574 . "launchpad.net/gocheck"
575 "launchpad.net/juju-core/cmd"
576- "launchpad.net/juju-core/cmd/jujuc/server"
577+ "launchpad.net/juju-core/worker/uniter/hook"
578 "path/filepath"
579 )
580
581 type RelationGetSuite struct {
582- HookContextSuite
583+ ContextSuite
584 }
585
586 var _ = Suite(&RelationGetSuite{})
587@@ -153,14 +153,14 @@
588 }
589
590 func (s *RelationGetSuite) SetUpTest(c *C) {
591- s.HookContextSuite.SetUpTest(c)
592+ s.ContextSuite.SetUpTest(c)
593 // Perturb local settings for relation 0.
594 node, err := s.relctxs[0].Settings()
595 c.Assert(err, IsNil)
596 node.Set("private-address", "foo: bar\n")
597
598 // Add some member settings for a "member" in relation 1.
599- s.relctxs[1].UpdateMembers(server.SettingsMap{
600+ s.relctxs[1].UpdateMembers(hook.SettingsMap{
601 "m/0": map[string]interface{}{"pew": "pew\npew\n"},
602 })
603
604@@ -175,7 +175,7 @@
605 func (s *RelationGetSuite) TestRelationGet(c *C) {
606 for i, t := range relationGetTests {
607 c.Logf("test %d: %s", i, t.summary)
608- hctx := s.GetHookContext(c, t.relid, t.unit)
609+ hctx := s.GetContext(c, t.relid, t.unit)
610 com, err := hctx.NewCommand("relation-get")
611 c.Assert(err, IsNil)
612 ctx := dummyContext(c)
613@@ -240,7 +240,7 @@
614 func (s *RelationGetSuite) TestHelp(c *C) {
615 for i, t := range relationGetHelpTests {
616 c.Logf("test %d", i)
617- hctx := s.GetHookContext(c, t.relid, t.unit)
618+ hctx := s.GetContext(c, t.relid, t.unit)
619 com, err := hctx.NewCommand("relation-get")
620 c.Assert(err, IsNil)
621 ctx := dummyContext(c)
622@@ -257,7 +257,7 @@
623 }
624
625 func (s *RelationGetSuite) TestOutputPath(c *C) {
626- hctx := s.GetHookContext(c, 1, "m/0")
627+ hctx := s.GetContext(c, 1, "m/0")
628 com, err := hctx.NewCommand("relation-get")
629 c.Assert(err, IsNil)
630 ctx := dummyContext(c)
631
632=== renamed file 'cmd/jujuc/server/relation-ids.go' => 'worker/uniter/hook/relation-ids.go'
633--- cmd/jujuc/server/relation-ids.go 2012-08-07 12:41:54 +0000
634+++ worker/uniter/hook/relation-ids.go 2012-10-01 10:27:24 +0000
635@@ -1,4 +1,4 @@
636-package server
637+package hook
638
639 import (
640 "fmt"
641@@ -9,13 +9,13 @@
642
643 // RelationIdsCommand implements the relation-ids command.
644 type RelationIdsCommand struct {
645- *HookContext
646+ *Context
647 Name string
648 out cmd.Output
649 }
650
651-func NewRelationIdsCommand(ctx *HookContext) (cmd.Command, error) {
652- return &RelationIdsCommand{HookContext: ctx}, nil
653+func NewRelationIdsCommand(ctx *Context) (cmd.Command, error) {
654+ return &RelationIdsCommand{Context: ctx}, nil
655 }
656
657 func (c *RelationIdsCommand) Info() *cmd.Info {
658
659=== renamed file 'cmd/jujuc/server/relation-ids_test.go' => 'worker/uniter/hook/relation-ids_test.go'
660--- cmd/jujuc/server/relation-ids_test.go 2012-08-15 11:51:56 +0000
661+++ worker/uniter/hook/relation-ids_test.go 2012-10-01 10:27:24 +0000
662@@ -1,13 +1,13 @@
663-package server_test
664+package hook_test
665
666 import (
667 "fmt"
668 . "launchpad.net/gocheck"
669 "launchpad.net/juju-core/charm"
670 "launchpad.net/juju-core/cmd"
671- "launchpad.net/juju-core/cmd/jujuc/server"
672 "launchpad.net/juju-core/juju/testing"
673 "launchpad.net/juju-core/state"
674+ "launchpad.net/juju-core/worker/uniter/hook"
675 )
676
677 type RelationIdsSuite struct {
678@@ -15,7 +15,7 @@
679 ch *state.Charm
680 service *state.Service
681 unit *state.Unit
682- relctxs map[int]*server.RelationContext
683+ relctxs map[int]*hook.RelationContext
684 }
685
686 var _ = Suite(&RelationIdsSuite{})
687@@ -28,7 +28,7 @@
688 c.Assert(err, IsNil)
689 s.unit, err = s.service.AddUnit()
690 c.Assert(err, IsNil)
691- s.relctxs = map[int]*server.RelationContext{}
692+ s.relctxs = map[int]*hook.RelationContext{}
693 s.AddRelatedServices(c, "x", 3)
694 s.AddRelatedServices(c, "y", 1)
695 }
696@@ -47,16 +47,16 @@
697 c.Assert(err, IsNil)
698 ru, err := rel.Unit(s.unit)
699 c.Assert(err, IsNil)
700- s.relctxs[rel.Id()] = server.NewRelationContext(ru, nil)
701+ s.relctxs[rel.Id()] = hook.NewRelationContext(ru, nil)
702 }
703 }
704
705-func (s *RelationIdsSuite) GetHookContext(c *C, relid int) *server.HookContext {
706+func (s *RelationIdsSuite) GetContext(c *C, relid int) *hook.Context {
707 if relid != -1 {
708 _, found := s.relctxs[relid]
709 c.Assert(found, Equals, true)
710 }
711- return &server.HookContext{
712+ return &hook.Context{
713 Service: s.service,
714 Unit: s.unit,
715 Id: "TestCtx",
716@@ -137,7 +137,7 @@
717 func (s *RelationIdsSuite) TestRelationIds(c *C) {
718 for i, t := range relationIdsTests {
719 c.Logf("test %d: %s", i, t.summary)
720- hctx := s.GetHookContext(c, t.relid)
721+ hctx := s.GetContext(c, t.relid)
722 com, err := hctx.NewCommand("relation-ids")
723 c.Assert(err, IsNil)
724 ctx := dummyContext(c)
725@@ -177,7 +177,7 @@
726 3: {"relation-ids [options] [<name>]", "\nCurrent default relation name is \"y\".\n"},
727 } {
728 c.Logf("relid %d", relid)
729- hctx := s.GetHookContext(c, relid)
730+ hctx := s.GetContext(c, relid)
731 com, err := hctx.NewCommand("relation-ids")
732 c.Assert(err, IsNil)
733 ctx := dummyContext(c)
734
735=== renamed file 'cmd/jujuc/server/relation-list.go' => 'worker/uniter/hook/relation-list.go'
736--- cmd/jujuc/server/relation-list.go 2012-08-07 14:22:28 +0000
737+++ worker/uniter/hook/relation-list.go 2012-10-01 10:27:24 +0000
738@@ -1,4 +1,4 @@
739-package server
740+package hook
741
742 import (
743 "fmt"
744@@ -8,13 +8,13 @@
745
746 // RelationListCommand implements the relation-list command.
747 type RelationListCommand struct {
748- *HookContext
749+ *Context
750 RelationId int
751 out cmd.Output
752 }
753
754-func NewRelationListCommand(ctx *HookContext) (cmd.Command, error) {
755- return &RelationListCommand{HookContext: ctx}, nil
756+func NewRelationListCommand(ctx *Context) (cmd.Command, error) {
757+ return &RelationListCommand{Context: ctx}, nil
758 }
759
760 func (c *RelationListCommand) Info() *cmd.Info {
761
762=== renamed file 'cmd/jujuc/server/relation-list_test.go' => 'worker/uniter/hook/relation-list_test.go'
763--- cmd/jujuc/server/relation-list_test.go 2012-08-13 11:18:06 +0000
764+++ worker/uniter/hook/relation-list_test.go 2012-10-01 10:27:24 +0000
765@@ -1,14 +1,14 @@
766-package server_test
767+package hook_test
768
769 import (
770 "fmt"
771 . "launchpad.net/gocheck"
772 "launchpad.net/juju-core/cmd"
773- "launchpad.net/juju-core/cmd/jujuc/server"
774+ "launchpad.net/juju-core/worker/uniter/hook"
775 )
776
777 type RelationListSuite struct {
778- HookContextSuite
779+ ContextSuite
780 }
781
782 var _ = Suite(&RelationListSuite{})
783@@ -102,7 +102,7 @@
784 func (s *RelationListSuite) TestRelationList(c *C) {
785 for i, t := range relationListTests {
786 c.Logf("test %d: %s", i, t.summary)
787- hctx := s.GetHookContext(c, t.relid, "")
788+ hctx := s.GetContext(c, t.relid, "")
789 setMembers(hctx.Relations[0], t.members0)
790 setMembers(hctx.Relations[1], t.members1)
791 com, err := hctx.NewCommand("relation-list")
792@@ -145,7 +145,7 @@
793 0: {"[<id>]", "\nCurrent default relation id is \"peer0:0\".\n"},
794 } {
795 c.Logf("test relid %d", relid)
796- hctx := s.GetHookContext(c, relid, "")
797+ hctx := s.GetContext(c, relid, "")
798 com, err := hctx.NewCommand("relation-list")
799 c.Assert(err, IsNil)
800 ctx := dummyContext(c)
801@@ -158,11 +158,11 @@
802 }
803 }
804
805-func setMembers(rctx *server.RelationContext, members []string) {
806+func setMembers(rctx *hook.RelationContext, members []string) {
807 for _, u := range rctx.Units() {
808 rctx.DeleteMember(u)
809 }
810- m := server.SettingsMap{}
811+ m := hook.SettingsMap{}
812 for _, name := range members {
813 m[name] = nil
814 }
815
816=== renamed file 'cmd/jujuc/server/relation-set.go' => 'worker/uniter/hook/relation-set.go'
817--- cmd/jujuc/server/relation-set.go 2012-08-07 14:22:28 +0000
818+++ worker/uniter/hook/relation-set.go 2012-10-01 10:27:24 +0000
819@@ -1,4 +1,4 @@
820-package server
821+package hook
822
823 import (
824 "fmt"
825@@ -9,13 +9,13 @@
826
827 // RelationSetCommand implements the relation-set command.
828 type RelationSetCommand struct {
829- *HookContext
830+ *Context
831 RelationId int
832 Settings map[string]string
833 }
834
835-func NewRelationSetCommand(ctx *HookContext) (cmd.Command, error) {
836- return &RelationSetCommand{HookContext: ctx, Settings: map[string]string{}}, nil
837+func NewRelationSetCommand(ctx *Context) (cmd.Command, error) {
838+ return &RelationSetCommand{Context: ctx, Settings: map[string]string{}}, nil
839 }
840
841 func (c *RelationSetCommand) Info() *cmd.Info {
842
843=== renamed file 'cmd/jujuc/server/relation-set_test.go' => 'worker/uniter/hook/relation-set_test.go'
844--- cmd/jujuc/server/relation-set_test.go 2012-08-07 14:22:28 +0000
845+++ worker/uniter/hook/relation-set_test.go 2012-10-01 10:27:24 +0000
846@@ -1,14 +1,14 @@
847-package server_test
848+package hook_test
849
850 import (
851 "fmt"
852 . "launchpad.net/gocheck"
853 "launchpad.net/juju-core/cmd"
854- "launchpad.net/juju-core/cmd/jujuc/server"
855+ "launchpad.net/juju-core/worker/uniter/hook"
856 )
857
858 type RelationSetSuite struct {
859- HookContextSuite
860+ ContextSuite
861 }
862
863 var _ = Suite(&RelationSetSuite{})
864@@ -21,7 +21,7 @@
865 func (s *RelationSetSuite) TestHelp(c *C) {
866 for i, t := range helpTests {
867 c.Logf("test %d", i)
868- hctx := s.GetHookContext(c, t.relid, "")
869+ hctx := s.GetContext(c, t.relid, "")
870 com, err := hctx.NewCommand("relation-set")
871 c.Assert(err, IsNil)
872 ctx := dummyContext(c)
873@@ -149,13 +149,13 @@
874 func (s *RelationSetSuite) TestInit(c *C) {
875 for i, t := range relationSetInitTests {
876 c.Logf("test %d", i)
877- hctx := s.GetHookContext(c, t.ctxrelid, "")
878+ hctx := s.GetContext(c, t.ctxrelid, "")
879 com, err := hctx.NewCommand("relation-set")
880 c.Assert(err, IsNil)
881 err = com.Init(dummyFlagSet(), t.args)
882 if t.err == "" {
883 c.Assert(err, IsNil)
884- rset := com.(*server.RelationSetCommand)
885+ rset := com.(*hook.RelationSetCommand)
886 c.Assert(rset.RelationId, Equals, t.relid)
887 c.Assert(rset.Settings, DeepEquals, t.settings)
888 } else {
889@@ -182,7 +182,7 @@
890 }
891
892 func (s *RelationSetSuite) TestRun(c *C) {
893- hctx := s.GetHookContext(c, 0, "")
894+ hctx := s.GetContext(c, 0, "")
895 for i, t := range relationSetRunTests {
896 c.Logf("test %d", i)
897
898@@ -198,7 +198,7 @@
899 c.Assert(err, IsNil)
900 com, err := hctx.NewCommand("relation-set")
901 c.Assert(err, IsNil)
902- rset := com.(*server.RelationSetCommand)
903+ rset := com.(*hook.RelationSetCommand)
904 rset.RelationId = 1
905 rset.Settings = t.change
906 ctx := dummyContext(c)
907
908=== renamed file 'cmd/jujuc/server/unit-get.go' => 'worker/uniter/hook/unit-get.go'
909--- cmd/jujuc/server/unit-get.go 2012-07-31 21:36:59 +0000
910+++ worker/uniter/hook/unit-get.go 2012-10-01 10:27:24 +0000
911@@ -1,4 +1,4 @@
912-package server
913+package hook
914
915 import (
916 "errors"
917@@ -9,13 +9,13 @@
918
919 // UnitGetCommand implements the unit-get command.
920 type UnitGetCommand struct {
921- *HookContext
922+ *Context
923 Key string
924 out cmd.Output
925 }
926
927-func NewUnitGetCommand(ctx *HookContext) (cmd.Command, error) {
928- return &UnitGetCommand{HookContext: ctx}, nil
929+func NewUnitGetCommand(ctx *Context) (cmd.Command, error) {
930+ return &UnitGetCommand{Context: ctx}, nil
931 }
932
933 func (c *UnitGetCommand) Info() *cmd.Info {
934
935=== renamed file 'cmd/jujuc/server/unit-get_test.go' => 'worker/uniter/hook/unit-get_test.go'
936--- cmd/jujuc/server/unit-get_test.go 2012-07-31 21:36:59 +0000
937+++ worker/uniter/hook/unit-get_test.go 2012-10-01 10:27:24 +0000
938@@ -1,4 +1,4 @@
939-package server_test
940+package hook_test
941
942 import (
943 "io/ioutil"
944@@ -8,13 +8,13 @@
945 )
946
947 type UnitGetSuite struct {
948- HookContextSuite
949+ ContextSuite
950 }
951
952 var _ = Suite(&UnitGetSuite{})
953
954 func (s *UnitGetSuite) SetUpTest(c *C) {
955- s.HookContextSuite.SetUpTest(c)
956+ s.ContextSuite.SetUpTest(c)
957 err := s.unit.SetPublicAddress("gimli.minecraft.example.com")
958 c.Assert(err, IsNil)
959 err = s.unit.SetPrivateAddress("192.168.0.99")
960@@ -35,7 +35,7 @@
961
962 func (s *UnitGetSuite) TestOutputFormat(c *C) {
963 for _, t := range unitGetTests {
964- hctx := s.GetHookContext(c, -1, "")
965+ hctx := s.GetContext(c, -1, "")
966 com, err := hctx.NewCommand("unit-get")
967 c.Assert(err, IsNil)
968 ctx := dummyContext(c)
969@@ -47,7 +47,7 @@
970 }
971
972 func (s *UnitGetSuite) TestHelp(c *C) {
973- hctx := s.GetHookContext(c, -1, "")
974+ hctx := s.GetContext(c, -1, "")
975 com, err := hctx.NewCommand("unit-get")
976 c.Assert(err, IsNil)
977 ctx := dummyContext(c)
978@@ -66,7 +66,7 @@
979 }
980
981 func (s *UnitGetSuite) TestOutputPath(c *C) {
982- hctx := s.GetHookContext(c, -1, "")
983+ hctx := s.GetContext(c, -1, "")
984 com, err := hctx.NewCommand("unit-get")
985 c.Assert(err, IsNil)
986 ctx := dummyContext(c)
987@@ -80,7 +80,7 @@
988 }
989
990 func (s *UnitGetSuite) TestUnknownSetting(c *C) {
991- hctx := s.GetHookContext(c, -1, "")
992+ hctx := s.GetContext(c, -1, "")
993 com, err := hctx.NewCommand("unit-get")
994 c.Assert(err, IsNil)
995 err = com.Init(dummyFlagSet(), []string{"protected-address"})
996@@ -88,7 +88,7 @@
997 }
998
999 func (s *UnitGetSuite) TestUnknownArg(c *C) {
1000- hctx := s.GetHookContext(c, -1, "")
1001+ hctx := s.GetContext(c, -1, "")
1002 com, err := hctx.NewCommand("unit-get")
1003 c.Assert(err, IsNil)
1004 err = com.Init(dummyFlagSet(), []string{"private-address", "blah"})
1005
1006=== renamed file 'cmd/jujuc/server/util_test.go' => 'worker/uniter/hook/util_test.go'
1007--- cmd/jujuc/server/util_test.go 2012-09-21 09:32:11 +0000
1008+++ worker/uniter/hook/util_test.go 2012-10-01 10:27:24 +0000
1009@@ -1,4 +1,4 @@
1010-package server_test
1011+package hook_test
1012
1013 import (
1014 "bytes"
1015@@ -6,18 +6,12 @@
1016 . "launchpad.net/gocheck"
1017 "launchpad.net/juju-core/charm"
1018 "launchpad.net/juju-core/cmd"
1019- "launchpad.net/juju-core/cmd/jujuc/server"
1020 "launchpad.net/juju-core/juju/testing"
1021 "launchpad.net/juju-core/state"
1022- coretesting "launchpad.net/juju-core/testing"
1023+ "launchpad.net/juju-core/worker/uniter/hook"
1024 "strings"
1025- stdtesting "testing"
1026 )
1027
1028-func TestPackage(t *stdtesting.T) {
1029- coretesting.MgoTestPackage(t)
1030-}
1031-
1032 func dummyContext(c *C) *cmd.Context {
1033 return &cmd.Context{c.MkDir(), nil, &bytes.Buffer{}, &bytes.Buffer{}}
1034 }
1035@@ -26,16 +20,16 @@
1036 return w.(*bytes.Buffer).String()
1037 }
1038
1039-type HookContextSuite struct {
1040+type ContextSuite struct {
1041 testing.JujuConnSuite
1042 ch *state.Charm
1043 service *state.Service
1044 unit *state.Unit
1045 relunits map[int]*state.RelationUnit
1046- relctxs map[int]*server.RelationContext
1047+ relctxs map[int]*hook.RelationContext
1048 }
1049
1050-func (s *HookContextSuite) SetUpTest(c *C) {
1051+func (s *ContextSuite) SetUpTest(c *C) {
1052 s.JujuConnSuite.SetUpTest(c)
1053 s.ch = s.AddTestingCharm(c, "dummy")
1054 var err error
1055@@ -43,12 +37,12 @@
1056 c.Assert(err, IsNil)
1057 s.unit = s.AddUnit(c)
1058 s.relunits = map[int]*state.RelationUnit{}
1059- s.relctxs = map[int]*server.RelationContext{}
1060+ s.relctxs = map[int]*hook.RelationContext{}
1061 s.AddRelationContext(c, "peer0")
1062 s.AddRelationContext(c, "peer1")
1063 }
1064
1065-func (s *HookContextSuite) AddUnit(c *C) *state.Unit {
1066+func (s *ContextSuite) AddUnit(c *C) *state.Unit {
1067 unit, err := s.service.AddUnit()
1068 c.Assert(err, IsNil)
1069 name := strings.Replace(unit.Name(), "/", "-", 1)
1070@@ -57,7 +51,7 @@
1071 return unit
1072 }
1073
1074-func (s *HookContextSuite) AddRelationContext(c *C, name string) {
1075+func (s *ContextSuite) AddRelationContext(c *C, name string) {
1076 ep := state.RelationEndpoint{
1077 s.service.Name(), "ifce", name, state.RolePeer, charm.ScopeGlobal,
1078 }
1079@@ -68,15 +62,15 @@
1080 s.relunits[rel.Id()] = ru
1081 err = ru.EnterScope()
1082 c.Assert(err, IsNil)
1083- s.relctxs[rel.Id()] = server.NewRelationContext(ru, nil)
1084+ s.relctxs[rel.Id()] = hook.NewRelationContext(ru, nil)
1085 }
1086
1087-func (s *HookContextSuite) GetHookContext(c *C, relid int, remote string) *server.HookContext {
1088+func (s *ContextSuite) GetContext(c *C, relid int, remote string) *hook.Context {
1089 if relid != -1 {
1090 _, found := s.relctxs[relid]
1091 c.Assert(found, Equals, true)
1092 }
1093- return &server.HookContext{
1094+ return &hook.Context{
1095 Service: s.service,
1096 Unit: s.unit,
1097 Id: "TestCtx",
1098
1099=== modified file 'worker/uniter/relationer.go'
1100--- worker/uniter/relationer.go 2012-09-25 22:01:28 +0000
1101+++ worker/uniter/relationer.go 2012-10-01 10:27:24 +0000
1102@@ -2,7 +2,6 @@
1103
1104 import (
1105 "fmt"
1106- "launchpad.net/juju-core/cmd/jujuc/server"
1107 "launchpad.net/juju-core/state"
1108 "launchpad.net/juju-core/worker/uniter/hook"
1109 "launchpad.net/juju-core/worker/uniter/relation"
1110@@ -10,7 +9,7 @@
1111
1112 // Relationer manages a unit's presence in a relation.
1113 type Relationer struct {
1114- ctx *server.RelationContext
1115+ ctx *hook.RelationContext
1116 ru *state.RelationUnit
1117 dir *relation.StateDir
1118 queue relation.HookQueue
1119@@ -22,7 +21,7 @@
1120 // relation until explicitly requested.
1121 func NewRelationer(ru *state.RelationUnit, dir *relation.StateDir, hooks chan<- hook.Info) *Relationer {
1122 return &Relationer{
1123- ctx: server.NewRelationContext(ru, dir.State().Members),
1124+ ctx: hook.NewRelationContext(ru, dir.State().Members),
1125 ru: ru,
1126 dir: dir,
1127 hooks: hooks,
1128@@ -30,7 +29,7 @@
1129 }
1130
1131 // Context returns the RelationContext associated with r.
1132-func (r *Relationer) Context() *server.RelationContext {
1133+func (r *Relationer) Context() *hook.RelationContext {
1134 return r.ctx
1135 }
1136
1137@@ -98,7 +97,7 @@
1138 if hi.Kind == hook.RelationDeparted {
1139 r.ctx.DeleteMember(hi.RemoteUnit)
1140 } else if hi.RemoteUnit != "" {
1141- r.ctx.UpdateMembers(server.SettingsMap{hi.RemoteUnit: nil})
1142+ r.ctx.UpdateMembers(hook.SettingsMap{hi.RemoteUnit: nil})
1143 }
1144 name := r.ru.Endpoint().RelationName
1145 return fmt.Sprintf("%s-%s", name, hi.Kind), nil
1146
1147=== modified file 'worker/uniter/tools.go'
1148--- worker/uniter/tools.go 2012-09-13 15:52:04 +0000
1149+++ worker/uniter/tools.go 2012-10-01 10:27:24 +0000
1150@@ -2,7 +2,7 @@
1151
1152 import (
1153 "fmt"
1154- "launchpad.net/juju-core/cmd/jujuc/server"
1155+ "launchpad.net/juju-core/worker/uniter/hook"
1156 "os"
1157 "path/filepath"
1158 )
1159@@ -10,7 +10,7 @@
1160 // EnsureJujucSymlinks creates a symbolic link to jujuc within dir for each
1161 // hook command. If the commands already exist, this operation does nothing.
1162 func EnsureJujucSymlinks(dir string) (err error) {
1163- for _, name := range server.CommandNames() {
1164+ for _, name := range hook.CommandNames() {
1165 // The link operation fails when the target already exists,
1166 // so this is a no-op when the command names already
1167 // exist.
1168
1169=== modified file 'worker/uniter/tools_test.go'
1170--- worker/uniter/tools_test.go 2012-09-13 15:52:04 +0000
1171+++ worker/uniter/tools_test.go 2012-10-01 10:27:24 +0000
1172@@ -3,10 +3,10 @@
1173 import (
1174 "io/ioutil"
1175 . "launchpad.net/gocheck"
1176- "launchpad.net/juju-core/cmd/jujuc/server"
1177 "launchpad.net/juju-core/environs"
1178 "launchpad.net/juju-core/version"
1179 "launchpad.net/juju-core/worker/uniter"
1180+ "launchpad.net/juju-core/worker/uniter/hook"
1181 "os"
1182 "path/filepath"
1183 "time"
1184@@ -45,7 +45,7 @@
1185 err = uniter.EnsureJujucSymlinks(s.toolsDir)
1186 c.Assert(err, IsNil)
1187 mtimes := map[string]time.Time{}
1188- for _, name := range server.CommandNames() {
1189+ for _, name := range hook.CommandNames() {
1190 tool := filepath.Join(s.toolsDir, name)
1191 mtimes[tool] = assertLink(tool)
1192 }
1193
1194=== modified file 'worker/uniter/uniter.go'
1195--- worker/uniter/uniter.go 2012-09-28 15:27:47 +0000
1196+++ worker/uniter/uniter.go 2012-10-01 10:27:24 +0000
1197@@ -194,7 +194,7 @@
1198 // TODO: update relation context; get hook name.
1199 }
1200 hctxId := fmt.Sprintf("%s:%s:%d", u.unit.Name(), hookName, u.rand.Int63())
1201- hctx := server.HookContext{
1202+ hctx := hook.Context{
1203 Service: u.service,
1204 Unit: u.unit,
1205 Id: hctxId,

Subscribers

People subscribed via source and target branches