From 011ef6ac17cd7567d02a7776af4e1ee370be8e7e Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Wed, 13 Sep 2017 20:48:03 -0500 Subject: [PATCH] (GH-1398) Use feature for ignore unfound pkgs Use a feature flip for ignoring unfound packages for outdated. --- src/chocolatey/infrastructure.app/ApplicationParameters.cs | 1 + .../infrastructure.app/builders/ConfigurationBuilder.cs | 5 +++-- .../infrastructure.app/commands/ChocolateyOutdatedCommand.cs | 4 ++-- .../configuration/ChocolateyConfiguration.cs | 2 +- src/chocolatey/infrastructure.app/services/NugetService.cs | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/chocolatey/infrastructure.app/ApplicationParameters.cs b/src/chocolatey/infrastructure.app/ApplicationParameters.cs index d4330537cb..b8e27b2b84 100644 --- a/src/chocolatey/infrastructure.app/ApplicationParameters.cs +++ b/src/chocolatey/infrastructure.app/ApplicationParameters.cs @@ -166,6 +166,7 @@ public static class Features public static readonly string ShowDownloadProgress = "showDownloadProgress"; public static readonly string StopOnFirstPackageFailure = "stopOnFirstPackageFailure"; public static readonly string UseRememberedArgumentsForUpgrades = "useRememberedArgumentsForUpgrades"; + public static readonly string IgnoreUnfoundPackagesOnUpgradeOutdated = "ignoreUnfoundPackagesOnUpgradeOutdated"; } public static class Messages diff --git a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs index 6ec9a7d20c..cc89b2fae0 100644 --- a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs +++ b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs @@ -284,8 +284,9 @@ private static void set_feature_flags(ChocolateyConfiguration config, ConfigFile config.Features.UseFipsCompliantChecksums = set_feature_flag(ApplicationParameters.Features.UseFipsCompliantChecksums, configFileSettings, defaultEnabled: false, description: "Use FIPS Compliant Checksums - Ensure checksumming done by choco uses FIPS compliant algorithms. Not recommended unless required by FIPS Mode. Enabling on an existing installation could have unintended consequences related to upgrades/uninstalls. Available in 0.9.10+."); config.Features.ShowNonElevatedWarnings = set_feature_flag(ApplicationParameters.Features.ShowNonElevatedWarnings, configFileSettings, defaultEnabled: true, description: "Show Non-Elevated Warnings - Display non-elevated warnings. Available in 0.10.4+."); config.Features.ShowDownloadProgress = set_feature_flag(ApplicationParameters.Features.ShowDownloadProgress, configFileSettings, defaultEnabled: true, description: "Show Download Progress - Show download progress percentages in the CLI. Available in 0.10.4+."); - config.Features.StopOnFirstPackageFailure = set_feature_flag(ApplicationParameters.Features.StopOnFirstPackageFailure, configFileSettings, defaultEnabled: false, description: "Stop On First Package Failure - stop running install, upgrade or uninstall on first package failure instead of continuing with others. As this will affect upgrade all, it is normally recommended to leave this off. Available in 0.10.4+."); - config.Features.UseRememberedArgumentsForUpgrades = set_feature_flag(ApplicationParameters.Features.UseRememberedArgumentsForUpgrades, configFileSettings, defaultEnabled: false, description: "Use Remembered Arguments For Upgrades - when running upgrades, use arguments for upgrade that were used for installation ('remembered'). This is helpful when running upgrade for all packages. Available in 0.10.4+. This is considered in preview for 0.10.4 and will be flipped to on by default in a future release."); + config.Features.StopOnFirstPackageFailure = set_feature_flag(ApplicationParameters.Features.StopOnFirstPackageFailure, configFileSettings, defaultEnabled: false, description: "Stop On First Package Failure - Stop running install, upgrade or uninstall on first package failure instead of continuing with others. As this will affect upgrade all, it is normally recommended to leave this off. Available in 0.10.4+."); + config.Features.UseRememberedArgumentsForUpgrades = set_feature_flag(ApplicationParameters.Features.UseRememberedArgumentsForUpgrades, configFileSettings, defaultEnabled: false, description: "Use Remembered Arguments For Upgrades - When running upgrades, use arguments for upgrade that were used for installation ('remembered'). This is helpful when running upgrade for all packages. Available in 0.10.4+. This is considered in preview for 0.10.4 and will be flipped to on by default in a future release."); + config.Features.IgnoreUnfoundPackagesOnUpgradeOutdated = set_feature_flag(ApplicationParameters.Features.IgnoreUnfoundPackagesOnUpgradeOutdated, configFileSettings, defaultEnabled: false, description: "Ignore Unfound Packages On Upgrade Outdated - When checking outdated or upgrades, if a package is not found against sources specified, don't report the package at all. Available in 0.10.9+."); config.Features.ScriptsCheckLastExitCode = set_feature_flag(ApplicationParameters.Features.ScriptsCheckLastExitCode, configFileSettings, defaultEnabled: false, description: "Scripts Check $LastExitCode (external commands) - Leave this off unless you absolutely need it while you fix your package scripts to use `throw 'error message'` or `Set-PowerShellExitCode #` instead of `exit #`. This behavior started in 0.9.10 and produced hard to find bugs. If the last external process exits successfully but with an exit code of not zero, this could cause hard to detect package failures. Available in 0.10.3+. Will be removed in 0.11.0."); config.PromptForConfirmation = !set_feature_flag(ApplicationParameters.Features.AllowGlobalConfirmation, configFileSettings, defaultEnabled: false, description: "Prompt for confirmation in scripts or bypass."); } diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs index d9e3a6abc5..24d6cdb7a3 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyOutdatedCommand.cs @@ -56,8 +56,8 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon "Ignore Pinned - Ignore pinned packages. Defaults to false. Available in 0.10.6+.", option => configuration.OutdatedCommand.IgnorePinned = option != null) .Add("ignore-unfound", - "Ignore Unfound Packages - Ignore packages that are not found on the sources used (or the defaults). Defaults to false. Available in 0.10.9+.", - option => configuration.OutdatedCommand.IgnoreUnfoundPackages = option != null) + "Ignore Unfound Packages - Ignore packages that are not found on the sources used (or the defaults). Overrides the default feature '{0}' set to '{1}'. Available in 0.10.9+.".format_with(ApplicationParameters.Features.IgnoreUnfoundPackagesOnUpgradeOutdated, configuration.Features.IgnoreUnfoundPackagesOnUpgradeOutdated.to_string()), + option => configuration.Features.IgnoreUnfoundPackagesOnUpgradeOutdated = option != null) ; } diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index edf74c31e6..060739835c 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -387,6 +387,7 @@ public sealed class FeaturesConfiguration public bool ShowDownloadProgress { get; set; } public bool StopOnFirstPackageFailure { get; set; } public bool UseRememberedArgumentsForUpgrades { get; set; } + public bool IgnoreUnfoundPackagesOnUpgradeOutdated { get; set; } //todo remove in 0.11.0 public bool ScriptsCheckLastExitCode { get; set; } @@ -500,7 +501,6 @@ public sealed class PinCommandConfiguration public sealed class OutdatedCommandConfiguration { public bool IgnorePinned { get; set; } - public bool IgnoreUnfoundPackages { get; set; } } [Serializable] diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 1262cb1689..c937ea8644 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -667,7 +667,7 @@ public ConcurrentDictionary upgrade_run(ChocolateyConfigu if (availablePackage == null) { - if (config.OutdatedCommand.IgnoreUnfoundPackages) continue; + if (config.Features.IgnoreUnfoundPackagesOnUpgradeOutdated) continue; string logMessage = "{0} was not found with the source(s) listed.{1} If you specified a particular version and are receiving this message, it is possible that the package name exists but the version does not.{1} Version: \"{2}\"; Source(s): \"{3}\"".format_with(packageName, Environment.NewLine, config.Version, config.Sources); var unfoundResult = packageInstalls.GetOrAdd(packageName, new PackageResult(packageName, version.to_string(), null));