moby/pkg/parsers/operatingsystem/operatingsystem_unix.go
Sebastiaan van Stijn e4e819b49c
pkg/parsers/operatingsystem: fix stray import
This was caught by goimports;

    goimports -w $(find . -type f -name '*.go'| grep -v "/vendor/")

CI doesn't run on these platforms, so didn't catch it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-08 18:42:20 +02:00

32 lines
995 B
Go

//go:build freebsd || darwin
// +build freebsd darwin
package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatingsystem"
import (
"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 unix.ByteSliceToString(utsname.Machine[:]), 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")
}