Ejemplo n.º 1
0
 private IDictionary <IProgrammingPlatform, string> GetCompatiblePlatforms(DockerfileContext ctx)
 {
     return(_platformDetector.GetCompatiblePlatforms(ctx, ctx.Platform, ctx.PlatformVersion));
 }
Ejemplo n.º 2
0
        private IList <BuildScriptSnippet> GetBuildSnippets(
            BuildScriptGeneratorContext context,
            IEnumerable <PlatformDetectorResult> detectionResults,
            bool runDetection,
            [CanBeNull] List <string> directoriesToExcludeFromCopyToIntermediateDir,
            [CanBeNull] List <string> directoriesToExcludeFromCopyToBuildOutputDir)
        {
            var snippets = new List <BuildScriptSnippet>();

            IDictionary <IProgrammingPlatform, PlatformDetectorResult> platformsToUse;

            if (runDetection)
            {
                platformsToUse = _compatiblePlatformDetector.GetCompatiblePlatforms(context);
            }
            else
            {
                platformsToUse = _compatiblePlatformDetector.GetCompatiblePlatforms(context, detectionResults);
            }

            foreach (var platformAndDetectorResult in platformsToUse)
            {
                var(platform, detectorResult) = platformAndDetectorResult;

                if (directoriesToExcludeFromCopyToIntermediateDir != null)
                {
                    var excludedDirs = platform.GetDirectoriesToExcludeFromCopyToIntermediateDir(context);
                    if (excludedDirs.Any())
                    {
                        directoriesToExcludeFromCopyToIntermediateDir.AddRange(excludedDirs);
                    }
                }

                if (directoriesToExcludeFromCopyToBuildOutputDir != null)
                {
                    var excludedDirs = platform.GetDirectoriesToExcludeFromCopyToBuildOutputDir(context);
                    if (excludedDirs.Any())
                    {
                        directoriesToExcludeFromCopyToBuildOutputDir.AddRange(excludedDirs);
                    }
                }

                string cleanOrNot = platform.IsCleanRepo(context.SourceRepo) ? "clean" : "not clean";
                _logger.LogDebug($"Repo is {cleanOrNot} for {platform.Name}");

                var snippet = platform.GenerateBashBuildScriptSnippet(context, detectorResult);
                if (snippet != null)
                {
                    _logger.LogDebug(
                        "Platform {platformName} with version {platformVersion} was used.",
                        platform.Name,
                        detectorResult);
                    snippets.Add(snippet);
                }
                else
                {
                    _logger.LogWarning("{platformType}.GenerateBashBuildScriptSnippet() returned null",
                                       platform.GetType());
                }
            }

            return(snippets);
        }
Ejemplo n.º 3
0
 public IDictionary <IProgrammingPlatform, string> GetCompatiblePlatforms(BuildScriptGeneratorContext ctx)
 {
     return(_platformDetector.GetCompatiblePlatforms(ctx, ctx.Language, ctx.LanguageVersion));
 }
Ejemplo n.º 4
0
 private IDictionary <IProgrammingPlatform, PlatformDetectorResult> GetCompatiblePlatforms(DockerfileContext ctx)
 {
     return(_platformDetector.GetCompatiblePlatforms(ctx));
 }