diff --git a/internal/generator/generator.go b/internal/generator/generator.go index 46ed83e..0db39a7 100644 --- a/internal/generator/generator.go +++ b/internal/generator/generator.go @@ -3,7 +3,9 @@ package generator import ( "bytes" "context" + "errors" "fmt" + "os" "sync" "github.com/rs/zerolog" @@ -59,6 +61,14 @@ func (puller ChartPuller) Pull(ctx context.Context, opts helm.PullOptions) error mutex.Lock() defer mutex.Unlock() + if _, err := os.Stat(opts.OutputDir); err == nil { + // If output directory exists it has been pulled by another goroutine + // No need to pull the chart + return nil + } else if !errors.Is(err, os.ErrNotExist) { + return fmt.Errorf("failed to stat chart cache: %w", err) + } + if err := cli.Pull(ctx, opts); err != nil { return fmt.Errorf("%w: %q", err, &buffer) }