2016-05-06 10:03:01 +00:00
|
|
|
// +build freebsd darwin
|
|
|
|
|
2015-07-29 18:25:56 +00:00
|
|
|
package operatingsystem
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2016-05-06 10:03:01 +00:00
|
|
|
"os/exec"
|
2015-07-29 18:25:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// GetOperatingSystem gets the name of the current operating system.
|
|
|
|
func GetOperatingSystem() (string, error) {
|
2016-05-06 10:03:01 +00:00
|
|
|
cmd := exec.Command("uname", "-s")
|
|
|
|
osName, err := cmd.Output()
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
return string(osName), nil
|
2015-07-29 18:25:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// IsContainerized returns true if we are running inside a container.
|
2016-05-06 10:03:01 +00:00
|
|
|
// No-op on FreeBSD and Darwin, always returns false.
|
2015-07-29 18:25:56 +00:00
|
|
|
func IsContainerized() (bool, error) {
|
2016-05-06 10:03:01 +00:00
|
|
|
// TODO: Implement jail detection for freeBSD
|
2015-07-29 18:25:56 +00:00
|
|
|
return false, errors.New("Cannot detect if we are in container")
|
|
|
|
}
|