Return non-zero exit code on overlay sub-commands

Signed-off-by: xu yang <xyang@ciq.com>
This commit is contained in:
xu yang
2024-10-30 05:50:39 +00:00
committed by Jonathon Anderson
parent 795c44e650
commit 97c6772e51
10 changed files with 50 additions and 93 deletions

View File

@@ -1,6 +1,7 @@
package mkdir
import (
"fmt"
"os"
"path"
@@ -19,8 +20,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
overlaySourceDir = overlay.OverlaySourceDir(overlayName)
if !util.IsDir(overlaySourceDir) {
wwlog.Error("Overlay does not exist: %s", overlayName)
os.Exit(1)
return fmt.Errorf("overlay does not exist: %s", overlayName)
}
overlayDir := path.Join(overlaySourceDir, dirName)
@@ -29,8 +29,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
err := os.MkdirAll(overlayDir, os.FileMode(PermMode))
if err != nil {
wwlog.Error("Could not create directory: %s", path.Dir(overlayDir))
os.Exit(1)
return fmt.Errorf("could not create directory: %s", path.Dir(overlayDir))
}
return nil