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 FileDownloadVerify here
  • The constructor takes URL as an argument, you can put these parameters in the URL's string os_name, os_arch and version which will be substituted later.
  • This class has these methods:
    • download_file it takes version, hash and path as arguments, it downloads a file using the URL.
    • unzip, it takes a path to a downloaded file and unzips it using unzip or tar according to its extension.
    • make_exec it takes a path to a downloaded file and makes it an executable file.
    • prepare it is a shortcut to download_file then unzip and last make_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 May 12, 2023 by Mouhsen Ibrahim
Assignee Loading
Time tracking Loading