discover

package
v1.14.5 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	HostPath string
	Path     string
}

Device represents a discovered character device.

type Discover

type Discover interface {
	Devices() ([]Device, error)
	Mounts() ([]Mount, error)
	Hooks() ([]Hook, error)
}

Discover defines an interface for discovering the devices, mounts, and hooks available on a system

func CreateCreateSymlinkHook added in v1.13.0

func CreateCreateSymlinkHook(nvidiaCTKPath string, links []string) Discover

CreateCreateSymlinkHook creates a hook which creates a symlink from link -> target.

func Merge added in v1.11.0

func Merge(d ...Discover) Discover

Merge creates a discoverer that is the composite of a list of discoveres.

func NewCharDeviceDiscoverer added in v1.11.0

func NewCharDeviceDiscoverer(logger logger.Interface, devices []string, root string) Discover

NewCharDeviceDiscoverer creates a discoverer which locates the specified set of device nodes.

func NewDeviceDiscoverer added in v1.11.0

func NewDeviceDiscoverer(logger logger.Interface, locator lookup.Locator, root string, devices []string) Discover

NewDeviceDiscoverer creates a discoverer which locates the specified set of device nodes using the specified locator.

func NewGDSDiscoverer added in v1.11.0

func NewGDSDiscoverer(logger logger.Interface, root string) (Discover, error)

NewGDSDiscoverer creates a discoverer for GPUDirect Storage devices and mounts.

func NewGraphicsDiscoverer added in v1.12.0

func NewGraphicsDiscoverer(logger logger.Interface, devices image.VisibleDevices, driverRoot string, nvidiaCTKPath string) (Discover, error)

NewGraphicsDiscoverer returns the discoverer for graphics tools such as Vulkan.

func NewGraphicsMountsDiscoverer added in v1.12.0

func NewGraphicsMountsDiscoverer(logger logger.Interface, driverRoot string, nvidiaCTKPath string) (Discover, error)

NewGraphicsMountsDiscoverer creates a discoverer for the mounts required by graphics tools such as vulkan.

func NewIPCDiscoverer added in v1.13.0

func NewIPCDiscoverer(logger logger.Interface, driverRoot string) (Discover, error)

NewIPCDiscoverer creats a discoverer for NVIDIA IPC sockets.

func NewLDCacheUpdateHook

func NewLDCacheUpdateHook(logger logger.Interface, mounts Discover, nvidiaCTKPath string) (Discover, error)

NewLDCacheUpdateHook creates a discoverer that updates the ldcache for the specified mounts. A logger can also be specified

func NewMOFEDDiscoverer added in v1.11.0

func NewMOFEDDiscoverer(logger logger.Interface, root string) (Discover, error)

NewMOFEDDiscoverer creates a discoverer for MOFED devices.

func NewMounts added in v1.11.0

func NewMounts(logger logger.Interface, lookup lookup.Locator, root string, required []string) Discover

NewMounts creates a discoverer for the required mounts using the specified locator.

type DiscoverMock

type DiscoverMock struct {
	// DevicesFunc mocks the Devices method.
	DevicesFunc func() ([]Device, error)

	// HooksFunc mocks the Hooks method.
	HooksFunc func() ([]Hook, error)

	// MountsFunc mocks the Mounts method.
	MountsFunc func() ([]Mount, error)
	// contains filtered or unexported fields
}

DiscoverMock is a mock implementation of Discover.

func TestSomethingThatUsesDiscover(t *testing.T) {

	// make and configure a mocked Discover
	mockedDiscover := &DiscoverMock{
		DevicesFunc: func() ([]Device, error) {
			panic("mock out the Devices method")
		},
		HooksFunc: func() ([]Hook, error) {
			panic("mock out the Hooks method")
		},
		MountsFunc: func() ([]Mount, error) {
			panic("mock out the Mounts method")
		},
	}

	// use mockedDiscover in code that requires Discover
	// and then make assertions.

}

func (*DiscoverMock) Devices

func (mock *DiscoverMock) Devices() ([]Device, error)

Devices calls DevicesFunc.

func (*DiscoverMock) DevicesCalls

func (mock *DiscoverMock) DevicesCalls() []struct {
}

DevicesCalls gets all the calls that were made to Devices. Check the length with:

len(mockedDiscover.DevicesCalls())

func (*DiscoverMock) Hooks

func (mock *DiscoverMock) Hooks() ([]Hook, error)

Hooks calls HooksFunc.

func (*DiscoverMock) HooksCalls

func (mock *DiscoverMock) HooksCalls() []struct {
}

HooksCalls gets all the calls that were made to Hooks. Check the length with:

len(mockedDiscover.HooksCalls())

func (*DiscoverMock) Mounts

func (mock *DiscoverMock) Mounts() ([]Mount, error)

Mounts calls MountsFunc.

func (*DiscoverMock) MountsCalls

func (mock *DiscoverMock) MountsCalls() []struct {
}

MountsCalls gets all the calls that were made to Mounts. Check the length with:

len(mockedDiscover.MountsCalls())

type Filter added in v1.12.0

type Filter interface {
	DeviceIsSelected(device Device) bool
}

Filter defines an interface for filtering discovered entities

type Hook

type Hook struct {
	Lifecycle string
	Path      string
	Args      []string
}

Hook represents a discovered hook.

func CreateLDCacheUpdateHook added in v1.12.0

func CreateLDCacheUpdateHook(executable string, libraries []string) Hook

CreateLDCacheUpdateHook locates the NVIDIA Container Toolkit CLI and creates a hook for updating the LD Cache

func CreateNvidiaCTKHook added in v1.12.0

func CreateNvidiaCTKHook(nvidiaCTKPath string, hookName string, additionalArgs ...string) Hook

CreateNvidiaCTKHook creates a hook which invokes the NVIDIA Container CLI hook subcommand.

func (Hook) Devices added in v1.13.0

func (h Hook) Devices() ([]Device, error)

Devices returns an empty list of devices for a Hook discoverer.

func (Hook) Hooks added in v1.13.0

func (h Hook) Hooks() ([]Hook, error)

Hooks allows the Hook type to also implement the Discoverer interface. It returns a single hook

func (Hook) Mounts added in v1.13.0

func (h Hook) Mounts() ([]Mount, error)

Mounts returns an empty list of mounts for a Hook discoverer.

type Mount

type Mount struct {
	HostPath string
	Path     string
	Options  []string
}

Mount represents a discovered mount.

type None

type None struct{}

None is a null discoverer that returns an empty list of devices and mounts.

func (None) Devices

func (e None) Devices() ([]Device, error)

Devices returns an empty list of devices

func (None) Hooks

func (e None) Hooks() ([]Hook, error)

Hooks returns an empty list of hooks

func (None) Mounts

func (e None) Mounts() ([]Mount, error)

Mounts returns an empty list of mounts

Jump to

Keyboard shortcuts

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