From 9de63619382e09ca0e8af3606a8d70e660c6d4c0 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Wed, 28 Sep 2022 13:39:11 +0200 Subject: [PATCH] Update vendoring Signed-off-by: Evan Lezar --- go.mod | 4 +- go.sum | 4 ++ .../pkg/{nvinfo => nvlib/info}/info.go | 25 +++++++++--- .../go-nvlib/pkg/nvlib/info/options.go | 39 +++++++++++++++++++ vendor/modules.txt | 6 +-- 5 files changed, 67 insertions(+), 11 deletions(-) rename vendor/gitlab.com/nvidia/cloud-native/go-nvlib/pkg/{nvinfo => nvlib/info}/info.go (76%) create mode 100644 vendor/gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/info/options.go diff --git a/go.mod b/go.mod index 1d884f12..15adb278 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.14 require ( github.com/BurntSushi/toml v1.0.0 - github.com/NVIDIA/go-nvml v0.11.6-0.0.20220715143214-a79f46f2a6f7 + github.com/NVIDIA/go-nvml v0.11.6-0.0.20220823120812-7e2082095e82 github.com/container-orchestrated-devices/container-device-interface v0.4.1-0.20220614144320-dc973e22f674 github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect github.com/kr/text v0.2.0 // indirect @@ -17,7 +17,7 @@ require ( github.com/urfave/cli v1.22.4 // indirect github.com/urfave/cli/v2 v2.3.0 github.com/xeipuuv/gojsonpointer v0.0.0-20190809123943-df4f5c81cb3b // indirect - gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20220725232003-c7f47cb02a33 + gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20220922133427-1049a7fa76a9 golang.org/x/mod v0.5.0 golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect diff --git a/go.sum b/go.sum index a4063e8f..12f9cc3b 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/NVIDIA/go-nvml v0.11.6-0.0.20220614115128-31f8b89eb740/go.mod h1:hy7HYeQy335x6nEss0Ne3PYqleRa6Ct+VKD9RQ4nyFs= github.com/NVIDIA/go-nvml v0.11.6-0.0.20220715143214-a79f46f2a6f7 h1:yl06QAxbf3g3VZX5/7CaZfTUZqFztdZZvlq0TfAvQrk= github.com/NVIDIA/go-nvml v0.11.6-0.0.20220715143214-a79f46f2a6f7/go.mod h1:hy7HYeQy335x6nEss0Ne3PYqleRa6Ct+VKD9RQ4nyFs= +github.com/NVIDIA/go-nvml v0.11.6-0.0.20220823120812-7e2082095e82 h1:x751Xx1tdxkiA/sdkv2J769n21UbYKzVOpe9S/h1M3k= +github.com/NVIDIA/go-nvml v0.11.6-0.0.20220823120812-7e2082095e82/go.mod h1:hy7HYeQy335x6nEss0Ne3PYqleRa6Ct+VKD9RQ4nyFs= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= @@ -297,6 +299,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20220725232003-c7f47cb02a33 h1:YnWOCWHjoQtpzKUo/ihqs0ldj+GJ2qJ4QhLctMwzcKk= gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20220725232003-c7f47cb02a33/go.mod h1:SIbXUP9E8o3uWK6MMfX6Oi9ABkUqhPSX8W8VdVWkYI4= +gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20220922133427-1049a7fa76a9 h1:3C1cK0/n1HGfH0MPCCPRntK8xPNlrVq9OWR4RA72jW0= +gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20220922133427-1049a7fa76a9/go.mod h1:GStidGxhaqJhYFW1YpOnLvYCbL2EsM0od7IW4u7+JgU= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= diff --git a/vendor/gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvinfo/info.go b/vendor/gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/info/info.go similarity index 76% rename from vendor/gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvinfo/info.go rename to vendor/gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/info/info.go index e7319bb0..a901d547 100644 --- a/vendor/gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvinfo/info.go +++ b/vendor/gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/info/info.go @@ -14,18 +14,31 @@ # limitations under the License. **/ -package nvinfo +package info import ( "fmt" "os" + "path/filepath" "strings" "github.com/NVIDIA/go-nvml/pkg/dl" ) -// HasNVML returns true if NVML is detected on the system -func HasNVML() (bool, string) { +// Interface provides the API to the info package +type Interface interface { + HasNvml() (bool, string) + IsTegraSystem() (bool, string) +} + +type infolib struct { + root string +} + +var _ Interface = &infolib{} + +// HasNvml returns true if NVML is detected on the system +func (i *infolib) HasNvml() (bool, string) { const ( nvmlLibraryName = "libnvidia-ml.so.1" nvmlLibraryLoadFlags = dl.RTLD_LAZY @@ -40,9 +53,9 @@ func HasNVML() (bool, string) { } // IsTegraSystem returns true if the system is detected as a Tegra-based system -func IsTegraSystem() (bool, string) { - const tegraReleaseFile = "/etc/nv_tegra_release" - const tegraFamilyFile = "/sys/devices/soc0/family" +func (i *infolib) IsTegraSystem() (bool, string) { + tegraReleaseFile := filepath.Join(i.root, "/etc/nv_tegra_release") + tegraFamilyFile := filepath.Join(i.root, "/sys/devices/soc0/family") if info, err := os.Stat(tegraReleaseFile); err == nil && !info.IsDir() { return true, fmt.Sprintf("%v found", tegraReleaseFile) diff --git a/vendor/gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/info/options.go b/vendor/gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/info/options.go new file mode 100644 index 00000000..314efa67 --- /dev/null +++ b/vendor/gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/info/options.go @@ -0,0 +1,39 @@ +/** +# Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +**/ + +package info + +// Option defines a function for passing options to the New() call +type Option func(*infolib) + +// New creates a new instance of the 'info' interface +func New(opts ...Option) Interface { + i := &infolib{} + for _, opt := range opts { + opt(i) + } + if i.root == "" { + i.root = "/" + } + return i +} + +// WithRoot provides a Option to set the root of the 'info' interface +func WithRoot(root string) Option { + return func(i *infolib) { + i.root = root + } +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 5afba1a9..c11ef60e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -2,7 +2,7 @@ ## explicit github.com/BurntSushi/toml github.com/BurntSushi/toml/internal -# github.com/NVIDIA/go-nvml v0.11.6-0.0.20220715143214-a79f46f2a6f7 +# github.com/NVIDIA/go-nvml v0.11.6-0.0.20220823120812-7e2082095e82 ## explicit github.com/NVIDIA/go-nvml/pkg/dl # github.com/blang/semver v3.5.1+incompatible @@ -74,9 +74,9 @@ github.com/xeipuuv/gojsonpointer github.com/xeipuuv/gojsonreference # github.com/xeipuuv/gojsonschema v1.2.0 github.com/xeipuuv/gojsonschema -# gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20220725232003-c7f47cb02a33 +# gitlab.com/nvidia/cloud-native/go-nvlib v0.0.0-20220922133427-1049a7fa76a9 ## explicit -gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvinfo +gitlab.com/nvidia/cloud-native/go-nvlib/pkg/nvlib/info # golang.org/x/mod v0.5.0 ## explicit golang.org/x/mod/semver