mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-25 21:39:10 +00:00
FIX: Factor out specModifier construction into function
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
e6730fd0f0
commit
11aa1d2a7d
@ -44,14 +44,9 @@ func newNVIDIAContainerRuntime(logger *logrus.Logger, cfg *config.Config, argv [
|
||||
return nil, fmt.Errorf("error constructing low-level runtime: %v", err)
|
||||
}
|
||||
|
||||
var specModifier oci.SpecModifier
|
||||
if cfg.NVIDIAContainerRuntimeConfig.Experimental {
|
||||
specModifier, err = modifier.NewExperimentalModifier(logger, cfg)
|
||||
specModifier, err := newSpecModifier(logger, cfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to construct experimental modifier: %v", err)
|
||||
}
|
||||
} else {
|
||||
specModifier = modifier.NewStableRuntimeModifier(logger)
|
||||
return nil, fmt.Errorf("failed to construct OCI spec modifier: %v", err)
|
||||
}
|
||||
|
||||
// Create the wrapping runtime with the specified modifier
|
||||
@ -64,3 +59,12 @@ func newNVIDIAContainerRuntime(logger *logrus.Logger, cfg *config.Config, argv [
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// newSpecModifier is a factory method that creates constructs an OCI spec modifer based on the provided config.
|
||||
func newSpecModifier(logger *logrus.Logger, cfg *config.Config) (oci.SpecModifier, error) {
|
||||
if !cfg.NVIDIAContainerRuntimeConfig.Experimental {
|
||||
return modifier.NewStableRuntimeModifier(logger), nil
|
||||
}
|
||||
|
||||
return modifier.NewExperimentalModifier(logger, cfg)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user