github.com/rawahars/moby@v24.0.4+incompatible/pkg/parsers/operatingsystem/operatingsystem_unix.go (about)

     1  //go:build freebsd || darwin
     2  // +build freebsd darwin
     3  
     4  package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatingsystem"
     5  
     6  import (
     7  	"errors"
     8  
     9  	"golang.org/x/sys/unix"
    10  )
    11  
    12  // GetOperatingSystem gets the name of the current operating system.
    13  func GetOperatingSystem() (string, error) {
    14  	utsname := &unix.Utsname{}
    15  	if err := unix.Uname(utsname); err != nil {
    16  		return "", err
    17  	}
    18  	return unix.ByteSliceToString(utsname.Machine[:]), nil
    19  }
    20  
    21  // GetOperatingSystemVersion gets the version of the current operating system, as a string.
    22  func GetOperatingSystemVersion() (string, error) {
    23  	// there's no standard unix way of getting this, sadly...
    24  	return "", errors.New("Unsupported on generic unix")
    25  }
    26  
    27  // IsContainerized returns true if we are running inside a container.
    28  // No-op on FreeBSD and Darwin, always returns false.
    29  func IsContainerized() (bool, error) {
    30  	// TODO: Implement jail detection for freeBSD
    31  	return false, errors.New("Cannot detect if we are in container")
    32  }