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