launchpad.net/~rogpeppe/juju-core/500-errgo-fix@v0.0.0-20140213181702-000000002356/worker/uniter/debug/common.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package debug 5 6 import ( 7 "fmt" 8 "launchpad.net/juju-core/names" 9 "path/filepath" 10 ) 11 12 const defaultFlockDir = "/tmp" 13 14 type HooksContext struct { 15 Unit string 16 FlockDir string 17 } 18 19 func NewHooksContext(unitName string) *HooksContext { 20 return &HooksContext{Unit: unitName, FlockDir: defaultFlockDir} 21 } 22 23 func (c *HooksContext) ClientFileLock() string { 24 basename := fmt.Sprintf("juju-%s-debug-hooks", names.UnitTag(c.Unit)) 25 return filepath.Join(c.FlockDir, basename) 26 } 27 28 func (c *HooksContext) ClientExitFileLock() string { 29 return c.ClientFileLock() + "-exit" 30 } 31 32 func (c *HooksContext) tmuxSessionName() string { 33 return c.Unit 34 }