operatingsystem_unix.go 938 B

1234567891011121314151617181920212223242526272829303132
  1. // +build freebsd darwin
  2. package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatingsystem"
  3. import (
  4. "errors"
  5. "fmt"
  6. "os/exec"
  7. )
  8. // GetOperatingSystem gets the name of the current operating system.
  9. func GetOperatingSystem() (string, error) {
  10. cmd := exec.Command("uname", "-s")
  11. osName, err := cmd.Output()
  12. if err != nil {
  13. return "", err
  14. }
  15. return string(osName), nil
  16. }
  17. // GetOperatingSystemVersion gets the version of the current operating system, as a string.
  18. func GetOperatingSystemVersion() (string, error) {
  19. // there's no standard unix way of getting this, sadly...
  20. return "", fmt.Error("Unsupported on generic unix")
  21. }
  22. // IsContainerized returns true if we are running inside a container.
  23. // No-op on FreeBSD and Darwin, always returns false.
  24. func IsContainerized() (bool, error) {
  25. // TODO: Implement jail detection for freeBSD
  26. return false, errors.New("Cannot detect if we are in container")
  27. }