2016-05-06 18:03:01 +08:00
|
|
|
// +build freebsd darwin
|
|
|
|
|
2018-02-05 16:05:59 -05:00
|
|
|
package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatingsystem"
|
2015-07-29 21:25:56 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2019-05-30 09:51:41 -07:00
|
|
|
"fmt"
|
2016-05-06 18:03:01 +08:00
|
|
|
"os/exec"
|
2019-08-29 16:58:38 +02:00
|
|
|
"strings"
|
2015-07-29 21:25:56 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// GetOperatingSystem gets the name of the current operating system.
|
|
|
|
func GetOperatingSystem() (string, error) {
|
2016-05-06 18:03:01 +08:00
|
|
|
cmd := exec.Command("uname", "-s")
|
|
|
|
osName, err := cmd.Output()
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
2019-08-29 16:58:38 +02:00
|
|
|
return strings.TrimSpace(string(osName)), nil
|
2015-07-29 21:25:56 +03:00
|
|
|
}
|
|
|
|
|
2019-05-30 09:51:41 -07:00
|
|
|
// GetOperatingSystemVersion gets the version of the current operating system, as a string.
|
|
|
|
func GetOperatingSystemVersion() (string, error) {
|
|
|
|
// there's no standard unix way of getting this, sadly...
|
|
|
|
return "", fmt.Error("Unsupported on generic unix")
|
|
|
|
}
|
|
|
|
|
2015-07-29 21:25:56 +03:00
|
|
|
// IsContainerized returns true if we are running inside a container.
|
2016-05-06 18:03:01 +08:00
|
|
|
// No-op on FreeBSD and Darwin, always returns false.
|
2015-07-29 21:25:56 +03:00
|
|
|
func IsContainerized() (bool, error) {
|
2016-05-06 18:03:01 +08:00
|
|
|
// TODO: Implement jail detection for freeBSD
|
2015-07-29 21:25:56 +03:00
|
|
|
return false, errors.New("Cannot detect if we are in container")
|
|
|
|
}
|