operatingsystem_unix.go 968 B

123456789101112131415161718192021222324252627282930313233
  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. "strings"
  8. )
  9. // GetOperatingSystem gets the name of the current operating system.
  10. func GetOperatingSystem() (string, error) {
  11. cmd := exec.Command("uname", "-s")
  12. osName, err := cmd.Output()
  13. if err != nil {
  14. return "", err
  15. }
  16. return strings.TrimSpace(string(osName)), nil
  17. }
  18. // GetOperatingSystemVersion gets the version of the current operating system, as a string.
  19. func GetOperatingSystemVersion() (string, error) {
  20. // there's no standard unix way of getting this, sadly...
  21. return "", fmt.Error("Unsupported on generic unix")
  22. }
  23. // IsContainerized returns true if we are running inside a container.
  24. // No-op on FreeBSD and Darwin, always returns false.
  25. func IsContainerized() (bool, error) {
  26. // TODO: Implement jail detection for freeBSD
  27. return false, errors.New("Cannot detect if we are in container")
  28. }