~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/utils/os/os.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
        Windows
15
15
        OSX
16
16
        CentOS
17
 
        Arch
 
17
        GenericLinux
18
18
)
19
19
 
20
20
func (t OSType) String() string {
27
27
                return "OSX"
28
28
        case CentOS:
29
29
                return "CentOS"
30
 
        case Arch:
31
 
                return "Arch"
 
30
        case GenericLinux:
 
31
                return "GenericLinux"
32
32
        }
33
33
        return "Unknown"
34
34
}
 
35
 
 
36
// EquivalentTo returns true if the OS type is equivalent to another
 
37
// OS type.
 
38
func (t OSType) EquivalentTo(t2 OSType) bool {
 
39
        if t == t2 {
 
40
                return true
 
41
        }
 
42
        return t.IsLinux() && t2.IsLinux()
 
43
}
 
44
 
 
45
// IsLinux returns true if the OS type is a Linux variant.
 
46
func (t OSType) IsLinux() bool {
 
47
        switch t {
 
48
        case Ubuntu, CentOS, GenericLinux:
 
49
                return true
 
50
        }
 
51
        return false
 
52
}