-
Notifications
You must be signed in to change notification settings - Fork 42
Update fetchBeatsBinary
to be reused in elastic-agent-poc
#1984
Conversation
narph
commented
Jan 10, 2022
- made method public to avoid any binary name construction
- added download path to download artifacts in the specified location
This pull request does not have a backport label. Could you fix it @narph? 🙏
|
💔 Tests Failed
Expand to view the summary
Build stats
Test stats 🧪
Test errorsExpand to view the tests failures
|
internal/utils/utils.go
Outdated
filepathFull := tempFile.Name() | ||
if downloadPath != "" { | ||
filepathFull = downloadPath | ||
} else { |
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.
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
internal/utils/utils.go
Outdated
@@ -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) { |
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
@narph how would you see delegating the download of the sha512 file to the handleDownload file? If it receives the new DownloadRequest struct instead of the URL, then it can internally handle the download of both files, the binary and its sha512. Then, we would be able to remove the duplication of the calls to the handleDownload in both scenarios: the artifactory and the bucket. |
* update func * fix path * work on download * small fix * remove test * add sha to google * fix typo * add comment (cherry picked from commit d3365c9)
* update func * fix path * work on download * small fix * remove test * add sha to google * fix typo * add comment (cherry picked from commit d3365c9) # Conflicts: # pkg/downloads/versions.go
…2009) * update func * fix path * work on download * small fix * remove test * add sha to google * fix typo * add comment (cherry picked from commit d3365c9) Co-authored-by: Mariana Dima <[email protected]>
…tic-agent-poc (#2010) * Update `fetchBeatsBinary` to be reused in elastic-agent-poc (#1984) * update func * fix path * work on download * small fix * remove test * add sha to google * fix typo * add comment (cherry picked from commit d3365c9) # Conflicts: # pkg/downloads/versions.go * fix: resolve conflicts * fix: update tests after missing backport Co-authored-by: Mariana Dima <[email protected]> Co-authored-by: Manuel de la Peña <[email protected]>
* main: (45 commits) feat: add CentOS 8 support (elastic#2034) fix: set default region for AWS cli (elastic#2053) chore: use Ansible's built-in replace instead of sed (elastic#2048) chore: split stack configuration and start into two tasks (elastic#2044) feat: enable SSH access to users for debugging cloud instances (elastic#2001) fix: use the right branch for 7.17 backports (elastic#2025) SLES15 enablement (elastic#2007) chore: bump stale agent for main (elastic#2014) Update `fetchBeatsBinary` to be reused in elastic-agent-poc (elastic#1984) chore: add resiliency when provisioning the stack (elastic#1990) chore: bump elastic-package to v0.32.1 (elastic#1959) feat: export Fetch&Download methods in the /pkg directory (elastic#1943) bump stack version 8.1.0-dbc834fd (elastic#1948) bump stack version 8.1.0-76902d39 (elastic#1946) chore: retire 7.15 adding 7.17 (elastic#1938) ci: use withAPMEnv (elastic#1917) Update main branch (elastic#1928) bump stack version 8.1.0-befff95a (elastic#1929) chore: properly evaluate how tests are skipped on CI when checking modified files (elastic#1924) bump stack version 8.1.0-60bffc32 (elastic#1921) ...
…1984) * update func * fix path * work on download * small fix * remove test * add sha to google * fix typo * add comment
* ci: use withAPMEnv (#1917) * feat: partial backport for (#1628) * chore: define variable for BeatsLocalPath * fix: update path initialisation in unit tests * chore: pass inline env vars to commands Co-authored-by: Victor Martinez <[email protected]> Co-authored-by: Victor Martinez <[email protected]> * feat: export Fetch&Download methods in the /pkg directory (#1943) * chore: copy internal's version files into the exported pkg public package * chore: run unit tests from top-level goal * chore: use public package instead of the internal one * chore: remove old internal files for habdling downloads * fix: update missing references * Update `fetchBeatsBinary` to be reused in elastic-agent-poc (#1984) * update func * fix path * work on download * small fix * remove test * add sha to google * fix typo * add comment * ci: increase log rotation (#2138) * chore: increase build timeout to 90 minutes (#2139) * feat: support downloading project artifacts for the new bucket layout (#2172) * feat: support for the new bucket structure * feat: calculate bucket URLs using resolvers * chore: support for legacy Beats Old PRs needs to be tested and the binaries could not exist in the new layout * chore: support looking up the bucket in up-to 3 locations 1. new project layout 2. new beats layout 3. legacy beats layout * chore: simplify boolean logic * fix: pass worker environment for versions to the VMs * fix: predefine kibana version * fix: remove extra char * fix: remove extra char * chore: log resolvers * chore: use new project method when fetching artifacts * fix: pass stack version to stack deployment * fix: use artifact to check for ubi8 variant * chore: improve logs in resolvers * fix: apply variants to project resolver Ubi8 is a valid variant for elastic-agent * chore: use Stack version for the dependant beats In the running-on-top-of-beats feature file, the code installs some Beats and we do not want to use the given SHA, because elastic-agent now lives in a separate repo, therefore they do not share commit SHAs * fix: use fleet-ci bucket for elastic-agent and fleet-server * chore: look up both CI buckets * chore: make useCISnapshots configurable on downloads * chore: background processes should not use CI snapshots * feat: separate elastic-agent version from beats version * chore: extract useCISnapshots to a function * chore: use Github_Check_Repo to identify where the Git commit lives * fix: k8s-autodiscover lives in both worlds * fix: missing package * fix: use snapshot version in k8s-autodiscover * fix: missing import Co-authored-by: Victor Martinez <[email protected]> Co-authored-by: Mariana Dima <[email protected]>