Skip to content

Commit

Permalink
(chocolateyGH-1347) API Fix: GetConfiguration() manipulates config
Browse files Browse the repository at this point in the history
Previously, `GetChocoaltey.GetConfiguration()` would allow manipulating
the configuration for other calls when using Chocolatey's API. Ensure
that it is purely used for informational purposes and won't affect the
settings that are used when running Chocolatey's API with future calls.
  • Loading branch information
ferventcoder committed Aug 29, 2017
1 parent b709dc3 commit 19f068f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/chocolatey/GetChocolatey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,22 @@ public int ListCount()
}

/// <summary>
/// Gets the configuration. Should be used purely for informational purposes
/// Gets a copy of the configuration. Any changes here will have no effect as this is provided purely for informational purposes.
/// </summary>
/// <returns>The configuration for Chocolatey</returns>
/// <remarks>Only call this once you have registered all container components with Chocolatey</remarks>
public ChocolateyConfiguration GetConfiguration()
{
ensure_environment();

return create_configuration(new List<string>());
// ensure_original_configuration() already calls create_configuration()
// so no need to repeat, just grab the result
var configuration = ensure_original_configuration(
new List<string>(),
(config) => config
);

return configuration;
}

private void ensure_original_configuration(IList<string> args, Action<ChocolateyConfiguration> action)
Expand Down

0 comments on commit 19f068f

Please sign in to comment.