github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/pkg/parsers/operatingsystem/operatingsystem_unix.go (about)

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