(GH-145) Add insync? and invoke_test_method to dsc provider #124
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 PR the DSC base provider had no way to handle resource level insync checks and could only rely on the default property-by-property insync checks in Puppet::Property. This fell short in cases where such a check could not work, such as in cases where the DSC Resource does not return the expected values in Get or had a mismatch between its API spec and the implementation.
This PR:
@@cached_test_resultscached_test_results, to retrieve the cacheinsync?method which can be called by the resource API; for more info, see Allow custom insync? checking for resources puppet-resource_api#225. This method only handles custom insync validation for a resource which has thevalidation_modespecified asresourceand otherwise defaults to the existing behavior. If thevalidation_modeis specified asresourcehowever, it instead first checks the test result cache for whether or not the resource is in the desired state and, if the resource has not already been cached, callsinvoke_test_methodand returns that result.Invoke-DscResourcesimilarly to the existinginvoke_set_method; unlike with set, however, it caches the name and whether or not the resource is in the desired state and then returnstrueif in the desired state and otherwisefalse. In cases where something goes wrong, it writes an error and returnsnil.This PR includes new unit tests for the additional methods.
This PR makes progress towards but does not alone implement puppetlabs/Puppet.Dsc#145; it is also blocked on the RSAPI changes in puppetlabs/puppet-resource_api#225.