From 19cfb2774dbe5127586ecc41355e5ca2e8371ec8 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Thu, 19 Jan 2023 10:37:10 +0100 Subject: [PATCH] Use common code to construct nvidia-ctk hooks Signed-off-by: Evan Lezar --- internal/discover/graphics.go | 15 +++++++-------- internal/discover/symlinks.go | 15 +++++++-------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/internal/discover/graphics.go b/internal/discover/graphics.go index c0f058da..7847314c 100644 --- a/internal/discover/graphics.go +++ b/internal/discover/graphics.go @@ -25,7 +25,6 @@ import ( "github.com/NVIDIA/nvidia-container-toolkit/internal/info/drm" "github.com/NVIDIA/nvidia-container-toolkit/internal/info/proc" "github.com/NVIDIA/nvidia-container-toolkit/internal/lookup" - "github.com/container-orchestrated-devices/container-device-interface/pkg/cdi" "github.com/sirupsen/logrus" ) @@ -130,18 +129,18 @@ func (d drmDevicesByPath) Hooks() ([]Hook, error) { return nil, nil } - args := []string{d.nvidiaCTKPath, "hook", "create-symlinks"} + var args []string for _, l := range links { args = append(args, "--link", l) } - h := Hook{ - Lifecycle: cdi.CreateContainerHook, - Path: d.nvidiaCTKPath, - Args: args, - } + hook := CreateNvidiaCTKHook( + d.nvidiaCTKPath, + "create-symlinks", + args..., + ) - return []Hook{h}, nil + return []Hook{hook}, nil } // getSpecificLinkArgs returns the required specic links that need to be created diff --git a/internal/discover/symlinks.go b/internal/discover/symlinks.go index a8f904c1..b5d344e3 100644 --- a/internal/discover/symlinks.go +++ b/internal/discover/symlinks.go @@ -21,7 +21,6 @@ import ( "path/filepath" "strings" - "github.com/container-orchestrated-devices/container-device-interface/pkg/cdi" "github.com/sirupsen/logrus" ) @@ -47,7 +46,7 @@ func NewCreateSymlinksHook(logger *logrus.Logger, csvFiles []string, mounts Disc // Hooks returns a hook to create the symlinks from the required CSV files func (d symlinks) Hooks() ([]Hook, error) { - args := []string{d.nvidiaCTKPath, "hook", "create-symlinks"} + var args []string for _, f := range d.csvFiles { args = append(args, "--csv-filename", f) } @@ -58,13 +57,13 @@ func (d symlinks) Hooks() ([]Hook, error) { } args = append(args, links...) - h := Hook{ - Lifecycle: cdi.CreateContainerHook, - Path: d.nvidiaCTKPath, - Args: args, - } + hook := CreateNvidiaCTKHook( + d.nvidiaCTKPath, + "create-symlinks", + args..., + ) - return []Hook{h}, nil + return []Hook{hook}, nil } // getSpecificLinkArgs returns the required specic links that need to be created