1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/pkg/parsers/operatingsystem/operatingsystem_unix.go
Sebastiaan van Stijn 686be57d0a
Update to Go 1.17.0, and gofmt with Go 1.17
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-08-24 23:33:27 +02:00

33 lines
1 KiB
Go

//go:build freebsd || darwin
// +build freebsd darwin
package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatingsystem"
import (
"bytes"
"errors"
"golang.org/x/sys/unix"
)
// GetOperatingSystem gets the name of the current operating system.
func GetOperatingSystem() (string, error) {
utsname := &unix.Utsname{}
if err := unix.Uname(utsname); err != nil {
return "", err
}
return string(utsname.Machine[:bytes.IndexByte(utsname.Sysname[:], 0)]), nil
}
// 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 "", errors.New("Unsupported on generic unix")
}
// IsContainerized returns true if we are running inside a container.
// No-op on FreeBSD and Darwin, always returns false.
func IsContainerized() (bool, error) {
// TODO: Implement jail detection for freeBSD
return false, errors.New("Cannot detect if we are in container")
}