diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ce56f03..10637794 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## v4.6.1, unreleased +### Added + +- Added `wwctl overlay import --overwrite` to overwrite existing overlay file. + ### Fixed - Fixed panic in warewulfd if node netdev is only defined in a profile. #1817 diff --git a/internal/app/wwctl/overlay/imprt/main.go b/internal/app/wwctl/overlay/imprt/main.go index 335ab673..ef948fe7 100644 --- a/internal/app/wwctl/overlay/imprt/main.go +++ b/internal/app/wwctl/overlay/imprt/main.go @@ -42,7 +42,7 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) { dest = path.Join(dest, path.Base(source)) } - if util.IsFile(overlay_.File(dest)) { + if !OverwriteFile && util.IsFile(overlay_.File(dest)) { return fmt.Errorf("a file with that name already exists in the overlay: %s", overlayName) } diff --git a/internal/app/wwctl/overlay/imprt/root.go b/internal/app/wwctl/overlay/imprt/root.go index 8d54521e..c3958d86 100644 --- a/internal/app/wwctl/overlay/imprt/root.go +++ b/internal/app/wwctl/overlay/imprt/root.go @@ -24,12 +24,14 @@ var ( } }, } + OverwriteFile bool NoOverlayUpdate bool CreateDirs bool Workers int ) func init() { + baseCmd.PersistentFlags().BoolVarP(&OverwriteFile, "overwrite", "o", false, "Overwrite file if exists") baseCmd.PersistentFlags().BoolVarP(&NoOverlayUpdate, "noupdate", "n", false, "Don't update overlays") baseCmd.PersistentFlags().BoolVarP(&CreateDirs, "parents", "p", false, "Create any necessary parent directories") baseCmd.PersistentFlags().IntVar(&Workers, "workers", 0, "The number of parallel workers building overlays (<=0 indicates 1 worker per CPU)")