Skip to content

Commit 667881d

Browse files
authored
Merge pull request #1 from elezar/separate-hook-binary
Separate hook binary
2 parents 0b65105 + 879e6fc commit 667881d

File tree

4 files changed

+42
-17
lines changed

4 files changed

+42
-17
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# NVIDIA Container Toolkit Changelog
22

3+
* Move `nvidia-ctk hook` commands to a separate `nvidia-cdi-hook` binary. The same subcommands are supported.
4+
35
## v1.15.0
46

57
* Remove `nvidia-container-runtime` and `nvidia-docker2` packages.
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
# Copyright 2024 NVIDIA CORPORATION
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
**/
16+
17+
package commands
18+
19+
import (
20+
"github.com/urfave/cli/v2"
21+
22+
"github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/chmod"
23+
symlinks "github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/create-symlinks"
24+
ldcache "github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/update-ldcache"
25+
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
26+
)
27+
28+
// New creates the commands associated with supported CDI hooks.
29+
// These are shared by the nvidia-cdi-hook and nvidia-ctk hook commands.
30+
func New(logger logger.Interface) []*cli.Command {
31+
return []*cli.Command{
32+
ldcache.NewCommand(logger),
33+
symlinks.NewCommand(logger),
34+
chmod.NewCommand(logger),
35+
}
36+
}

cmd/nvidia-cdi-hook/main.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ import (
2525

2626
cli "github.com/urfave/cli/v2"
2727

28-
chmod "github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/chmod"
29-
symlinks "github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/create-symlinks"
30-
ldcache "github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/update-ldcache"
28+
"github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/commands"
3129
)
3230

3331
// options defines the options that can be set for the CLI through config files,
@@ -84,11 +82,7 @@ func main() {
8482
}
8583

8684
// Define the subcommands
87-
c.Commands = []*cli.Command{
88-
ldcache.NewCommand(logger),
89-
symlinks.NewCommand(logger),
90-
chmod.NewCommand(logger),
91-
}
85+
c.Commands = commands.New(logger)
9286

9387
// Run the CLI
9488
err := c.Run(os.Args)

cmd/nvidia-ctk/hook/hook.go

+2-9
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717
package hook
1818

1919
import (
20-
chmod "github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/chmod"
20+
"github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/commands"
2121
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
2222

2323
"github.com/urfave/cli/v2"
24-
25-
symlinks "github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/create-symlinks"
26-
ldcache "github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-cdi-hook/update-ldcache"
2724
)
2825

2926
type hookCommand struct {
@@ -46,11 +43,7 @@ func (m hookCommand) build() *cli.Command {
4643
Usage: "A collection of hooks that may be injected into an OCI spec",
4744
}
4845

49-
hook.Subcommands = []*cli.Command{
50-
ldcache.NewCommand(m.logger),
51-
symlinks.NewCommand(m.logger),
52-
chmod.NewCommand(m.logger),
53-
}
46+
hook.Subcommands = commands.New(m.logger)
5447

5548
return &hook
5649
}

0 commit comments

Comments
 (0)