5959 Usage : "File holding line-separated regex-patterns to be allowed (comments allowed, use #)" ,
6060 EnvVar : "DOXY_PATTERN_FILE" ,
6161 }
62+ deviceFileFlag = cli.StringFlag {
63+ Name : "device-file" ,
64+ Value : proxy .DEVICE_FILE ,
65+ Usage : "File holding line-separated devices to be mapped in when in (GPU|HPC) mode (comments allowed, use #)" ,
66+ EnvVar : "DOXY_DEVICE_FILE" ,
67+ }
6268)
6369
6470func EvalOptions (cfg * config.Config ) (po []proxy.ProxyOption ) {
@@ -90,10 +96,25 @@ func EvalPatternOpts(cfg *config.Config) (proxy.ProxyOption) {
9096 os .Exit (1 )
9197
9298 }
93- patterns , err = proxy .ReadPatterns (reader )
99+ patterns , err = proxy .ReadLineFile (reader )
94100 return proxy .WithPatterns (patterns )
95101}
96102
103+ func EvalDevicesOpts (cfg * config.Config ) (proxy.ProxyOption ) {
104+ deviceFile , _ := cfg .String ("device-file" )
105+ reader , err := os .Open (deviceFile )
106+ defer reader .Close ()
107+ devices := []string {}
108+ if err != nil {
109+ return proxy .WithPatterns (proxy .DEVICES )
110+ }
111+ devices , err = proxy .ReadLineFile (reader )
112+ if err != nil {
113+ log .Printf ("Error while reading device file: %s" , err .Error ())
114+ }
115+ return proxy .WithDevMappings (devices )
116+ }
117+
97118func EvalBindMountOpts (cfg * config.Config ) (proxy.ProxyOption ) {
98119 bindStr , _ := cfg .String ("add-binds" )
99120 bindMounts := strings .Split (bindStr ,"," )
@@ -106,6 +127,7 @@ func RunApp(ctx *cli.Context) {
106127 cfg := config .NewConfig ([]config.Provider {config .NewCLI (ctx , true )})
107128 po := EvalOptions (cfg )
108129 po = append (po , EvalPatternOpts (cfg ))
130+ po = append (po , EvalDevicesOpts (cfg ))
109131 po = append (po , EvalBindMountOpts (cfg ))
110132 p := proxy .NewProxy (po ... )
111133 p .Run ()
@@ -121,6 +143,7 @@ func main() {
121143 proxySocketFlag ,
122144 debugFlag ,
123145 gpuEnabled ,
146+ deviceFileFlag ,
124147 patternFileFlag ,
125148 proxyPatternKey ,
126149 bindAddFlag ,
0 commit comments