info

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 11

Documentation

Index

Constants

View Source
const (
	PlatformAuto    = Platform("auto")
	PlatformNVML    = Platform("nvml")
	PlatformTegra   = Platform("tegra")
	PlatformWSL     = Platform("wsl")
	PlatformUnknown = Platform("unknown")
)

Variables

This section is empty.

Functions

func IsIntegratedGPUName added in v0.10.0

func IsIntegratedGPUName(name string) bool

IsIntegratedGPUName checks whether the specified device name is associated with a known integrated GPU.

Devices with the following names are considered integrated GPUs:

GPU 0: Orin (nvgpu) (UUID: 54d0709b-558d-5a59-9c65-0c5fc14a21a4)
GPU 0: NVIDIA Thor  (UUID: 54d0709b-558d-5a59-9c65-0c5fc14a21a4)

(Where this shows the nvidia-smi -L output on these systems).

Types

type Interface

type Interface interface {
	PlatformResolver
	PropertyExtractor
}

Interface provides the API to the info package.

func New

func New(opts ...Option) Interface

New creates a new instance of the 'info' interface.

type Option

type Option func(*options)

Option defines a function for passing options to the New() call.

func WithDeviceLib added in v0.4.0

func WithDeviceLib(devicelib device.Interface) Option

WithDeviceLib sets the device library for the library.

func WithLogger added in v0.4.0

func WithLogger(logger basicLogger) Option

WithLogger sets the logger for the library.

func WithNvmlLib added in v0.4.0

func WithNvmlLib(nvmllib nvml.Interface) Option

WithNvmlLib sets the nvml library for the library.

func WithPlatform added in v0.4.0

func WithPlatform(platform Platform) Option

WithPlatform provides an option to set the platform explicitly.

func WithPropertyExtractor added in v0.4.0

func WithPropertyExtractor(propertyExtractor PropertyExtractor) Option

WithPropertyExtractor provides an Option to set the PropertyExtractor interface implementation. This is predominantly used for testing.

func WithRoot

func WithRoot(r string) Option

WithRoot provides a Option to set the root of the 'info' interface.

type Platform added in v0.4.0

type Platform string

Platform represents a supported plaform.

type PlatformResolver added in v0.4.0

type PlatformResolver interface {
	ResolvePlatform() Platform
}

PlatformResolver defines a function to resolve the current platform.

type PropertyExtractor added in v0.4.0

type PropertyExtractor interface {
	HasDXCore() (bool, string)
	HasNvml() (bool, string)
	HasTegraFiles() (bool, string)
	HasAnIntegratedGPU() (bool, string)
}

PropertyExtractor provides a set of functions to query capabilities of the system.

type PropertyExtractorMock added in v0.4.0

type PropertyExtractorMock struct {
	// HasAnIntegratedGPUFunc mocks the HasAnIntegratedGPU method.
	HasAnIntegratedGPUFunc func() (bool, string)

	// HasDXCoreFunc mocks the HasDXCore method.
	HasDXCoreFunc func() (bool, string)

	// HasNvmlFunc mocks the HasNvml method.
	HasNvmlFunc func() (bool, string)

	// HasTegraFilesFunc mocks the HasTegraFiles method.
	HasTegraFilesFunc func() (bool, string)
	// contains filtered or unexported fields
}

PropertyExtractorMock is a mock implementation of PropertyExtractor.

func TestSomethingThatUsesPropertyExtractor(t *testing.T) {

	// make and configure a mocked PropertyExtractor
	mockedPropertyExtractor := &PropertyExtractorMock{
		HasAnIntegratedGPUFunc: func() (bool, string) {
			panic("mock out the HasAnIntegratedGPU method")
		},
		HasDXCoreFunc: func() (bool, string) {
			panic("mock out the HasDXCore method")
		},
		HasNvmlFunc: func() (bool, string) {
			panic("mock out the HasNvml method")
		},
		HasTegraFilesFunc: func() (bool, string) {
			panic("mock out the HasTegraFiles method")
		},
	}

	// use mockedPropertyExtractor in code that requires PropertyExtractor
	// and then make assertions.

}

func (*PropertyExtractorMock) HasAnIntegratedGPU added in v0.10.0

func (mock *PropertyExtractorMock) HasAnIntegratedGPU() (bool, string)

HasAnIntegratedGPU calls HasAnIntegratedGPUFunc.

func (*PropertyExtractorMock) HasAnIntegratedGPUCalls added in v0.10.0

func (mock *PropertyExtractorMock) HasAnIntegratedGPUCalls() []struct {
}

HasAnIntegratedGPUCalls gets all the calls that were made to HasAnIntegratedGPU. Check the length with:

len(mockedPropertyExtractor.HasAnIntegratedGPUCalls())

func (*PropertyExtractorMock) HasDXCore added in v0.4.0

func (mock *PropertyExtractorMock) HasDXCore() (bool, string)

HasDXCore calls HasDXCoreFunc.

func (*PropertyExtractorMock) HasDXCoreCalls added in v0.4.0

func (mock *PropertyExtractorMock) HasDXCoreCalls() []struct {
}

HasDXCoreCalls gets all the calls that were made to HasDXCore. Check the length with:

len(mockedPropertyExtractor.HasDXCoreCalls())

func (*PropertyExtractorMock) HasNvml added in v0.4.0

func (mock *PropertyExtractorMock) HasNvml() (bool, string)

HasNvml calls HasNvmlFunc.

func (*PropertyExtractorMock) HasNvmlCalls added in v0.4.0

func (mock *PropertyExtractorMock) HasNvmlCalls() []struct {
}

HasNvmlCalls gets all the calls that were made to HasNvml. Check the length with:

len(mockedPropertyExtractor.HasNvmlCalls())

func (*PropertyExtractorMock) HasTegraFiles added in v0.4.0

func (mock *PropertyExtractorMock) HasTegraFiles() (bool, string)

HasTegraFiles calls HasTegraFilesFunc.

func (*PropertyExtractorMock) HasTegraFilesCalls added in v0.4.0

func (mock *PropertyExtractorMock) HasTegraFilesCalls() []struct {
}

HasTegraFilesCalls gets all the calls that were made to HasTegraFiles. Check the length with:

len(mockedPropertyExtractor.HasTegraFilesCalls())

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL