/// <summary> /// Outputs container image objects for each image matching the provided parameters. /// </summary> protected override async Task ProcessRecordAsync() { var listParams = new ImagesListParameters() { All = (All || Id != null) }; foreach (var img in await DkrClient.Images.ListImagesAsync(listParams)) { if (Id == null || Id.Any(i => img.RepoTags.Any(r => i.Split('/').Last().Contains(":") ? r == i : r == (i + ":latest"))) || Id.Any(i => img.ID.StartsWith(i) || img.ID.StartsWith("sha256:" + i))) { WriteObject(img); } } }
private IEnumerable <IPackage> GetPackages(IPackageRepository repository) { var packages = repository.GetPackages(); if (Id.Any()) { var packageIdSet = new HashSet <string>(packages.Select(r => r.Id), StringComparer.OrdinalIgnoreCase); var idSet = new HashSet <string>(Id, StringComparer.OrdinalIgnoreCase); var invalid = Id.Where(id => !packageIdSet.Contains(id)); if (invalid.Any()) { throw new CommandLineException(NuGetResources.UnableToFindPackages, String.Join(", ", invalid)); } packages = packages.Where(r => idSet.Contains(r.Id)); } var packageSorter = new PackageSorter(targetFramework: null); return(packageSorter.GetPackagesByDependencyOrder(new ReadOnlyPackageRepository(packages)).Reverse()); }
public void Validate() { char[] invalid = Path.GetInvalidFileNameChars(); if (FileInclusions.Any(ext => ext.Any(c => invalid.Contains(c)) || ext.Contains('.'))) { throw new ArgumentException("One or more file extensions are not valid"); } if (FileExclusions.Any(ext => ext.Any(c => invalid.Contains(c)) || ext.Contains('.'))) { throw new ArgumentException("One or more file extensions are not valid"); } invalid = Path.GetInvalidPathChars(); if (DirExclusions.Any(ext => ext.Contains(Path.DirectorySeparatorChar) || ext.Any(c => invalid.Contains(c)))) { throw new ArgumentException("One or more dir exclusions are not valid"); } if (!string.IsNullOrEmpty(Id) && (Id.Contains(Path.DirectorySeparatorChar) || Id.Any(c => invalid.Contains(c)))) { throw new ArgumentException("The backup id is not valid"); } if (MaxSize <= 100) { throw new ArgumentException("The maximum size must be at least 100KB"); } if (string.IsNullOrEmpty(SourceDirectory) && !SourceDirectoryCurrent) { throw new ArgumentException("The source directory can't be empty"); } if (SourceDirectoryCurrent && !string.IsNullOrEmpty(SourceDirectory)) { throw new ArgumentException("The --source-current and --source options can't be used at the same time"); } if (!string.IsNullOrEmpty(SourceDirectory)) { invalid = Path.GetInvalidPathChars(); if (SourceDirectory.Any(c => invalid.Contains(c))) { throw new ArgumentException("The source directory isn't valid"); } if (!Directory.Exists(SourceDirectory)) { throw new ArgumentException("The source directory doesn't exist"); } } if (!Directory.Exists(TargetDirectory)) { throw new ArgumentException("The target directory doesn't exist"); } if (FileInclusions.Any() && FileExclusions.Any()) { throw new ArgumentException("The list of extensions to exclude must be empty when other extensions to look for are specified"); } if (Preset != ExtensionsPreset.None && (FileInclusions.Any() || FileExclusions.Any())) { throw new ArgumentException("The preset option cannot be used with --include or --exclude"); } if (Threads == 0 || Threads < -1) { throw new ArgumentException("Invalid number of threads"); } if (Multithread && Threads == 1) { throw new ArgumentException("Do you really want to multithread with just a single thread?"); } }