Skip to content

(11298) Utilize facter/util/cfpropertylist to read/write plist files on OS X#262

Closed
glarizza wants to merge 11 commits intopuppetlabs:2.7.xfrom
glarizza:feature/2.7.x/plist_support
Closed

(11298) Utilize facter/util/cfpropertylist to read/write plist files on OS X#262
glarizza wants to merge 11 commits intopuppetlabs:2.7.xfrom
glarizza:feature/2.7.x/plist_support

Conversation

@glarizza
Copy link
Copy Markdown

@glarizza glarizza commented Dec 8, 2011

CFPropertyList is a Ruby library that can read/write XML AND binary plist files without having to use the 'plutil' command on OS X. The end-result is exponentially faster Puppet runs that have to query/stop/start OS X services.

This set of commits will utilize that library if it's found in Facter, and roll back to the older facter/util/plist library should it not exist. I will be filing a pull request against Facter simultaneously.

Gary Larizza added 11 commits December 8, 2011 10:47
Remove support for the facter/util/plist library and
plutil.
Add support for CFPropertyList that will be vendored in
facter/util.
If a launchd plist reports nil, skip it.
Instead of explicitly saving all plists to XML, use
FORMAT_AUTO to save to their existing format.
Setting FORMAT_AUTO caused errors in Puppet.  Reverting the
change until it can be sorted out.
The implementation had a bug where the save method was 
attempted on a Hash instead of a CFPropertyList::List
Plist file.  This commit fixes that.
Since we no longer use Plist::Emit to save changes, the spec tests
were adapted to the newer methods.
When a plist file has a bad doctype string it will still pass lint,
but ruby's libxml will flag it as malformed and throw an error. This
is compounded by the fact that Apple ships a plist in 10.6 that has
a bad doctype string (/System/Library/LaunchDaemons/org.ntp.ntpd.plist).
It's not our job to 'correct' the file, so instead a debug message is
thrown, the plist file is read into a variable, and the doctype string
in the variable is substituted for a correct doctype string.
The CFPropertyList library vendored in facter/util will parse plists faster
than the facter/util/plist library, however if CFPropertyList isn't installed
there needs to be a failback to facter/util/plist.  

If facter/util/cfpropertylist is installed, we will default to that behavior,
but if it isn't, the $legacy_plist_support variable will be set to true and
Puppet will default back to facter/util/plist library.
We've introduced facter/util/cfpropertylist as a method by which to
read/save plist files, so we need to test for that. This commit
adapts our tests to ultimately test for the same end-result while
adjusting what Mocha expects depending on the plist library used.

The $legacy_plist_support variable will be set in the launchd
provider when we're using the older facter/util/plist library, so
we're using the presence of that variable to indicate whether we're
using the older facter/util/plist library or newer
facter/util/cfpropertylist library.
@glarizza
Copy link
Copy Markdown
Author

glarizza commented Dec 9, 2011

This code relies on the corresponding pull request for Facter, which is here puppetlabs/facter#109

@slippycheeze
Copy link
Copy Markdown
Contributor

The pair is closed as "pending other changes, not merged", so I am going to close this off on the same basis.

Sorry it took so long to get this looked at. I have no in-principal object to the change.

hlindberg pushed a commit to hlindberg/puppet that referenced this pull request Oct 16, 2014
minor update to event code of conduct
melissa pushed a commit to melissa/puppet that referenced this pull request Mar 30, 2018
 (PCP-174) Acceptance - refactor cert paths

LGTM @ commit 8040582

I'll follow up with a PR to add the helper method to give neat test failures when retry_on fails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants