config

package
v1.17.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultExecutableDir specifies the default path to use for executables if they cannot be located in the path.
	DefaultExecutableDir = "/usr/bin"

	// NVIDIAContainerRuntimeHookExecutable is the executable name for the NVIDIA Container Runtime Hook
	NVIDIAContainerRuntimeHookExecutable = "nvidia-container-runtime-hook"
	// NVIDIAContainerToolkitExecutable is the executable name for the NVIDIA Container Toolkit (an alias for the NVIDIA Container Runtime Hook)
	NVIDIAContainerToolkitExecutable = "nvidia-container-toolkit"
)

Functions

func GetConfigFilePath added in v1.14.0

func GetConfigFilePath() string

GetConfigFilePath returns the path to the config file for the configured system

func NormalizeLDConfigPath added in v1.15.0

func NormalizeLDConfigPath(path string) string

NormalizeLDConfigPath returns the resolved path of the configured LDConfig binary. This is only done for host LDConfigs and is required to handle systems where /sbin/ldconfig is a wrapper around /sbin/ldconfig.real.

func ResolveNVIDIACDIHookPath added in v1.16.0

func ResolveNVIDIACDIHookPath(logger logger.Interface, nvidiaCDIHookPath string) string

ResolveNVIDIACDIHookPath resolves the path to the nvidia-cdi-hook binary. This executable is used in hooks and needs to be an absolute path. If the path is specified as an absolute path, it is used directly without checking for existence of an executable at that path.

func ResolveNVIDIACTKPath deprecated added in v1.14.0

func ResolveNVIDIACTKPath(logger logger.Interface, nvidiaCTKPath string) string

ResolveNVIDIACTKPath resolves the path to the nvidia-ctk binary. This executable is used in hooks and needs to be an absolute path. If the path is specified as an absolute path, it is used directly without checking for existence of an executable at that path.

Deprecated: Use ResolveNVIDIACDIHookPath directly instead.

func ResolveNVIDIAContainerRuntimeHookPath added in v1.13.2

func ResolveNVIDIAContainerRuntimeHookPath(logger logger.Interface, nvidiaContainerRuntimeHookPath string) string

ResolveNVIDIAContainerRuntimeHookPath resolves the path the nvidia-container-runtime-hook binary.

Types

type CTKConfig

type CTKConfig struct {
	Path string `toml:"path"`
}

CTKConfig stores the config options for the NVIDIA Container Toolkit CLI (nvidia-ctk)

type Config

type Config struct {
	DisableRequire                 bool   `toml:"disable-require"`
	SwarmResource                  string `toml:"swarm-resource"`
	AcceptEnvvarUnprivileged       bool   `toml:"accept-nvidia-visible-devices-envvar-when-unprivileged"`
	AcceptDeviceListAsVolumeMounts bool   `toml:"accept-nvidia-visible-devices-as-volume-mounts"`
	SupportedDriverCapabilities    string `toml:"supported-driver-capabilities"`

	NVIDIAContainerCLIConfig         ContainerCLIConfig `toml:"nvidia-container-cli"`
	NVIDIACTKConfig                  CTKConfig          `toml:"nvidia-ctk"`
	NVIDIAContainerRuntimeConfig     RuntimeConfig      `toml:"nvidia-container-runtime"`
	NVIDIAContainerRuntimeHookConfig RuntimeHookConfig  `toml:"nvidia-container-runtime-hook"`

	// Features allows for finer control over optional features.
	Features features `toml:"features,omitempty"`
}

Config represents the contents of the config.toml file for the NVIDIA Container Toolkit Note: This is currently duplicated by the HookConfig in cmd/nvidia-container-toolkit/hook_config.go

func GetConfig

func GetConfig() (*Config, error)

GetConfig sets up the config struct. Values are read from a toml file or set via the environment.

func GetDefault added in v1.14.0

func GetDefault() (*Config, error)

GetDefault defines the default values for the config

type ContainerCLIConfig

type ContainerCLIConfig struct {
	Root        string   `toml:"root"`
	Path        string   `toml:"path"`
	Environment []string `toml:"environment"`
	Debug       string   `toml:"debug"`
	Ldcache     string   `toml:"ldcache"`
	LoadKmods   bool     `toml:"load-kmods"`
	// NoPivot disables the pivot root operation in the NVIDIA Container CLI.
	// This is not exposed in the config if not set.
	NoPivot   bool   `toml:"no-pivot,omitempty"`
	NoCgroups bool   `toml:"no-cgroups"`
	User      string `toml:"user"`
	Ldconfig  string `toml:"ldconfig"`
}

ContainerCLIConfig stores the options for the nvidia-container-cli

func (*ContainerCLIConfig) NormalizeLDConfigPath added in v1.15.0

func (c *ContainerCLIConfig) NormalizeLDConfigPath() string

NormalizeLDConfigPath returns the resolved path of the configured LDConfig binary. This is only done for host LDConfigs and is required to handle systems where /sbin/ldconfig is a wrapper around /sbin/ldconfig.real.

type Option added in v1.14.0

type Option func(*options)

Option is a functional option for loading TOML config files.

func WithConfigFile added in v1.14.0

func WithConfigFile(configFile string) Option

WithConfigFile sets the config file option.

func WithRequired added in v1.14.1

func WithRequired(required bool) Option

WithRequired sets the required option. If this is set to true, a failure to open the specified file is treated as an error

type RuntimeConfig

type RuntimeConfig struct {
	DebugFilePath string `toml:"debug"`
	// LogLevel defines the logging level for the application
	LogLevel string `toml:"log-level"`
	// Runtimes defines the candidates for the low-level runtime
	Runtimes []string    `toml:"runtimes"`
	Mode     string      `toml:"mode"`
	Modes    modesConfig `toml:"modes"`
}

RuntimeConfig stores the config options for the NVIDIA Container Runtime

func GetDefaultRuntimeConfig

func GetDefaultRuntimeConfig() (*RuntimeConfig, error)

GetDefaultRuntimeConfig defines the default values for the config

type RuntimeHookConfig added in v1.13.0

type RuntimeHookConfig struct {
	// Path specifies the path to the NVIDIA Container Runtime hook binary.
	// If an executable name is specified, this will be resolved in the path.
	Path string `toml:"path"`
	// SkipModeDetection disables the mode check for the runtime hook.
	SkipModeDetection bool `toml:"skip-mode-detection"`
}

RuntimeHookConfig stores the config options for the NVIDIA Container Runtime

func GetDefaultRuntimeHookConfig added in v1.13.0

func GetDefaultRuntimeHookConfig() (*RuntimeHookConfig, error)

GetDefaultRuntimeHookConfig defines the default values for the config

type Toml added in v1.14.0

type Toml toml.Tree

Toml is a type for the TOML representation of a config.

func New added in v1.14.0

func New(opts ...Option) (*Toml, error)

New creates a new toml tree based on the provided options

func (*Toml) Config added in v1.14.0

func (t *Toml) Config() (*Config, error)

Config returns the typed config associated with the toml tree.

func (*Toml) Delete added in v1.14.0

func (t *Toml) Delete(key string) error

Delete deletes the specified key from the TOML config.

func (*Toml) Get added in v1.14.0

func (t *Toml) Get(key string) interface{}

Get returns the value for the specified key.

func (*Toml) GetDefault added in v1.17.0

func (t *Toml) GetDefault(key string, def interface{}) interface{}

GetDefault returns the value for the specified key and falls back to the default value if the Get call fails

func (*Toml) Save added in v1.14.0

func (t *Toml) Save(w io.Writer) (int64, error)

Save saves the config to the specified Writer.

func (*Toml) Set added in v1.14.0

func (t *Toml) Set(key string, value interface{})

Set sets the specified key to the specified value in the TOML config.

func (*Toml) Unmarshal added in v1.14.0

func (t *Toml) Unmarshal(v interface{}) error

Unmarshal wraps the toml.Tree Unmarshal function.

func (*Toml) WriteTo added in v1.17.0

func (t *Toml) WriteTo(w io.Writer) (int64, error)

WriteTo encode the Tree as Toml and writes it to the writer w. Returns the number of bytes written in case of success, or an error if anything happened.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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