Refactor Docker Auth to improve testability and reliability
Description
Followup of !2048 (merged).
The MR only moved auth logic from the docker executor to a separate package and avoided refactoring it to limit the risk of regressions.
The code however suffers from some reliability and testability issues - using global variables, not handling errors, low test coverage.
Proposal
Refactor the code in helpers/docker/auth to:
- wrap the functions in a struct, possibly with an interface so that it can be injected in executors and mocked
- inject
HomeDirectoryas a dependency to the struct to avoid setting it as a global variable in tests - handle errors from
readConfigsFromReader - Convert
TestSplitDockerImageName,TestSplitDefaultDockerImageNameandTestSplitDefaultIndexDockerImageNameto table driven tests and add more cases. - Inject
userFetcherso that tests can be created for the logic fetching the user and using it to determine the home directory. - increase test coverage for resolver functions -
readConfigsFromReader,readConfigsFromCredentialsStore,readConfigsFromCredentialsHelper
Edited by Lyubomir Raykov