public IEnumerable <Platform> GetPlatforms(Image image) { IEnumerable <Platform> platforms = image.Platforms; if (IncludeArchitecture != null) { string archRegexPattern = GetFilterRegexPattern(IncludeArchitecture); platforms = platforms.Where(platform => Regex.IsMatch(platform.Architecture.GetDockerName(), archRegexPattern, RegexOptions.IgnoreCase)); } if (IncludeOsType != null) { string osTypeRegexPattern = GetFilterRegexPattern(IncludeOsType); platforms = platforms.Where(platform => Regex.IsMatch(platform.OS.GetDockerName(), osTypeRegexPattern, RegexOptions.IgnoreCase)); } if (IncludePaths?.Any() ?? false) { string pathsRegexPattern = GetFilterRegexPattern(IncludePaths.ToArray()); platforms = platforms.Where(platform => Regex.IsMatch(platform.Dockerfile, pathsRegexPattern, RegexOptions.IgnoreCase)); } if (IncludeOsVersions?.Any() ?? false) { string includeOsVersionsPattern = GetFilterRegexPattern(IncludeOsVersions.ToArray()); platforms = platforms.Where(platform => Regex.IsMatch(platform.OsVersion ?? string.Empty, includeOsVersionsPattern, RegexOptions.IgnoreCase)); } return(platforms.ToArray()); }
public IEnumerable <Platform> FilterPlatforms(IEnumerable <Platform> platforms, string?resolvedProductVersion) { if (IncludeProductVersions?.Any() ?? false) { string includeProductVersionsPattern = GetFilterRegexPattern(IncludeProductVersions.ToArray()); if (resolvedProductVersion is not null && !Regex.IsMatch(resolvedProductVersion, includeProductVersionsPattern, RegexOptions.IgnoreCase)) { return(Enumerable.Empty <Platform>()); } } if (!string.IsNullOrEmpty(IncludeArchitecture)) { string archRegexPattern = GetFilterRegexPattern(IncludeArchitecture); platforms = platforms.Where(platform => Regex.IsMatch(platform.Architecture.GetDockerName(), archRegexPattern, RegexOptions.IgnoreCase)); } if (!string.IsNullOrEmpty(IncludeOsType)) { string osTypeRegexPattern = GetFilterRegexPattern(IncludeOsType); platforms = platforms.Where(platform => Regex.IsMatch(platform.OS.GetDockerName(), osTypeRegexPattern, RegexOptions.IgnoreCase)); } if (IncludePaths?.Any() ?? false) { string pathsRegexPattern = GetFilterRegexPattern(IncludePaths.ToArray()); platforms = platforms.Where(platform => Regex.IsMatch(platform.Dockerfile, pathsRegexPattern, RegexOptions.IgnoreCase)); } if (IncludeOsVersions?.Any() ?? false) { string includeOsVersionsPattern = GetFilterRegexPattern(IncludeOsVersions.ToArray()); platforms = platforms.Where(platform => Regex.IsMatch(platform.OsVersion ?? string.Empty, includeOsVersionsPattern, RegexOptions.IgnoreCase)); } return(platforms.ToArray()); }