private static IEnumerable <IDependencyUpdater> GetUpdaters( string dockerfileVersion, IEnumerable <IDependencyInfo> buildInfos) { string[] dockerfiles = Directory.GetFiles( Path.Combine(RepoRoot, dockerfileVersion), "Dockerfile", SearchOption.AllDirectories); Trace.TraceInformation("Updating the following Dockerfiles:"); Trace.TraceInformation(string.Join(Environment.NewLine, dockerfiles)); // NOTE: The order in which the updaters are returned/invoked is important as there are cross dependencies // (e.g. sha updater requires the version numbers to be updated within the Dockerfiles) List <IDependencyUpdater> manifestBasedUpdaters = new List <IDependencyUpdater>(); CreateManifestUpdater(manifestBasedUpdaters, "Sdk", buildInfos, SdkBuildInfoName); CreateManifestUpdater(manifestBasedUpdaters, "Runtime", buildInfos, RuntimeBuildInfoName); manifestBasedUpdaters.Add(new ReadMeUpdater(RepoRoot)); return(CreateDockerfileVariableUpdaters(dockerfiles, buildInfos, VariableHelper.DotnetSdkVersionName, SdkBuildInfoName) .Concat(CreateDockerfileVariableUpdaters( dockerfiles, buildInfos, VariableHelper.AspNetVersionName, AspNetCoreBuildInfoName)) .Concat(CreateDockerfileVariableUpdaters( dockerfiles, buildInfos, VariableHelper.DotnetVersionName, RuntimeBuildInfoName)) .Concat(dockerfiles.Select(path => DockerfileShaUpdater.CreateProductShaUpdater(path))) .Concat(dockerfiles.Select(path => DockerfileShaUpdater.CreateLzmaShaUpdater(path))) .Concat(manifestBasedUpdaters)); }
private static IEnumerable <IDependencyUpdater> GetUpdaters(string dockerfileVersion) { string[] dockerfiles = Directory.GetFiles( Path.Combine(RepoRoot, dockerfileVersion), "Dockerfile", SearchOption.AllDirectories); Trace.TraceInformation("Updating the following Dockerfiles:"); Trace.TraceInformation(string.Join(Environment.NewLine, dockerfiles)); return(dockerfiles .Select(path => CreateDockerfileEnvUpdater(path, "DOTNET_SDK_VERSION", SdkBuildInfoName)) .Concat(dockerfiles.Select(path => CreateDockerfileEnvUpdater(path, "ASPNETCORE_VERSION", AspNetCoreBuildInfoName))) .Concat(dockerfiles.Select(path => CreateDockerfileEnvUpdater(path, "DOTNET_VERSION", RuntimeBuildInfoName))) .Concat(dockerfiles.Select(path => DockerfileShaUpdater.CreateProductShaUpdater(path))) .Concat(dockerfiles.Select(path => DockerfileShaUpdater.CreateLzmaShaUpdater(path)))); }
private static IEnumerable <IDependencyUpdater> GetUpdaters() { // NOTE: The order in which the updaters are returned/invoked is important as there are cross dependencies // (e.g. sha updater requires the version numbers to be updated within the Dockerfiles) foreach (string productName in Options.ProductVersions.Keys) { yield return(new VersionUpdater(VersionType.Build, productName, Options.DockerfileVersion, RepoRoot)); yield return(new VersionUpdater(VersionType.Product, productName, Options.DockerfileVersion, RepoRoot)); foreach (IDependencyUpdater shaUpdater in DockerfileShaUpdater.CreateUpdaters(productName, Options.DockerfileVersion, RepoRoot, Options)) { yield return(shaUpdater); } } yield return(ScriptRunnerUpdater.GetDockerfileUpdater(RepoRoot)); yield return(ScriptRunnerUpdater.GetReadMeUpdater(RepoRoot)); }
public static IEnumerable <IDependencyUpdater> CreateUpdaters( string productName, string dockerfileVersion, string repoRoot, Options options) { string versionsPath = System.IO.Path.Combine(repoRoot, Program.VersionsFilename); string versions = File.ReadAllText(versionsPath); // The format of the sha variable name is '<productName>|<dockerfileVersion>|<os>|<arch>|sha'. // The 'os' and 'arch' segments are optional. string shaVariablePattern = $"\"(?<{ShaVariableGroupName}>{Regex.Escape(productName)}\\|{Regex.Escape(dockerfileVersion)}.*\\|sha)\":"; Regex shaVariableRegex = new Regex(shaVariablePattern); return(shaVariableRegex.Matches(versions) .Select(match => match.Groups[ShaVariableGroupName].Value) .Select(variable => { Trace.TraceInformation($"Updating {variable}"); string[] parts = variable.Split('|'); DockerfileShaUpdater updater = new DockerfileShaUpdater() { _productName = productName, _buildVersion = GetBuildVersion(productName, dockerfileVersion, versions, options), _dockerfileVersion = dockerfileVersion, _os = parts.Length >= 4 ? parts[2] : string.Empty, _arch = parts.Length >= 5 ? parts[3] : string.Empty, _options = options, _versions = versions, Path = versionsPath, VersionGroupName = ShaValueGroupName }; string archPattern = updater._arch == string.Empty ? string.Empty : "|" + updater._arch; string osPattern = updater._os == string.Empty ? string.Empty : "|" + updater._os; updater.Regex = new Regex( $"{shaVariablePattern.Replace(".*", Regex.Escape(osPattern + archPattern))} \"(?<{ShaValueGroupName}>.*)\""); return updater; }) .ToArray()); }