From 7cdcfa34ae499c0735d60c7180c61b5a027f45d2 Mon Sep 17 00:00:00 2001 From: Eileen Date: Thu, 3 Aug 2023 15:36:03 -0400 Subject: [PATCH] fix: ensure external plugin can scaffold files in new dirs --- pkg/plugins/external/helpers.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/plugins/external/helpers.go b/pkg/plugins/external/helpers.go index 702cb1dc84c..a1bc759317e 100644 --- a/pkg/plugins/external/helpers.go +++ b/pkg/plugins/external/helpers.go @@ -168,7 +168,15 @@ func handlePluginResponse(fs machinery.Filesystem, req external.PluginRequest, p } for filename, data := range res.Universe { - f, err := fs.FS.Create(filepath.Join(currentDir, filename)) + path := filepath.Join(currentDir, filename) + dir := filepath.Dir(path) + + // create the directory if it does not exist + if err := os.MkdirAll(dir, 0o750); err != nil { + return fmt.Errorf("error creating the directory: %v", err) + } + + f, err := fs.FS.Create(path) if err != nil { return err }