Skip to content

Commit 7f412cd

Browse files
committed
[no-relnote] Set Commands in declaration
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 0f823e6 commit 7f412cd

File tree

9 files changed

+30
-39
lines changed

9 files changed

+30
-39
lines changed

cmd/nvidia-cdi-hook/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ func main() {
4949
Name: "NVIDIA CDI Hook",
5050
Usage: "Command to structure files for usage inside a container, called as hooks from a container runtime, defined in a CDI yaml file",
5151
Version: info.GetVersionString(),
52-
// Define the subcommands
53-
Commands: commands.New(logger),
5452
// Set log-level for all subcommands
5553
Before: func(ctx context.Context, cmd *cli.Command) (context.Context, error) {
5654
logLevel := logrus.InfoLevel
@@ -74,6 +72,8 @@ func main() {
7472
commands.IssueUnsupportedHookWarning(logger, cmd)
7573
return nil
7674
},
75+
// Define the subcommands
76+
Commands: commands.New(logger),
7777
}
7878

7979
// Setup the flags for this command

cmd/nvidia-ctk/cdi/cdi.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ func (m command) build() *cli.Command {
4343
cdi := cli.Command{
4444
Name: "cdi",
4545
Usage: "Provide tools for interacting with Container Device Interface specifications",
46-
}
47-
48-
cdi.Commands = []*cli.Command{
49-
generate.NewCommand(m.logger),
50-
transform.NewCommand(m.logger),
51-
list.NewCommand(m.logger),
46+
Commands: []*cli.Command{
47+
generate.NewCommand(m.logger),
48+
transform.NewCommand(m.logger),
49+
list.NewCommand(m.logger),
50+
},
5251
}
5352

5453
return &cdi

cmd/nvidia-ctk/cdi/transform/transform.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ func (m command) build() *cli.Command {
4040
c := cli.Command{
4141
Name: "transform",
4242
Usage: "Apply a transform to a CDI specification",
43+
Commands: []*cli.Command{
44+
root.NewCommand(m.logger),
45+
},
4346
}
4447

4548
c.Flags = []cli.Flag{}
4649

47-
c.Commands = []*cli.Command{
48-
root.NewCommand(m.logger),
49-
}
50-
5150
return &c
5251
}

cmd/nvidia-ctk/config/config.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ func (m command) build() *cli.Command {
6767
Action: func(ctx context.Context, cmd *cli.Command) error {
6868
return m.run(&opts)
6969
},
70+
Commands: []*cli.Command{
71+
createdefault.NewCommand(m.logger),
72+
},
7073
}
7174

7275
c.Flags = []cli.Flag{
@@ -107,10 +110,6 @@ func (m command) build() *cli.Command {
107110
},
108111
}
109112

110-
c.Commands = []*cli.Command{
111-
createdefault.NewCommand(m.logger),
112-
}
113-
114113
return &c
115114
}
116115

cmd/nvidia-ctk/hook/hook.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ func (m hookCommand) build() *cli.Command {
5454
commands.IssueUnsupportedHookWarning(m.logger, cmd)
5555
return nil
5656
},
57+
Commands: commands.New(m.logger),
5758
}
5859

59-
hook.Commands = commands.New(m.logger)
60-
6160
return &hook
6261
}

cmd/nvidia-ctk/info/info.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,5 @@ func (m command) build() *cli.Command {
4242
Usage: "Provide information about the system",
4343
}
4444

45-
info.Commands = []*cli.Command{}
46-
4745
return &info
4846
}

cmd/nvidia-ctk/main.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ func main() {
6868
logger.SetLevel(logLevel)
6969
return ctx, nil
7070
},
71+
// Define the subcommands
72+
Commands: []*cli.Command{
73+
hook.NewCommand(logger),
74+
runtime.NewCommand(logger),
75+
infoCLI.NewCommand(logger),
76+
cdi.NewCommand(logger),
77+
system.NewCommand(logger),
78+
config.NewCommand(logger),
79+
},
7180
}
7281

7382
// Setup the flags for this command
@@ -87,16 +96,6 @@ func main() {
8796
},
8897
}
8998

90-
// Define the subcommands
91-
c.Commands = []*cli.Command{
92-
hook.NewCommand(logger),
93-
runtime.NewCommand(logger),
94-
infoCLI.NewCommand(logger),
95-
cdi.NewCommand(logger),
96-
system.NewCommand(logger),
97-
config.NewCommand(logger),
98-
}
99-
10099
// Run the CLI
101100
err := c.Run(context.Background(), os.Args)
102101
if err != nil {

cmd/nvidia-ctk/runtime/runtime.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ func (m runtimeCommand) build() *cli.Command {
4040
runtime := cli.Command{
4141
Name: "runtime",
4242
Usage: "A collection of runtime-related utilities for the NVIDIA Container Toolkit",
43-
}
44-
45-
runtime.Commands = []*cli.Command{
46-
configure.NewCommand(m.logger),
43+
Commands: []*cli.Command{
44+
configure.NewCommand(m.logger),
45+
},
4746
}
4847

4948
return &runtime

cmd/nvidia-ctk/system/system.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ func (m command) build() *cli.Command {
4141
system := cli.Command{
4242
Name: "system",
4343
Usage: "A collection of system-related utilities for the NVIDIA Container Toolkit",
44-
}
45-
46-
system.Commands = []*cli.Command{
47-
devchar.NewCommand(m.logger),
48-
devicenodes.NewCommand(m.logger),
44+
Commands: []*cli.Command{
45+
devchar.NewCommand(m.logger),
46+
devicenodes.NewCommand(m.logger),
47+
},
4948
}
5049

5150
return &system

0 commit comments

Comments
 (0)