From f202072220f96610f2c08ee89c37f6552ce54d65 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 9 Jan 2026 23:58:52 -0500 Subject: [PATCH] fix: ensure the destination directory exists when extracting files from a repository Closes #8272 --- plugins/common/common.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/plugins/common/common.go b/plugins/common/common.go index 281ff39a9..a5045d67f 100644 --- a/plugins/common/common.go +++ b/plugins/common/common.go @@ -123,6 +123,19 @@ func CorePostDeploy(input CorePostDeployInput) error { return fmt.Errorf("Missing required Destination in CorePostDeploy for plugin %v", input.PluginName) } + if !DirectoryExists(input.Destination) { + if err := os.MkdirAll(input.Destination, 0755); err != nil { + return fmt.Errorf("Unable to create destination directory %v: %s", input.Destination, err.Error()) + } + + if err := SetPermissions(SetPermissionInput{ + Filename: input.Destination, + Mode: 0755, + }); err != nil { + return fmt.Errorf("Unable to set destination directory permissions %v: %s", input.Destination, err.Error()) + } + } + for i, extractedPath := range input.ExtractedPaths { if extractedPath.Path == "" { return fmt.Errorf("Missing required Name in CorePostDeploy for index %v for plugin %v", i, input.PluginName) @@ -250,6 +263,19 @@ func CorePostExtract(input CorePostExtractInput) error { }) sourceImage := results.StdoutContents() + if !DirectoryExists(input.Destination) { + if err := os.MkdirAll(input.Destination, 0755); err != nil { + return fmt.Errorf("Unable to create destination directory %v: %s", input.Destination, err.Error()) + } + + if err := SetPermissions(SetPermissionInput{ + Filename: input.Destination, + Mode: 0755, + }); err != nil { + return fmt.Errorf("Unable to set destination directory permissions %v: %s", input.Destination, err.Error()) + } + } + for i, toExtract := range input.ToExtract { if toExtract.Name == "" { return fmt.Errorf("Name is required for index %v in CorePostExtract for plugin %v", i, input.PluginName)