cdi

package
v0.17.4 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	CreateSpecFile() error
	QualifiedName(string, string) string
}

Interface provides the API to the 'cdi' package

func New

func New(infolib info.Interface, nvmllib nvml.Interface, devicelib device.Interface, opts ...Option) (Interface, error)

New constructs a new instance of the 'cdi' interface

func NewNullHandler

func NewNullHandler() Interface

NewNullHandler returns an instance of the 'cdi' interface that can be used when CDI specs are not required.

type InterfaceMock

type InterfaceMock struct {
	// CreateSpecFileFunc mocks the CreateSpecFile method.
	CreateSpecFileFunc func() error

	// QualifiedNameFunc mocks the QualifiedName method.
	QualifiedNameFunc func(s1 string, s2 string) string
	// contains filtered or unexported fields
}

InterfaceMock is a mock implementation of Interface.

func TestSomethingThatUsesInterface(t *testing.T) {

	// make and configure a mocked Interface
	mockedInterface := &InterfaceMock{
		CreateSpecFileFunc: func() error {
			panic("mock out the CreateSpecFile method")
		},
		QualifiedNameFunc: func(s1 string, s2 string) string {
			panic("mock out the QualifiedName method")
		},
	}

	// use mockedInterface in code that requires Interface
	// and then make assertions.

}

func (*InterfaceMock) CreateSpecFile

func (mock *InterfaceMock) CreateSpecFile() error

CreateSpecFile calls CreateSpecFileFunc.

func (*InterfaceMock) CreateSpecFileCalls

func (mock *InterfaceMock) CreateSpecFileCalls() []struct {
}

CreateSpecFileCalls gets all the calls that were made to CreateSpecFile. Check the length with:

len(mockedInterface.CreateSpecFileCalls())

func (*InterfaceMock) QualifiedName

func (mock *InterfaceMock) QualifiedName(s1 string, s2 string) string

QualifiedName calls QualifiedNameFunc.

func (*InterfaceMock) QualifiedNameCalls

func (mock *InterfaceMock) QualifiedNameCalls() []struct {
	S1 string
	S2 string
}

QualifiedNameCalls gets all the calls that were made to QualifiedName. Check the length with:

len(mockedInterface.QualifiedNameCalls())

type Option

type Option func(*cdiHandler)

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

func WithDevRoot added in v0.16.0

func WithDevRoot(root string) Option

WithDevRoot sets the dev root for the `cdi` interface.

func WithDeviceIDStrategy

func WithDeviceIDStrategy(strategy string) Option

WithDeviceIDStrategy provides an Option to set the device ID strategy used by the 'cdi' interface

func WithDeviceListStrategies added in v0.15.0

func WithDeviceListStrategies(deviceListStrategies spec.DeviceListStrategies) Option

WithDeviceListStrategies provides an Option to set the enabled flag used by the 'cdi' interface

func WithDriverRoot

func WithDriverRoot(root string) Option

WithDriverRoot provides an Option to set the driver root used by the 'cdi' interface.

func WithGdsEnabled

func WithGdsEnabled(enabled bool) Option

WithGdsEnabled provides and option to set whether a GDS CDI spec should be generated

func WithImexChannels added in v0.17.0

func WithImexChannels(imexChannels imex.Channels) Option

WithImexChannels sets the IMEX channels for which CDI specs should be generated.

func WithMofedEnabled

func WithMofedEnabled(enabled bool) Option

WithMofedEnabled provides and option to set whether a MOFED CDI spec should be generated

func WithNvidiaCTKPath

func WithNvidiaCTKPath(path string) Option

WithNvidiaCTKPath provides an Option to set the nvidia-ctk path used by the 'cdi' interface

func WithTargetDevRoot added in v0.16.0

func WithTargetDevRoot(root string) Option

WithTargetDevRoot provides an Option to set the target (host) dev root used by the 'cdi' interface

func WithTargetDriverRoot

func WithTargetDriverRoot(root string) Option

WithTargetDriverRoot provides an Option to set the target (host) driver root used by the 'cdi' interface

func WithVendor

func WithVendor(vendor string) Option

WithVendor provides an Option to set the vendor used by the 'cdi' interface

Jump to

Keyboard shortcuts

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