Skip to content

Commit

Permalink
remove fetchHash flag
Browse files Browse the repository at this point in the history
  • Loading branch information
pchila committed Jul 14, 2023
1 parent 7dfff4e commit f5090c3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
23 changes: 10 additions & 13 deletions pkg/testing/fetcher_artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,16 @@ func (f *artifactFetcher) Fetch(ctx context.Context, operatingSystem string, arc
path := fmt.Sprintf("elastic-agent-%s-%s", version, suffix)
downloadSrc := fmt.Sprintf("%s%s", uri, path)
return &artifactResult{
doer: f.doer,
src: downloadSrc,
path: path,
fetchHash: true,
doer: f.doer,
src: downloadSrc,
path: path,
}, nil
}

type artifactResult struct {
doer httpDoer
src string
path string
fetchHash bool
doer httpDoer
src string
path string
}

// Name is the name of the fetched result.
Expand All @@ -104,11 +102,10 @@ func (r *artifactResult) Fetch(ctx context.Context, l Logger, dir string) error
return fmt.Errorf("failed to download %s: %w", r.src, err)
}

if r.fetchHash {
err := DownloadPackage(ctx, l, r.doer, r.src+hashExt, filepath.Join(dir, r.path+hashExt))
if err != nil {
return fmt.Errorf("failed to download %s: %w", r.src, err)
}
// fetch package hash
err = DownloadPackage(ctx, l, r.doer, r.src+hashExt, filepath.Join(dir, r.path+hashExt))
if err != nil {
return fmt.Errorf("failed to download %s: %w", r.src, err)
}

return nil
Expand Down
16 changes: 7 additions & 9 deletions pkg/testing/fetcher_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ func (f *localFetcher) Fetch(_ context.Context, operatingSystem string, architec
if err != nil {
return nil, fmt.Errorf("failed to find build at %s: %w", f.dir, err)
}
return &localFetcherResult{src: f.dir, path: build, fetchHash: true}, nil
return &localFetcherResult{src: f.dir, path: build}, nil
}

type localFetcherResult struct {
src string
path string
fetchHash bool
src string
path string
}

// Name is the name of the fetched result.
Expand All @@ -93,11 +92,10 @@ func (r *localFetcherResult) Fetch(_ context.Context, _ Logger, dir string) erro
return fmt.Errorf("error copying file: %w", err)
}

if r.fetchHash {
err := copyFile(fullPath+hashExt, path+hashExt)
if err != nil {
return fmt.Errorf("error copying file: %w", err)
}
// fetch artifact hash
err = copyFile(fullPath+hashExt, path+hashExt)
if err != nil {
return fmt.Errorf("error copying file: %w", err)
}

return nil
Expand Down

0 comments on commit f5090c3

Please sign in to comment.