Add --overwrite to wwctl overlay import

- Closes: #386

Signed-off-by: Timothy Middelkoop <tmiddelkoop@internet2.edu>
This commit is contained in:
Timothy Middelkoop
2025-02-23 16:29:05 +00:00
committed by Jonathon Anderson
parent e02f9ec02b
commit ae54fd207b
3 changed files with 7 additions and 1 deletions

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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)")