Skip to content

Commit 514b15a

Browse files
committed
Switch to FetchWithContext
This updates the calls to the fetcher to use the newer FetchWithContext method.
1 parent afe5875 commit 514b15a

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

pkg/cmd/fetcher.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ type ProxyArchiveFetcher struct {
2929
maxUntarSize int
3030
}
3131

32-
// Fetch implements the ArchiveFetcher implementation, but uses the Kube service
32+
// FetchWithContext implements the ArchiveFetcher implementation, but uses the Kube service
3333
// proxy mechanism to get the archive.
34-
func (p *ProxyArchiveFetcher) Fetch(archiveURL, checksum, dir string) error {
34+
func (p *ProxyArchiveFetcher) FetchWithContext(ctx context.Context, archiveURL, checksum, dir string) error {
3535
parsed, err := parseArtifactURL(archiveURL)
3636
if err != nil {
3737
return err
3838
}
3939

4040
responseWrapper := p.Client.Services(parsed.namespace).ProxyGet(parsed.scheme, parsed.name, parsed.port, parsed.path, nil)
41-
b, err := responseWrapper.DoRaw(context.Background())
41+
b, err := responseWrapper.DoRaw(ctx)
4242
if err != nil {
4343
return err
4444
}

pkg/cmd/local_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type localFetcher struct {
6969
logger logr.Logger
7070
}
7171

72-
func (l localFetcher) Fetch(archiveURL, checksum, dir string) error {
72+
func (l localFetcher) FetchWithContext(_ context.Context, archiveURL, checksum, dir string) error {
7373
parsed, err := url.Parse(archiveURL)
7474
if err != nil {
7575
return err

pkg/parser/repository_parser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
// ArchiveFetcher implementations should get the URL, validate the contents
1818
// against the checksum and leave the unpacked version in the dir.
1919
type ArchiveFetcher interface {
20-
Fetch(archiveURL, checksum, dir string) error
20+
FetchWithContext(ctx context.Context, archiveURL, checksum, dir string) error
2121
}
2222

2323
// RepositoryParser fetches archives from a Repository and parses the
@@ -44,7 +44,7 @@ func (p *RepositoryParser) GenerateFromFiles(ctx context.Context, archiveURL, ch
4444
}
4545
}()
4646

47-
if err := p.fetcher.Fetch(archiveURL, checksum, tempDir); err != nil {
47+
if err := p.fetcher.FetchWithContext(ctx, archiveURL, checksum, tempDir); err != nil {
4848
return nil, fmt.Errorf("failed to get archive URL %s: %w", archiveURL, err)
4949
}
5050

@@ -82,7 +82,7 @@ func (p *RepositoryParser) GenerateFromDirectories(ctx context.Context, archiveU
8282
}
8383
}()
8484

85-
if err := p.fetcher.Fetch(archiveURL, checksum, tempDir); err != nil {
85+
if err := p.fetcher.FetchWithContext(ctx, archiveURL, checksum, tempDir); err != nil {
8686
return nil, fmt.Errorf("failed to get archive URL %s: %w", archiveURL, err)
8787
}
8888

0 commit comments

Comments
 (0)