mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-28 23:17:24 +00:00
[no-relnote] Merge verifyFlags and validateFlags
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
ab0a4eaa19
commit
7f4b520a59
@ -130,6 +130,12 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func validateFlags(_ *cli.Context, o *options) error {
|
func validateFlags(_ *cli.Context, o *options) error {
|
||||||
|
if o.root == "" {
|
||||||
|
return fmt.Errorf("the install root must be specified")
|
||||||
|
}
|
||||||
|
if _, exists := availableRuntimes[o.runtime]; !exists {
|
||||||
|
return fmt.Errorf("unknown runtime: %v", o.runtime)
|
||||||
|
}
|
||||||
if filepath.Base(o.pidFile) != toolkitPidFilename {
|
if filepath.Base(o.pidFile) != toolkitPidFilename {
|
||||||
return fmt.Errorf("invalid toolkit.pid path %v", o.pidFile)
|
return fmt.Errorf("invalid toolkit.pid path %v", o.pidFile)
|
||||||
}
|
}
|
||||||
@ -144,12 +150,7 @@ func validateFlags(_ *cli.Context, o *options) error {
|
|||||||
|
|
||||||
// Run runs the core logic of the CLI
|
// Run runs the core logic of the CLI
|
||||||
func Run(c *cli.Context, o *options) error {
|
func Run(c *cli.Context, o *options) error {
|
||||||
err := verifyFlags(o)
|
err := initialize(o.pidFile)
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unable to verify flags: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = initialize(o.pidFile)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to initialize: %v", err)
|
return fmt.Errorf("unable to initialize: %v", err)
|
||||||
}
|
}
|
||||||
@ -217,18 +218,6 @@ func ParseArgs(args []string) ([]string, string, error) {
|
|||||||
return nil, "", fmt.Errorf("unexpected positional argument(s) %v", args[2:lastPositionalArg+1])
|
return nil, "", fmt.Errorf("unexpected positional argument(s) %v", args[2:lastPositionalArg+1])
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyFlags(o *options) error {
|
|
||||||
log.Infof("Verifying Flags")
|
|
||||||
if o.root == "" {
|
|
||||||
return fmt.Errorf("the install root must be specified")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, exists := availableRuntimes[o.runtime]; !exists {
|
|
||||||
return fmt.Errorf("unknown runtime: %v", o.runtime)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func initialize(pidFile string) error {
|
func initialize(pidFile string) error {
|
||||||
log.Infof("Initializing")
|
log.Infof("Initializing")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user