示例#1
0
        private void InitializeFromImage()
        {
            Match fromMatch = FromRegex.Match(File.ReadAllText(Path.Combine(Model.Dockerfile, "Dockerfile")));

            if (!fromMatch.Success)
            {
                throw new InvalidOperationException($"Unable to find the FROM image in {Model.Dockerfile}.");
            }

            FromImage = fromMatch.Groups["fromImage"].Value;
        }
示例#2
0
        private void InitializeFromImages()
        {
            string dockerfile = File.ReadAllText(this.DockerfilePath);
            IEnumerable <Match> fromMatches = FromRegex.Matches(dockerfile).Cast <Match>();

            if (!fromMatches.Any())
            {
                throw new InvalidOperationException($"Unable to find a FROM image in {this.DockerfilePath}.");
            }

            FromImages = fromMatches.Select(match => match.Groups["fromImage"].Value).ToArray();
        }
示例#3
0
        private void InitializeFromImages()
        {
            string        dockerfile  = File.ReadAllText(DockerfilePath);
            IList <Match> fromMatches = FromRegex.Matches(dockerfile);

            if (!fromMatches.Any())
            {
                throw new InvalidOperationException($"Unable to find a FROM image in {DockerfilePath}.");
            }

            FromImages = fromMatches
                         .Select(match => match.Groups[FromImageMatchName].Value)
                         .Where(from => !IsStageReference(from, fromMatches) && !from.Contains("$"))
                         .ToArray();
        }