Add helper methods to download and verify files
Motivation
As a core developer, I want to enable resource developers to easily download and verify files from the internet to be used when installing CLIs.
Current state
Every resource has its own almost duplicated code to download the binaries that it needs
Desired state
We have a method in the base resource class that can be used to download and verify binaries easily and also maybe verify versions of CLIs.
Steps
- Add a new class called
FileDownloadVerifyhere - The constructor takes URL as an argument, you can put these parameters in the URL's string
os_name,os_archandversionwhich will be substituted later. - This class has these methods:
-
download_fileit takesversion,hashand path as arguments, it downloads a file using the URL. -
unzip, it takes a path to a downloaded file and unzips it usingunziportaraccording to its extension. -
make_execit takes a path to a downloaded file and makes it an executable file. -
prepareit is a shortcut todownload_filethen unzip and lastmake_exec. - The class detects current os and arch on its own.
-
- This class will be used by other classes that represent CLIs used to execute commands.
Edited by Mouhsen Ibrahim