Skip to content

Commit

Permalink
Create folder target on fetch if not exist
Browse files Browse the repository at this point in the history
When fetching the folder target may not exist yet so let create it
automatically if not exist.
  • Loading branch information
chmouel committed Apr 26, 2024
1 parent 0cbfeaa commit ea1af5f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ import (
"context"
"fmt"
"net/url"
"os"
"strings"

"github.com/openshift-pipelines/tekton-caches/internal/provider/oci"
)

func Fetch(ctx context.Context, hash, target, folder string, insecure bool) error {
// check that folder exists or automatically create it
if _, err := os.Stat(folder); os.IsNotExist(err) {
if err := os.MkdirAll(folder, 0755); err != nil {
return fmt.Errorf("failed to create folder: %w", err)
}
}
u, err := url.Parse(target)
if err != nil {
return err
Expand Down

0 comments on commit ea1af5f

Please sign in to comment.