private void AddDockerfilePathLegs(
            MatrixInfo matrix, IEnumerable <string> matrixNameParts, IGrouping <PlatformId, PlatformInfo> platformGrouping)
        {
            IEnumerable <string> platformNameParts = new string[] {
                platformGrouping.Key.OsVersion ?? platformGrouping.Key.OS.GetDockerName(),
                platformGrouping.Key.Architecture.GetDockerName(),
            };

            IEnumerable <IEnumerable <PlatformInfo> > subgraphs = platformGrouping.GetCompleteSubgraphs(GetPlatformDependencies);

            foreach (IEnumerable <PlatformInfo> subgraph in subgraphs)
            {
                string[] dockerfilePaths = GetDockerfilePaths(subgraph)
                                           .Union(GetCustomLegGroupingDockerfilePaths(subgraph))
                                           .ToArray();

                LegInfo leg = new LegInfo()
                {
                    Name = GetDockerfilePathLegName(dockerfilePaths, platformNameParts, matrixNameParts)
                };
                matrix.Legs.Add(leg);

                AddImageBuilderPathsVariable(dockerfilePaths, leg);
                AddPlatformVariables(platformGrouping, leg);
            }
        }
        private void AddVersionedOsLegs(MatrixInfo matrix, IGrouping <PlatformId, PlatformInfo> platformGrouping)
        {
            var versionGroups = platformGrouping
                                .GroupBy(platform => new
            {
                // Assumption:  Dockerfile path format <ProductVersion>/<ImageVariant>/<OsVariant>/...
                DotNetVersion = platform.DockerfilePath.Split(s_pathSeparators)[0],
                OsVariant     = platform.DockerfilePath.Split(s_pathSeparators)[2].TrimEnd("-slim")
            });

            foreach (var versionGrouping in versionGroups)
            {
                LegInfo leg = new LegInfo()
                {
                    Name = $"{versionGrouping.Key.DotNetVersion}-{versionGrouping.Key.OsVariant}"
                };
                matrix.Legs.Add(leg);

                AddPlatformVariables(platformGrouping, leg);
                leg.Variables.Add(("dotnetVersion", versionGrouping.Key.DotNetVersion));
                leg.Variables.Add(("osVariant", versionGrouping.Key.OsVariant));

                IEnumerable <string> dockerfilePaths = GetDockerfilePaths(versionGrouping)
                                                       .Union(GetCustomLegGroupingDockerfilePaths(versionGrouping));

                AddImageBuilderPathsVariable(dockerfilePaths.ToArray(), leg);
            }
        }
Esempio n. 3
0
        private static void AddVersionedOsLegs(
            MatrixInfo matrix, IGrouping <dynamic, PlatformInfo> platformGrouping, bool includeArchitectureName)
        {
            var versionGroups = platformGrouping
                                .GroupBy(platform => new
            {
                // Assumption:  Dockerfile path format <ProductVersion>/<ImageVariant>/<OsVariant>/...
                DotNetVersion = platform.DockerfilePath.Split(PathSeparators)[0],
                OsVariant     = platform.DockerfilePath.Split(PathSeparators)[2].TrimEnd("-slim")
            });

            foreach (var versionGrouping in versionGroups)
            {
                string legName = $"{versionGrouping.Key.DotNetVersion}-{versionGrouping.Key.OsVariant}";
                if (includeArchitectureName)
                {
                    legName += $"-{GetArchitectureDisplayName(platformGrouping)}";
                }

                LegInfo leg = new LegInfo()
                {
                    Name = legName
                };
                matrix.Legs.Add(leg);

                leg.Variables.Add(("dotnetVersion", versionGrouping.Key.DotNetVersion));
                leg.Variables.Add(("osType", platformGrouping.Key.OS.ToString().ToLowerInvariant()));
                leg.Variables.Add(("osVariant", versionGrouping.Key.OsVariant));
                leg.Variables.Add(("osVersion", platformGrouping.Key.OS == OS.Windows ? platformGrouping.Key.OsVersion : "*"));
                leg.Variables.Add(("architecture", platformGrouping.Key.Architecture.ToString().ToLowerInvariant()));
            }
        }
        private static void AddImageBuilderPathsVariable(string[] dockerfilePaths, LegInfo leg)
        {
            string pathArgs = dockerfilePaths
                              .Select(path => $"--path {path}")
                              .Aggregate((working, next) => $"{working} {next}");

            leg.Variables.Add(("imageBuilderPaths", pathArgs));
        }
Esempio n. 5
0
        private void AddBuildLegs(MatrixInfo matrix, string[] matrixNameParts, IGrouping <dynamic, PlatformInfo> platformGrouping)
        {
            IEnumerable <IEnumerable <PlatformInfo> > subgraphs = platformGrouping.GetCompleteSubgraphs(GetPlatformDependencies);

            foreach (IEnumerable <PlatformInfo> subgraph in subgraphs)
            {
                string[] dockerfilePaths = subgraph
                                           .Select(platform => platform.Model.Dockerfile)
                                           .ToArray();
                LegInfo leg = new LegInfo()
                {
                    Name = FormatLegName(dockerfilePaths, matrixNameParts)
                };
                matrix.Legs.Add(leg);

                string pathArgs = dockerfilePaths
                                  .Select(path => $"--path {path}")
                                  .Aggregate((working, next) => $"{working} {next}");
                leg.Variables.Add(("imageBuilderPaths", pathArgs));
            }
        }
 private static void AddPlatformVariables(IGrouping <PlatformId, PlatformInfo> platformGrouping, LegInfo leg)
 {
     leg.Variables.Add(("osType", platformGrouping.Key.OS.GetDockerName()));
     leg.Variables.Add(("architecture", platformGrouping.Key.Architecture.GetDockerName()));
     leg.Variables.Add(("osVersion", platformGrouping.Key.OsVersion ?? "*"));
 }