Skip to content
This repository was archived by the owner on Nov 6, 2018. It is now read-only.

Update resources to current quality standards #20

Open
jtimberman opened this issue Oct 22, 2014 · 4 comments
Open

Update resources to current quality standards #20

jtimberman opened this issue Oct 22, 2014 · 4 comments

Comments

@jtimberman
Copy link
Contributor

The resources in this cookbook were written many moons ago. It was a primitive time, when things like "testing" weren't done.

Laundry list of improvements this cookbook needs:

Test Kitchen

While we can't distribute OS X vagrant boxes for using Test Kitchen, internally at CHEF we have some, and we should use those to enable testing with Test Kitchen.

Rename the Resources

This cookbook includes two resources:

  • mac_os_x_userdefaults
  • mac_os_x_plist_file

These are both awkward to type. They are also relatively simple LWRPs, and could be easily converted to subclass LWRPBase. This would give better flexibility for making alias resources. I am proposing:

  • osx_defaults
  • osx_plist

This gives clarity that they're for OS X. The old resource names would be aliases, and the attributes would remain.

State Attributes

Chef Reporting uses "state attributes" for reporting information about a Chef run. We should define those for the resources in this cookbook.

Why Run Mode

The LWRPs use inline resources, which gives us automatic why run mode support. This should be defined with the why_run_supported? method defined to return true.

Use inline resources

As stated, LWRPs here use inline resources, but we don't use the use_inline_resources method.

Use default action

We set default actions using #initialize rather than the default_action method.

ChefSpec Coverage

We need full ChefSpec coverage. This is related to Test Kitchen support.

ServerSpec Coverage

We need adequate ServerSpec coverage. This is related to Test Kitchen support.

Backwards Compatibility

This cookbook must remain backwards compatible. We can achieve that through proper test coverage.

Tests must be written and verified before refactoring the resources begins.

Platform Support

The goal is to support the following OS X platform versions:

  • 10.9
  • 10.10

Initially, 10.9 and 10.10 will be supported (as I have VMware Fusion vagrant boxes for TK). 10.8 support can come if a) someone provides it or b) it just works without additional effort. To my knowledge, Apple hasn't dramatically changed the way the defaults(1) system works.

@jtimberman
Copy link
Contributor Author

In the interest of collaboration and consolidation:

There is a fork of this cookbook, osx, which duplicates much of the functionality of the LWRPs, with shorter names of the resources. We should incorporate bug fixes from that and work with the maintainer to deprecate it.

The goal would be to make use of either cookbook interchangeable and backwards compatible.

@jtimberman
Copy link
Contributor Author

Further, the reason to keep the mac_os_x cookbook name is that's what ohai reports as the platform name.

@agh
Copy link
Contributor

agh commented Oct 22, 2014

Oh hello. I don't think that I did much more than a find and replace to substitute osx into the LWRPs. Honestly been a while since I looked at that cookbook. It's probably all kinds of bad.

I used osx because I think Apple officially called it 'OS X' starting 2-3 years ago, and ohai never caught up with that naming change. Plus typing osx_userdefaults is easier.

@jtimberman
Copy link
Contributor Author

The defaults(1) man page refers to this as the "Mac OS X user defaults system." I think that user_defaults makes the most sense as a resource name.

It wouldn't be terribly difficult to maintain backwards compatibility with osx_userdefaults and mac_os_x_userdefaults by making those aliases for a user_defaults resource.

mac_os_x_userdefaults "enable time machine on unsupported volumes" do
  domain "com.apple.systempreferences"
  key "TMShowUnsupportedNetworkVolumes"
  value "1"
end

# equivalent to this from your cookbook:
osx_userdefaults "enable time machine on unsupported volumes" do
  domain "com.apple.systempreferences"
  key "TMShowUnsupportedNetworkVolumes"
  value "1"
end

# equivalent to this (which would be the actual resource):
user_defaults "enable time machine on unsupported volumes" do
  domain "com.apple.systempreferences"
  key "TMShowUnsupportedNetworkVolumes"
  value "1"
end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants