-
Notifications
You must be signed in to change notification settings - Fork 341
Issue warning on unsupported CDI hook #1000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ type hookCommand struct { | |
logger logger.Interface | ||
} | ||
|
||
// NewCommand constructs a hook command with the specified logger | ||
// NewCommand constructs CLI subcommand for handling CDI hooks. | ||
func NewCommand(logger logger.Interface) *cli.Command { | ||
c := hookCommand{ | ||
logger: logger, | ||
|
@@ -37,10 +37,21 @@ func NewCommand(logger logger.Interface) *cli.Command { | |
|
||
// build | ||
func (m hookCommand) build() *cli.Command { | ||
// Create the 'hook' command | ||
// Create the 'hook' subcommand | ||
hook := cli.Command{ | ||
Name: "hook", | ||
Usage: "A collection of hooks that may be injected into an OCI spec", | ||
// We set the default action for the `hook` subcommand to issue a | ||
// warning and exit with no error. | ||
// This means that if an unsupported hook is run, a container will not fail | ||
// to launch. An unsupported hook could be the result of a CDI specification | ||
// referring to a new hook that is not yet supported by an older NVIDIA | ||
// Container Toolkit version or a hook that has been removed in newer | ||
// version. | ||
Action: func(ctx *cli.Context) error { | ||
commands.IssueUnsupportedHookWarning(m.logger, ctx) | ||
return nil | ||
}, | ||
} | ||
|
||
hook.Subcommands = commands.New(m.logger) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh. Hm maybe "hook" is the command, and sub-commands are one level deeper. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope my discussion above has cleared up the confusion here. We should make a pass of the existing code and update the comments / functions for consistency, but this has a low priority at present. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the CLI libraries perspective -- does this define a subcommand named "hook"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if so, the code comment maybe should be "create 'hook' subcommand" (just noting this as I try to understand the code here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLI library that we use (urfave) has the following heirarchy:
A top-level CLI
App
can have one or moreCommand
s. EachCommand
can have one or moreSubcommands
.Note that The
Subcommands
are themselvesCommands
which actually allows for arbitrary nesting.I agree that from a documentation perspective, what we mean when we say "command" is "subcommand" and should use "command" for "app" (the top-level CLI) instead.