-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathos.go
58 lines (51 loc) · 1.01 KB
/
os.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2015 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.
// Package os provides access to operating system related configuration.
package os
var HostOS = hostOS // for monkey patching
type OSType int
const (
Unknown OSType = iota
Ubuntu
Windows
OSX
CentOS
GenericLinux
OpenSUSE
Kubernetes
)
func (t OSType) String() string {
switch t {
case Ubuntu:
return "Ubuntu"
case Windows:
return "Windows"
case OSX:
return "OSX"
case CentOS:
return "CentOS"
case GenericLinux:
return "GenericLinux"
case OpenSUSE:
return "OpenSUSE"
case Kubernetes:
return "Kubernetes"
}
return "Unknown"
}
// EquivalentTo returns true if the OS type is equivalent to another
// OS type.
func (t OSType) EquivalentTo(t2 OSType) bool {
if t == t2 {
return true
}
return t.IsLinux() && t2.IsLinux()
}
// IsLinux returns true if the OS type is a Linux variant.
func (t OSType) IsLinux() bool {
switch t {
case Ubuntu, CentOS, GenericLinux, OpenSUSE:
return true
}
return false
}