~juju-qa/juju-core/1.16-packaging

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/juju/osenv/vars.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-09-20 22:06:08 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130920220608-298qxyybgb0n9c47
Tags: 1.14.1-0ubuntu1
New upstream point release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
package osenv
5
5
 
 
6
import (
 
7
        "os"
 
8
        "path/filepath"
 
9
        "runtime"
 
10
)
 
11
 
6
12
const (
7
13
        JujuEnv               = "JUJU_ENV"
8
14
        JujuHome              = "JUJU_HOME"
15
21
        JujuSharedStorageDir  = "JUJU_SHARED_STORAGE_DIR"
16
22
        JujuSharedStorageAddr = "JUJU_SHARED_STORAGE_ADDR"
17
23
)
 
24
 
 
25
// JujuHome returns the directory where juju should store application-specific files
 
26
func JujuHomeDir() string {
 
27
        jujuHome := os.Getenv(JujuHome)
 
28
        if jujuHome == "" {
 
29
                if runtime.GOOS == "windows" {
 
30
                        jujuHome = jujuHomeWin()
 
31
                } else {
 
32
                        jujuHome = jujuHomeLinux()
 
33
                }
 
34
        }
 
35
        return jujuHome
 
36
}
 
37
 
 
38
// jujuHomeLinux returns the directory where juju should store application-specific files on Linux.
 
39
func jujuHomeLinux() string {
 
40
        home := Home()
 
41
        if home == "" {
 
42
                return ""
 
43
        }
 
44
        return filepath.Join(home, ".juju")
 
45
}
 
46
 
 
47
// jujuHomeWin returns the directory where juju should store application-specific files on Windows.
 
48
func jujuHomeWin() string {
 
49
        appdata := os.Getenv("APPDATA")
 
50
        if appdata == "" {
 
51
                return ""
 
52
        }
 
53
        return filepath.Join(appdata, "Juju")
 
54
}