Change GPU device driver registration from init-time function assignment
to direct function exports.
This removes the init() function and global function variable pattern in
favor of a more explicit approach.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
| ... | ... |
@@ -10,13 +10,10 @@ import ( |
| 10 | 10 |
"github.com/moby/moby/v2/daemon/config" |
| 11 | 11 |
"github.com/moby/moby/v2/daemon/internal/capabilities" |
| 12 | 12 |
"github.com/opencontainers/runtime-spec/specs-go" |
| 13 |
- "tags.cncf.io/container-device-interface/pkg/cdi" |
|
| 14 | 13 |
) |
| 15 | 14 |
|
| 16 | 15 |
var deviceDrivers = map[string]*deviceDriver{}
|
| 17 | 16 |
|
| 18 |
-var RegisterGPUDeviceDrivers = func(_ *cdi.Cache) {}
|
|
| 19 |
- |
|
| 20 | 17 |
type deviceListing struct {
|
| 21 | 18 |
Devices []system.DeviceInfo |
| 22 | 19 |
Warnings []string |
| ... | ... |
@@ -2,14 +2,10 @@ package daemon |
| 2 | 2 |
|
| 3 | 3 |
import "tags.cncf.io/container-device-interface/pkg/cdi" |
| 4 | 4 |
|
| 5 |
-func init() {
|
|
| 6 |
- RegisterGPUDeviceDrivers = registerGPUDeviceDrivers |
|
| 7 |
-} |
|
| 8 |
- |
|
| 9 |
-// registerGPUDeviceDrivers registers GPU device drivers. |
|
| 5 |
+// RegisterGPUDeviceDrivers registers GPU device drivers. |
|
| 10 | 6 |
// If the cdiCache is provided, it is used to detect presence of CDI specs for AMD GPUs. |
| 11 | 7 |
// For NVIDIA GPUs, presence of CDI specs is detected by checking for the nvidia-cdi-hook binary. |
| 12 |
-func registerGPUDeviceDrivers(cdiCache *cdi.Cache) {
|
|
| 8 |
+func RegisterGPUDeviceDrivers(cdiCache *cdi.Cache) {
|
|
| 13 | 9 |
// Register NVIDIA device drivers. |
| 14 | 10 |
if nvidiaDrivers := getNVIDIADeviceDrivers(); len(nvidiaDrivers) > 0 {
|
| 15 | 11 |
for name, driver := range nvidiaDrivers {
|