// ReSharper disable ClassNeverInstantiated.Global namespace TeamCity.Docker { using System; using System.Collections.Generic; using System.Collections.Immutable; using System.IO; using System.Linq; using IoC; using Model; /// /// Locates configuration files for Docker Images. /// internal class ConfigurationExplorer : IConfigurationExplorer { [NotNull] private readonly ILogger _logger; [NotNull] private readonly IFileSystem _fileSystem; public ConfigurationExplorer( [NotNull] ILogger logger, [NotNull] IFileSystem fileSystem) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); } public Result> Explore(string sourcePath, IEnumerable configurationFiles) { if (sourcePath == null) { throw new ArgumentNullException(nameof(sourcePath)); } if (configurationFiles == null) { throw new ArgumentNullException(nameof(configurationFiles)); } var additionalVars = new Dictionary(); using (_logger.CreateBlock("Explore")) { foreach (var configurationFile in configurationFiles) { if (!_fileSystem.IsFileExist(configurationFile)) { _logger.Log($"The configuration file \"{configurationFile}\" (\"{Path.GetFullPath(configurationFile)}\") does not exist.", Result.Error); return new Result>(Enumerable.Empty