diff --git a/internal/oci/oci.go b/internal/oci/download.go similarity index 94% rename from internal/oci/oci.go rename to internal/oci/download.go index 2e003eace085..ccf0a1a812ba 100644 --- a/internal/oci/oci.go +++ b/internal/oci/download.go @@ -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" @@ -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) @@ -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} diff --git a/internal/oci/oci_test.go b/internal/oci/download_test.go similarity index 99% rename from internal/oci/oci_test.go rename to internal/oci/download_test.go index 37f9208b04f8..cc7512311cd9 100644 --- a/internal/oci/oci_test.go +++ b/internal/oci/download_test.go @@ -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)