provider/template: template_dir: don't crash if source dir nonexistent
When an error is passed, the FileInfo can be nil, which was previously causing a crash on trying to evaluate f.IsDir(). By checking for an error first we avoid this crash.
This commit is contained in:
parent
f721608e4e
commit
eda2550074
|
@ -89,12 +89,12 @@ func resourceTemplateDirCreate(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
|
||||||
// Recursively crawl the input files/directories and generate the output ones.
|
// Recursively crawl the input files/directories and generate the output ones.
|
||||||
err := filepath.Walk(sourceDir, func(p string, f os.FileInfo, err error) error {
|
err := filepath.Walk(sourceDir, func(p string, f os.FileInfo, err error) error {
|
||||||
if f.IsDir() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if f.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
relPath, _ := filepath.Rel(sourceDir, p)
|
relPath, _ := filepath.Rel(sourceDir, p)
|
||||||
return generateDirFile(p, path.Join(destinationDir, relPath), f, vars)
|
return generateDirFile(p, path.Join(destinationDir, relPath), f, vars)
|
||||||
|
|
Loading…
Reference in New Issue