This repository has been archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Update fetchBeatsBinary
to be reused in elastic-agent-poc
#1984
Merged
+101
−58
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
34d8a97
update func
narph 4b938d4
fix path
narph ff34138
Merge branch 'main' into download-path
narph 84b0864
work on download
narph 2f19ed7
small fix
narph 6596b0b
remove test
narph 2296bf5
add sha to google
narph fb2eda2
Merge branch 'main' into download-path
narph b3778ed
fix typo
narph 2e3ecea
add comment
narph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,8 @@ func GetArchitecture() string { | |
// DownloadFile will download a url and store it in a temporary path. | ||
// It writes to the destination file as it downloads it, without | ||
// loading the entire file into memory. | ||
func DownloadFile(url string) (string, error) { | ||
func DownloadFile(url string, downloadPath string) (string, error) { | ||
var filepathFull string | ||
tempParentDir := filepath.Join(os.TempDir(), uuid.NewString()) | ||
internalio.MkdirAll(tempParentDir) | ||
|
||
|
@@ -54,7 +55,11 @@ func DownloadFile(url string) (string, error) { | |
} | ||
defer tempFile.Close() | ||
|
||
filepathFull := tempFile.Name() | ||
if downloadPath != "" { | ||
filepathFull = downloadPath | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you move https://github.com/elastic/e2e-testing/pull/1984/files#diff-a7cadd8b7616e655fd258138320b33eb96f7cce8e8663ec92651f49ce07df000R45-R46 right here, covered by the else branch? We will be creating the temp file if and only if the downloadPath is not empty |
||
filepathFull = tempFile.Name() | ||
} | ||
|
||
exp := GetExponentialBackOff(3) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking at the implementation and it's not clear to me if we need to return the path again, as it's passed in the download path. I can picture a new struct (i.e.
DownloadRequest
) with two attributes: url and downloadPath. The DownloadFile method would receive a pointer to an instance of this struct. If the downloadPath is empty, then create a temporary file (as it does now), populating the download path, otherwise use the value in the request. The method would still return the request's download path.Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea if we're already passing in the downloadPath then a struct containing that information could be easily reused/referenced elsewhere. I also tend to go with defined structs as it improves readability and intent