mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
provider/template: template_dir explicitly create dest dir
Previously we were letting it get implicitly created as part of making the structure for copying in each file, but that isn't sufficient if the source directory is empty. By explicitly creating the directory first we ensure that it will complete successfully even in the case of an empty directory.
This commit is contained in:
parent
eda2550074
commit
eaac9fbca3
@ -87,11 +87,20 @@ func resourceTemplateDirCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Create the destination directory and any other intermediate directories
|
||||
// leading to it.
|
||||
if _, err := os.Stat(destinationDir); err != nil {
|
||||
if err := os.MkdirAll(destinationDir, 0777); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively crawl the input files/directories and generate the output ones.
|
||||
err := filepath.Walk(sourceDir, func(p string, f os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if f.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user