diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f0f4751..62484f0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/internal/app/wwctl/container/copy/main.go b/internal/app/wwctl/container/copy/main.go index 4c2e8faa..4d3c74b7 100644 --- a/internal/app/wwctl/container/copy/main.go +++ b/internal/app/wwctl/container/copy/main.go @@ -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 - }