Return non-zero exit code on node sub-commands

Signed-off-by: xu yang <xyang@ciq.com>
This commit is contained in:
xu yang
2024-09-26 06:15:02 +00:00
parent eb2fab9902
commit 3f120f2c4b
8 changed files with 31 additions and 54 deletions

View File

@@ -17,14 +17,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
return fmt.Errorf("could not open node configuration: %s", err)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Could not get node list: %s", err)
os.Exit(1)
return fmt.Errorf("could not get node list: %s", err)
}
args = hostlist.Expand(args)
@@ -38,7 +36,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if len(nodes) == 0 {
fmt.Printf("No nodes found\n")
wwlog.Info("No nodes found")
os.Exit(1)
}