Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the unused file store in a temp folder #5101

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading