(MODULES-4275) Customize ACE YAML serialization #97
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.
Ruby 2.3 has changed the behavior of YAML serialization so that
Hash derived instances will serialize all of their instance
variables per:
ruby/ruby@fe0414b
Psych used to produce an empty serialization of the ACE type in
Ruby 2.1.9 like:
--- !ruby/hash:Puppet::Type::Acl::Ace {}In Ruby 2.3, it will produce something like this:
The issue that arises is that @Provider is a Puppet provider
instance that cannot be YAML serialized and will crash in 2 key
situations during a Puppet run:
The solution is to implement the encode_with method on the ACE type
to control what gets serialized. Since ACE already has a to_hash
method, let it do the heavy lifting to produce the bare Hash
structure for Psych to serialize.
Note that nil is passed as the "tag" used by Pysch, which means
that the key / value pairs are emitted as a bare YAML hash instead
of the custom type:
--- !ruby/object:Puppet::Type::Acl::Acedescribed in PCP-542 where the master is unable to deserialize
YAML strings like the following because the Ruby classes are not
loaded on the master:
!ruby/hash:Puppet::Type::Acl::Ace {}within Puppe to address Ruby 2.3 related behavioral changes.