Skip to content

Commit

Permalink
Merge pull request #5101 from twz123/remove-temp-file-store
Browse files Browse the repository at this point in the history
Remove the unused file store in a temp folder
  • Loading branch information
ricardomaraschini authored Oct 10, 2024
2 parents 5010d2c + 2abd4d1 commit ef9c0c1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
14 changes: 0 additions & 14 deletions internal/oci/oci.go → internal/oci/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ import (
"fmt"
"io"
"net/http"
"os"

ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"oras.land/oras-go/v2/content"
"oras.land/oras-go/v2/content/file"
"oras.land/oras-go/v2/registry"
"oras.land/oras-go/v2/registry/remote"
"oras.land/oras-go/v2/registry/remote/auth"
Expand Down Expand Up @@ -59,12 +57,6 @@ func Download(ctx context.Context, url string, target io.Writer, options ...Down
return fmt.Errorf("failed to parse artifact reference: %w", err)
}

tmpdir, err := os.MkdirTemp("", "k0s-oci-artifact-*")
if err != nil {
return fmt.Errorf("failed to create temp dir: %w", err)
}
defer func() { _ = os.RemoveAll(tmpdir) }()

repo, err := remote.NewRepository(url)
if err != nil {
return fmt.Errorf("failed to create repository: %w", err)
Expand All @@ -74,12 +66,6 @@ func Download(ctx context.Context, url string, target io.Writer, options ...Down
repo.PlainHTTP = true
}

fs, err := file.New(tmpdir)
if err != nil {
return fmt.Errorf("failed to create file store: %w", err)
}
defer fs.Close()

transp := http.DefaultTransport.(*http.Transport).Clone()
if opts.insecureSkipTLSVerify {
transp.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
Expand Down
1 change: 1 addition & 0 deletions internal/oci/oci_test.go → internal/oci/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func startOCIMockServer(t *testing.T, tname string, test testFile) string {
w.WriteHeader(http.StatusNotFound)
}),
)
t.Cleanup(server.Close)

u, err := url.Parse(server.URL)
require.NoError(t, err)
Expand Down

0 comments on commit ef9c0c1

Please sign in to comment.