Exemplo n.º 1
0
        private static async Task <ManifestInfo?> GetSubscriptionManifestAsync(Subscription subscription,
                                                                               ManifestFilterOptions filterOptions, HttpClient httpClient, ILoggerService loggerService,
                                                                               Action <ManifestOptions>?configureOptions)
        {
            // If the command is filtered with an OS type that does not match the OsType filter of the subscription,
            // then there are no images that need to be inspected.
            string osTypeRegexPattern = ManifestFilter.GetFilterRegexPattern(filterOptions.OsType);

            if (!string.IsNullOrEmpty(subscription.OsType) &&
                !Regex.IsMatch(subscription.OsType, osTypeRegexPattern, RegexOptions.IgnoreCase))
            {
                return(null);
            }

            string repoPath = await GitHelper.DownloadAndExtractGitRepoArchiveAsync(httpClient, subscription.Manifest, loggerService);

            try
            {
                TempManifestOptions manifestOptions = new(filterOptions)
                {
                    Manifest  = Path.Combine(repoPath, subscription.Manifest.Path),
                    Variables = subscription.Manifest.Variables
                };

                configureOptions?.Invoke(manifestOptions);

                return(ManifestInfo.Load(manifestOptions));
            }
            finally
            {
                // The path to the repo is stored inside a zip extraction folder so be sure to delete that
                // zip extraction folder, not just the inner repo folder.
                Directory.Delete(new DirectoryInfo(repoPath).Parent !.FullName, true);
            }
        }
Exemplo n.º 2
0
        public static async Task <IEnumerable <(Subscription Subscription, ManifestInfo Manifest)> > GetSubscriptionManifestsAsync(
            string subscriptionsPath, ManifestFilterOptions filterOptions, HttpClient httpClient, ILoggerService loggerService,
            Action <ManifestOptions>?configureOptions = null)
        {
            string subscriptionsJson = File.ReadAllText(subscriptionsPath);

            Subscription[] subscriptions = JsonConvert.DeserializeObject <Subscription[]>(subscriptionsJson);

            List <(Subscription Subscription, ManifestInfo Manifest)> subscriptionManifests = new
                                                                                              List <(Subscription Subscription, ManifestInfo Manifest)>();

            foreach (Subscription subscription in subscriptions)
            {
                ManifestInfo?manifest = await GetSubscriptionManifestAsync(
                    subscription, filterOptions, httpClient, loggerService, configureOptions);

                if (manifest is not null)
                {
                    subscriptionManifests.Add((subscription, manifest));
                }
            }

            return(subscriptionManifests);
        }
Exemplo n.º 3
0
 public TempManifestOptions(ManifestFilterOptions filterOptions)
 {
     FilterOptions = filterOptions;
 }