Skip to content

Commit

Permalink
fix(PL-2763): check chart has been written before deciding to pull
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmdm committed Jun 18, 2024
1 parent aa42508 commit 19d5fa3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package generator
import (
"bytes"
"context"
"errors"
"fmt"
"os"
"sync"

"github.com/rs/zerolog"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 19d5fa3

Please sign in to comment.