alces-software / metalware

Tools and conventions for improving bare metal machine management
Other
2 stars 0 forks source link

Refactor BuildFileRetriever #421

Closed WilliamMcCumstie closed 6 years ago

WilliamMcCumstie commented 6 years ago

Based on #419, please merge it first.

The majority of the code changes concern refactoring BuildFileRetriever to be in a cleaner state. Previously multiple methods where being duplicated for both plugins and nodes which have to be manually passed into an internal data structure.

Instead inheritance is used to share the code and make the distinctions between plugins and nodes. The Cache has been removed from Input and is now included within a new BuildFileRetriever::Cache class. The new Cache class also has the retrieve method that works for both nodes and plugins.

The internal Struct for BFR has been removed and its methods have become standard instance methods.

Finally it fixes #300. When a file is downloaded, it is still cached to the cache/templates directory. But instead of saving the files using its basename, the url is hashed. This insures each url will have a unique download cache. (The hashing algorithm is SHA-1, so this does ignore the possibility of SHA-1 collisions).