Return non-zero exit code on container copy failure
Signed-off-by: xu yang <xyang@ciq.com>
This commit is contained in:
@@ -40,6 +40,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Replace slice in templates with sprig substr. #1093
|
||||
- Fix an invalid format issue for the GitHub nightly build action. #1258
|
||||
- Return non-zero exit code on overlay build failure #1393
|
||||
- Return non-zero exit code on container copy failure #1377
|
||||
|
||||
## v4.5.8, unreleased
|
||||
|
||||
|
||||
@@ -21,28 +21,22 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
}
|
||||
|
||||
if !container.DoesSourceExist(cdp.ContainerSource) {
|
||||
wwlog.Error("Container's source doesn't exists: %s", cdp.ContainerSource)
|
||||
return
|
||||
return fmt.Errorf("container's source doesn't exists: %s", cdp.ContainerSource)
|
||||
}
|
||||
|
||||
if !container.ValidName(cdp.ContainerDestination) {
|
||||
wwlog.Error("Container name contains illegal characters : %s", cdp.ContainerDestination)
|
||||
return
|
||||
return fmt.Errorf("container name contains illegal characters : %s", cdp.ContainerDestination)
|
||||
}
|
||||
|
||||
if container.DoesSourceExist(cdp.ContainerDestination) {
|
||||
wwlog.Error("An other container with name: %s already exists in sources.", cdp.ContainerDestination)
|
||||
return
|
||||
return fmt.Errorf("an other container with name: %s already exists in sources", cdp.ContainerDestination)
|
||||
}
|
||||
|
||||
err = container.Duplicate(cdp.ContainerSource, cdp.ContainerDestination)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("could not duplicate image: %s", err.Error())
|
||||
wwlog.Error(err.Error())
|
||||
return
|
||||
return fmt.Errorf("could not duplicate image: %s", err.Error())
|
||||
}
|
||||
|
||||
wwlog.Info("Container %s successfully duplicated as %s", cdp.ContainerSource, cdp.ContainerDestination)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user