Skip to content

Commit f67c155

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

File tree

18 files changed

+494
-515
lines changed

18 files changed

+494
-515
lines changed

cmd/nvidia-cdi-hook/chmod/chmod.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,22 @@ func (m command) build() *cli.Command {
6565
Action: func(ctx context.Context, cmd *cli.Command) error {
6666
return m.run(cmd, &cfg)
6767
},
68-
}
69-
70-
c.Flags = []cli.Flag{
71-
&cli.StringSliceFlag{
72-
Name: "path",
73-
Usage: "Specify a path to apply the specified mode to",
74-
Destination: &cfg.paths,
75-
},
76-
&cli.StringFlag{
77-
Name: "mode",
78-
Usage: "Specify the file mode",
79-
Destination: &cfg.modeStr,
80-
},
81-
&cli.StringFlag{
82-
Name: "container-spec",
83-
Usage: "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN",
84-
Destination: &cfg.containerSpec,
68+
Flags: []cli.Flag{
69+
&cli.StringSliceFlag{
70+
Name: "path",
71+
Usage: "Specify a path to apply the specified mode to",
72+
Destination: &cfg.paths,
73+
},
74+
&cli.StringFlag{
75+
Name: "mode",
76+
Usage: "Specify the file mode",
77+
Destination: &cfg.modeStr,
78+
},
79+
&cli.StringFlag{
80+
Name: "container-spec",
81+
Usage: "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN",
82+
Destination: &cfg.containerSpec,
83+
},
8584
},
8685
}
8786

cmd/nvidia-cdi-hook/create-soname-symlinks/soname-symlinks.go

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,23 @@ func (m command) build() *cli.Command {
7575
Action: func(ctx context.Context, cmd *cli.Command) error {
7676
return m.run(cmd, &cfg)
7777
},
78-
}
79-
80-
c.Flags = []cli.Flag{
81-
&cli.StringSliceFlag{
82-
Name: "folder",
83-
Usage: "Specify a directory to generate soname symlinks in. Can be specified multiple times",
84-
Destination: &cfg.folders,
85-
},
86-
&cli.StringFlag{
87-
Name: "ldconfig-path",
88-
Usage: "Specify the path to ldconfig on the host",
89-
Destination: &cfg.ldconfigPath,
90-
Value: "/sbin/ldconfig",
91-
},
92-
&cli.StringFlag{
93-
Name: "container-spec",
94-
Usage: "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN",
95-
Destination: &cfg.containerSpec,
78+
Flags: []cli.Flag{
79+
&cli.StringSliceFlag{
80+
Name: "folder",
81+
Usage: "Specify a directory to generate soname symlinks in. Can be specified multiple times",
82+
Destination: &cfg.folders,
83+
},
84+
&cli.StringFlag{
85+
Name: "ldconfig-path",
86+
Usage: "Specify the path to ldconfig on the host",
87+
Destination: &cfg.ldconfigPath,
88+
Value: "/sbin/ldconfig",
89+
},
90+
&cli.StringFlag{
91+
Name: "container-spec",
92+
Usage: "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN",
93+
Destination: &cfg.containerSpec,
94+
},
9695
},
9796
}
9897

cmd/nvidia-cdi-hook/create-symlinks/create-symlinks.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,19 @@ func (m command) build() *cli.Command {
5959
Action: func(_ context.Context, cmd *cli.Command) error {
6060
return m.run(cmd, &cfg)
6161
},
62-
}
63-
64-
c.Flags = []cli.Flag{
65-
&cli.StringSliceFlag{
66-
Name: "link",
67-
Usage: "Specify a specific link to create. The link is specified as target::link. If the link exists in the container root, it is removed.",
68-
Destination: &cfg.links,
69-
},
70-
// The following flags are testing-only flags.
71-
&cli.StringFlag{
72-
Name: "container-spec",
73-
Usage: "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN. This is only intended for testing.",
74-
Destination: &cfg.containerSpec,
75-
Hidden: true,
62+
Flags: []cli.Flag{
63+
&cli.StringSliceFlag{
64+
Name: "link",
65+
Usage: "Specify a specific link to create. The link is specified as target::link. If the link exists in the container root, it is removed.",
66+
Destination: &cfg.links,
67+
},
68+
// The following flags are testing-only flags.
69+
&cli.StringFlag{
70+
Name: "container-spec",
71+
Usage: "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN. This is only intended for testing.",
72+
Destination: &cfg.containerSpec,
73+
Hidden: true,
74+
},
7675
},
7776
}
7877

cmd/nvidia-cdi-hook/cudacompat/cudacompat.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,19 @@ func (m command) build() *cli.Command {
7070
Action: func(ctx context.Context, cmd *cli.Command) error {
7171
return m.run(cmd, &cfg)
7272
},
73-
}
74-
75-
c.Flags = []cli.Flag{
76-
&cli.StringFlag{
77-
Name: "host-driver-version",
78-
Usage: "Specify the host driver version. If the CUDA compat libraries detected in the container do not have a higher MAJOR version, the hook is a no-op.",
79-
Destination: &cfg.hostDriverVersion,
80-
},
81-
&cli.StringFlag{
82-
Name: "container-spec",
83-
Hidden: true,
84-
Category: "testing-only",
85-
Usage: "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN",
86-
Destination: &cfg.containerSpec,
73+
Flags: []cli.Flag{
74+
&cli.StringFlag{
75+
Name: "host-driver-version",
76+
Usage: "Specify the host driver version. If the CUDA compat libraries detected in the container do not have a higher MAJOR version, the hook is a no-op.",
77+
Destination: &cfg.hostDriverVersion,
78+
},
79+
&cli.StringFlag{
80+
Name: "container-spec",
81+
Hidden: true,
82+
Category: "testing-only",
83+
Usage: "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN",
84+
Destination: &cfg.containerSpec,
85+
},
8786
},
8887
}
8988

cmd/nvidia-cdi-hook/disable-device-node-modification/disable-device-node-modification.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ func NewCommand(logger logger.Interface) *cli.Command {
5454
Action: func(ctx context.Context, cmd *cli.Command) error {
5555
return run(ctx, cmd, &cfg)
5656
},
57-
}
58-
59-
c.Flags = []cli.Flag{
60-
&cli.StringFlag{
61-
Name: "container-spec",
62-
Hidden: true,
63-
Usage: "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN",
64-
Destination: &cfg.containerSpec,
57+
Flags: []cli.Flag{
58+
&cli.StringFlag{
59+
Name: "container-spec",
60+
Hidden: true,
61+
Usage: "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN",
62+
Destination: &cfg.containerSpec,
63+
},
6564
},
6665
}
6766

cmd/nvidia-cdi-hook/main.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,22 @@ func main() {
7474
},
7575
// Define the subcommands
7676
Commands: commands.New(logger),
77-
}
78-
79-
// Setup the flags for this command
80-
c.Flags = []cli.Flag{
81-
&cli.BoolFlag{
82-
Name: "debug",
83-
Aliases: []string{"d"},
84-
Usage: "Enable debug-level logging",
85-
Destination: &opts.Debug,
86-
// TODO: Support for NVIDIA_CDI_DEBUG is deprecated and NVIDIA_CTK_DEBUG should be used instead.
87-
Sources: cli.EnvVars("NVIDIA_CTK_DEBUG", "NVIDIA_CDI_DEBUG"),
88-
},
89-
&cli.BoolFlag{
90-
Name: "quiet",
91-
Usage: "Suppress all output except for errors; overrides --debug",
92-
Destination: &opts.Quiet,
93-
// TODO: Support for NVIDIA_CDI_QUIET is deprecated and NVIDIA_CTK_QUIET should be used instead.
94-
Sources: cli.EnvVars("NVIDIA_CTK_QUIET", "NVIDIA_CDI_QUIET"),
77+
Flags: []cli.Flag{
78+
&cli.BoolFlag{
79+
Name: "debug",
80+
Aliases: []string{"d"},
81+
Usage: "Enable debug-level logging",
82+
Destination: &opts.Debug,
83+
// TODO: Support for NVIDIA_CDI_DEBUG is deprecated and NVIDIA_CTK_DEBUG should be used instead.
84+
Sources: cli.EnvVars("NVIDIA_CTK_DEBUG", "NVIDIA_CDI_DEBUG"),
85+
},
86+
&cli.BoolFlag{
87+
Name: "quiet",
88+
Usage: "Suppress all output except for errors; overrides --debug",
89+
Destination: &opts.Quiet,
90+
// TODO: Support for NVIDIA_CDI_QUIET is deprecated and NVIDIA_CTK_QUIET should be used instead.
91+
Sources: cli.EnvVars("NVIDIA_CTK_QUIET", "NVIDIA_CDI_QUIET"),
92+
},
9593
},
9694
}
9795

cmd/nvidia-cdi-hook/update-ldcache/update-ldcache.go

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,23 @@ func (m command) build() *cli.Command {
7474
Action: func(_ context.Context, cmd *cli.Command) error {
7575
return m.run(cmd, &cfg)
7676
},
77-
}
78-
79-
c.Flags = []cli.Flag{
80-
&cli.StringSliceFlag{
81-
Name: "folder",
82-
Usage: "Specify a folder to add to /etc/ld.so.conf before updating the ld cache",
83-
Destination: &cfg.folders,
84-
},
85-
&cli.StringFlag{
86-
Name: "ldconfig-path",
87-
Usage: "Specify the path to the ldconfig program",
88-
Destination: &cfg.ldconfigPath,
89-
Value: "/sbin/ldconfig",
90-
},
91-
&cli.StringFlag{
92-
Name: "container-spec",
93-
Usage: "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN",
94-
Destination: &cfg.containerSpec,
77+
Flags: []cli.Flag{
78+
&cli.StringSliceFlag{
79+
Name: "folder",
80+
Usage: "Specify a folder to add to /etc/ld.so.conf before updating the ld cache",
81+
Destination: &cfg.folders,
82+
},
83+
&cli.StringFlag{
84+
Name: "ldconfig-path",
85+
Usage: "Specify the path to the ldconfig program",
86+
Destination: &cfg.ldconfigPath,
87+
Value: "/sbin/ldconfig",
88+
},
89+
&cli.StringFlag{
90+
Name: "container-spec",
91+
Usage: "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN",
92+
Destination: &cfg.containerSpec,
93+
},
9594
},
9695
}
9796

cmd/nvidia-ctk-installer/main.go

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -96,58 +96,57 @@ func (a app) build() *cli.Command {
9696
Action: func(_ context.Context, cmd *cli.Command) error {
9797
return a.Run(cmd, &options)
9898
},
99-
}
100-
101-
// Setup flags for the CLI
102-
c.Flags = []cli.Flag{
103-
&cli.BoolFlag{
104-
Name: "no-daemon",
105-
Aliases: []string{"n"},
106-
Usage: "terminate immediately after setting up the runtime. Note that no cleanup will be performed",
107-
Destination: &options.noDaemon,
108-
Sources: cli.EnvVars("NO_DAEMON"),
109-
},
110-
&cli.StringFlag{
111-
Name: "runtime",
112-
Aliases: []string{"r"},
113-
Usage: "the runtime to setup on this node. One of {'docker', 'crio', 'containerd'}",
114-
Value: defaultRuntime,
115-
Destination: &options.runtime,
116-
Sources: cli.EnvVars("RUNTIME"),
117-
},
118-
&cli.StringFlag{
119-
Name: "toolkit-install-dir",
120-
Aliases: []string{"root"},
121-
Usage: "The directory where the NVIDIA Container Toolkit is to be installed. " +
122-
"The components of the toolkit will be installed to `ROOT`/toolkit. " +
123-
"Note that in the case of a containerized installer, this is the path in the container and it is " +
124-
"recommended that this match the path on the host.",
125-
Value: defaultToolkitInstallDir,
126-
Destination: &options.toolkitInstallDir,
127-
Sources: cli.EnvVars("TOOLKIT_INSTALL_DIR", "ROOT"),
128-
},
129-
&cli.StringFlag{
130-
Name: "toolkit-source-root",
131-
Usage: "The folder where the required toolkit artifacts can be found. If this is not specified, the path /artifacts/{{ .ToolkitPackageType }} is used where ToolkitPackageType is the resolved package type",
132-
Destination: &options.sourceRoot,
133-
Sources: cli.EnvVars("TOOLKIT_SOURCE_ROOT"),
134-
},
135-
&cli.StringFlag{
136-
Name: "toolkit-package-type",
137-
Usage: "specify the package type to use for the toolkit. One of ['deb', 'rpm', 'auto', '']. If 'auto' or '' are used, the type is inferred automatically.",
138-
Value: "auto",
139-
Destination: &options.packageType,
140-
Sources: cli.EnvVars("TOOLKIT_PACKAGE_TYPE"),
141-
},
142-
&cli.StringFlag{
143-
Name: "pid-file",
144-
Value: defaultPidFile,
145-
Usage: "the path to a toolkit.pid file to ensure that only a single configuration instance is running",
146-
Destination: &options.pidFile,
147-
Sources: cli.EnvVars("TOOLKIT_PID_FILE", "PID_FILE"),
99+
Flags: []cli.Flag{
100+
&cli.BoolFlag{
101+
Name: "no-daemon",
102+
Aliases: []string{"n"},
103+
Usage: "terminate immediately after setting up the runtime. Note that no cleanup will be performed",
104+
Destination: &options.noDaemon,
105+
Sources: cli.EnvVars("NO_DAEMON"),
106+
},
107+
&cli.StringFlag{
108+
Name: "runtime",
109+
Aliases: []string{"r"},
110+
Usage: "the runtime to setup on this node. One of {'docker', 'crio', 'containerd'}",
111+
Value: defaultRuntime,
112+
Destination: &options.runtime,
113+
Sources: cli.EnvVars("RUNTIME"),
114+
},
115+
&cli.StringFlag{
116+
Name: "toolkit-install-dir",
117+
Aliases: []string{"root"},
118+
Usage: "The directory where the NVIDIA Container Toolkit is to be installed. " +
119+
"The components of the toolkit will be installed to `ROOT`/toolkit. " +
120+
"Note that in the case of a containerized installer, this is the path in the container and it is " +
121+
"recommended that this match the path on the host.",
122+
Value: defaultToolkitInstallDir,
123+
Destination: &options.toolkitInstallDir,
124+
Sources: cli.EnvVars("TOOLKIT_INSTALL_DIR", "ROOT"),
125+
},
126+
&cli.StringFlag{
127+
Name: "toolkit-source-root",
128+
Usage: "The folder where the required toolkit artifacts can be found. If this is not specified, the path /artifacts/{{ .ToolkitPackageType }} is used where ToolkitPackageType is the resolved package type",
129+
Destination: &options.sourceRoot,
130+
Sources: cli.EnvVars("TOOLKIT_SOURCE_ROOT"),
131+
},
132+
&cli.StringFlag{
133+
Name: "toolkit-package-type",
134+
Usage: "specify the package type to use for the toolkit. One of ['deb', 'rpm', 'auto', '']. If 'auto' or '' are used, the type is inferred automatically.",
135+
Value: "auto",
136+
Destination: &options.packageType,
137+
Sources: cli.EnvVars("TOOLKIT_PACKAGE_TYPE"),
138+
},
139+
&cli.StringFlag{
140+
Name: "pid-file",
141+
Value: defaultPidFile,
142+
Usage: "the path to a toolkit.pid file to ensure that only a single configuration instance is running",
143+
Destination: &options.pidFile,
144+
Sources: cli.EnvVars("TOOLKIT_PID_FILE", "PID_FILE"),
145+
},
148146
},
149147
}
150148

149+
// Add the additional flags specific to the toolkit and runtime config.
151150
c.Flags = append(c.Flags, toolkit.Flags(&options.toolkitOptions)...)
152151
c.Flags = append(c.Flags, runtime.Flags(&options.runtimeOptions)...)
153152

0 commit comments

Comments
 (0)