@@ -51,17 +51,29 @@ func main() {
5151 Version : info .GetVersionString (),
5252 // Define the subcommands
5353 Commands : commands .New (logger ),
54- }
55- // We set the default action for the `nvidia-cdi-hook` command to issue a
56- // warning and exit with no error.
57- // This means that if an unsupported hook is run, a container will not fail
58- // to launch. An unsupported hook could be the result of a CDI specification
59- // referring to a new hook that is not yet supported by an older NVIDIA
60- // Container Toolkit version or a hook that has been removed in newer
61- // version.
62- c .Action = func (ctx context.Context , cmd * cli.Command ) error {
63- commands .IssueUnsupportedHookWarning (logger , cmd )
64- return nil
54+ // Set log-level for all subcommands
55+ Before : func (ctx context.Context , cmd * cli.Command ) (context.Context , error ) {
56+ logLevel := logrus .InfoLevel
57+ if opts .Debug {
58+ logLevel = logrus .DebugLevel
59+ }
60+ if opts .Quiet {
61+ logLevel = logrus .ErrorLevel
62+ }
63+ logger .SetLevel (logLevel )
64+ return ctx , nil
65+ },
66+ // We set the default action for the `nvidia-cdi-hook` command to issue a
67+ // warning and exit with no error.
68+ // This means that if an unsupported hook is run, a container will not fail
69+ // to launch. An unsupported hook could be the result of a CDI specification
70+ // referring to a new hook that is not yet supported by an older NVIDIA
71+ // Container Toolkit version or a hook that has been removed in newer
72+ // version.
73+ Action : func (ctx context.Context , cmd * cli.Command ) error {
74+ commands .IssueUnsupportedHookWarning (logger , cmd )
75+ return nil
76+ },
6577 }
6678
6779 // Setup the flags for this command
@@ -83,19 +95,6 @@ func main() {
8395 },
8496 }
8597
86- // Set log-level for all subcommands
87- c .Before = func (ctx context.Context , cmd * cli.Command ) (context.Context , error ) {
88- logLevel := logrus .InfoLevel
89- if opts .Debug {
90- logLevel = logrus .DebugLevel
91- }
92- if opts .Quiet {
93- logLevel = logrus .ErrorLevel
94- }
95- logger .SetLevel (logLevel )
96- return ctx , nil
97- }
98-
9998 // Run the CLI
10099 err := c .Run (context .Background (), os .Args )
101100 if err != nil {
0 commit comments