File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -45,3 +45,13 @@ const (
4545 // This was added with v1.17.5 of the NVIDIA Container Toolkit.
4646 HookEnableCudaCompat = HookName ("enable-cuda-compat" )
4747)
48+
49+ // A FeatureFlag refers to a specific feature that can be toggled in the CDI api.
50+ // All features are off by default.
51+ type FeatureFlag string
52+
53+ const (
54+ // FeatureDisableNvsandboxUtils disables the use of nvsandboxutils when
55+ // querying devices.
56+ FeatureDisableNvsandboxUtils = FeatureFlag ("disable-nvsandbox-utils" )
57+ )
Original file line number Diff line number Diff line change @@ -56,6 +56,8 @@ type nvcdilib struct {
5656
5757 mergedDeviceOptions []transform.MergedDeviceOption
5858
59+ featureFlags map [FeatureFlag ]bool
60+
5961 disabledHooks disabledHooks
6062 hookCreator discover.HookCreator
6163}
@@ -64,6 +66,7 @@ type nvcdilib struct {
6466func New (opts ... Option ) (Interface , error ) {
6567 l := & nvcdilib {
6668 disabledHooks : make (disabledHooks ),
69+ featureFlags : make (map [FeatureFlag ]bool ),
6770 }
6871 for _ , opt := range opts {
6972 opt (l )
@@ -218,6 +221,9 @@ func (l *nvcdilib) getCudaVersionNvsandboxutils() (string, error) {
218221// getNvsandboxUtilsLib returns the nvsandboxutilslib to use for CDI spec
219222// generation.
220223func (l * nvcdilib ) getNvsandboxUtilsLib () nvsandboxutils.Interface {
224+ if l .featureFlags [FeatureDisableNvsandboxUtils ] {
225+ return nil
226+ }
221227 if l .nvsandboxutilslib != nil {
222228 return l .nvsandboxutilslib
223229 }
Original file line number Diff line number Diff line change @@ -166,3 +166,14 @@ func WithDisabledHook(hook HookName) Option {
166166 o .disabledHooks [hook ] = true
167167 }
168168}
169+
170+ // WithFeatureFlag allows specified features to be toggled on.
171+ // This option can be specified multiple times for each feature flag.
172+ func WithFeatureFlag (featureFlag FeatureFlag ) Option {
173+ return func (o * nvcdilib ) {
174+ if o .featureFlags == nil {
175+ o .featureFlags = make (map [FeatureFlag ]bool )
176+ }
177+ o .featureFlags [featureFlag ] = true
178+ }
179+ }
You can’t perform that action at this time.
0 commit comments