Skip to content

Commit c73f506

Browse files
authored
Merge pull request #4586 from camilamacedo86/enhance-helm
🐛 (helm/v1-alpha): Skip empty directories in chart generation
2 parents 8c817f5 + 151d217 commit c73f506

File tree

1 file changed

+14
-3
lines changed
  • pkg/plugins/optional/helm/v1alpha/scaffolds

1 file changed

+14
-3
lines changed

pkg/plugins/optional/helm/v1alpha/scaffolds/init.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,16 +231,27 @@ func (s *initScaffolder) copyConfigFiles() error {
231231
}
232232

233233
for _, dir := range configDirs {
234-
// Ensure destination directory exists
235-
if err := os.MkdirAll(dir.DestDir, os.ModePerm); err != nil {
236-
return fmt.Errorf("failed to create directory %s: %v", dir.DestDir, err)
234+
// Check if the source directory exists
235+
if _, err := os.Stat(dir.SrcDir); os.IsNotExist(err) {
236+
// Skip if the source directory does not exist
237+
continue
237238
}
238239

239240
files, err := filepath.Glob(filepath.Join(dir.SrcDir, "*.yaml"))
240241
if err != nil {
241242
return err
242243
}
243244

245+
// Skip processing if the directory is empty (no matching files)
246+
if len(files) == 0 {
247+
continue
248+
}
249+
250+
// Ensure destination directory exists
251+
if err := os.MkdirAll(dir.DestDir, os.ModePerm); err != nil {
252+
return fmt.Errorf("failed to create directory %s: %v", dir.DestDir, err)
253+
}
254+
244255
for _, srcFile := range files {
245256
destFile := filepath.Join(dir.DestDir, filepath.Base(srcFile))
246257
err := copyFileWithHelmLogic(srcFile, destFile, dir.SubDir, s.config.GetProjectName())

0 commit comments

Comments
 (0)