From 9ce690093d3b3dc0d583b6d94e54a29e55d212c6 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Wed, 6 Apr 2022 17:18:06 +0200 Subject: [PATCH] FIX: Make isNVIDIAContainerRuntimeHook mode idiomatic Signed-off-by: Evan Lezar --- cmd/nvidia-container-runtime/modifier/hook_remover.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/nvidia-container-runtime/modifier/hook_remover.go b/cmd/nvidia-container-runtime/modifier/hook_remover.go index 70067e2b..7df4b2f1 100644 --- a/cmd/nvidia-container-runtime/modifier/hook_remover.go +++ b/cmd/nvidia-container-runtime/modifier/hook_remover.go @@ -59,11 +59,12 @@ func (m nvidiaContainerRuntimeHookRemover) Modify(spec *specs.Spec) error { // or nvidia-container-toolkit hook. These are included, for example, by the non-experimental // nvidia-container-runtime or docker when specifying the --gpus flag. func isNVIDIAContainerRuntimeHook(hook *specs.Hook) bool { - lookFor := map[string]bool{ - nvidiaContainerRuntimeHookExecutable: true, - nvidiaContainerToolkitExecutable: true, + bins := map[string]struct{}{ + nvidiaContainerRuntimeHookExecutable: {}, + nvidiaContainerToolkitExecutable: {}, } - base := filepath.Base(hook.Path) - return lookFor[base] + _, exists := bins[filepath.Base(hook.Path)] + + return exists }