File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,9 +69,12 @@ func WithGPUs(opts ...Opts) oci.SpecOpts {
6969 return err
7070 }
7171 }
72- path , err := exec .LookPath ("containerd" )
73- if err != nil {
74- return err
72+ if c .OCIHookPath == "" {
73+ path , err := exec .LookPath ("containerd" )
74+ if err != nil {
75+ return err
76+ }
77+ c .OCIHookPath = path
7578 }
7679 nvidiaPath , err := exec .LookPath (nvidiaCLI )
7780 if err != nil {
@@ -81,7 +84,7 @@ func WithGPUs(opts ...Opts) oci.SpecOpts {
8184 s .Hooks = & specs.Hooks {}
8285 }
8386 s .Hooks .Prestart = append (s .Hooks .Prestart , specs.Hook {
84- Path : path ,
87+ Path : c . OCIHookPath ,
8588 Args : append ([]string {
8689 "containerd" ,
8790 "oci-hook" ,
@@ -101,6 +104,7 @@ type config struct {
101104 LDCache string
102105 LDConfig string
103106 Requirements []string
107+ OCIHookPath string
104108}
105109
106110func (c * config ) args () []string {
@@ -179,3 +183,23 @@ func WithRequiredCUDAVersion(major, minor int) Opts {
179183 return nil
180184 }
181185}
186+
187+ // WithOCIHookPath sets the hook path for the binary
188+ func WithOCIHookPath (path string ) Opts {
189+ return func (c * config ) error {
190+ c .OCIHookPath = path
191+ return nil
192+ }
193+ }
194+
195+ // WithLookupOCIHookPath sets the hook path for the binary via a binary name
196+ func WithLookupOCIHookPath (name string ) Opts {
197+ return func (c * config ) error {
198+ path , err := exec .LookPath (name )
199+ if err != nil {
200+ return err
201+ }
202+ c .OCIHookPath = path
203+ return nil
204+ }
205+ }
You can’t perform that action at this time.
0 commit comments