(MODULES-8047) Fix puppet resource chocolateyconfig #146
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this commit running
puppet resource chocolateyconfigwouldfail during the validation block which verified that no config items
were both :present and had an empty :value or were missing :value
altogether.
This is because Chocolatey represents a configuration item which is
using the defaults as an empty string. When collecting instances of
Chocolatey config items from the configuration file, it would find
the items, mark them as :present, and save them with a :value of "".
This would then fail the validation block.
During a
puppet applyrun the validation block is called before theinstances are fetched - and, therefore, before
@property_hashispopulated. This allows us to distinguish between the two calls and error
on any declared resources which specify
:ensureas:presentbut forgetto specify a
:value.This commit moves the validation logic from the type into the provider
in order to allow us to take advantage of the @property_hash information
during a
puppet resourcerun.This commit also updates the
get_configmethod to treat any discoveredChocolatey config item with an empty value as
:absent- this matchesthe behavior of
:ensure => :absentwhich callschoco config unset-this command replaces the existing value of a config item with an empty
string.
Now when returning the list of Chocolatey configs our model of them is
consistent, with
:absentmeaning that the configuration item is setto the default.
This commit does not change the behavior of a
puppet applyrun.This commit does include changes to the unit tests to reflect the
moving of the validation logic.