lusis/chef-logstash — pull request #353 by martinb3 (2014-09-17 16:37:46+00:00)
Title: Improve default attribute handling

Refactor default handling so that you can mix defaults and specific overrides better. This should be a backwards compatible change, but it will no longer raise exceptions for attributes that the caller forgot to supply or configure. For this reason, it seems like it should be a minor release bump, not a patch version bump.

Before, the code below meant that if you supplied any `@instance`, you had to override every single value or you would see NoMethodError will `nil` and `[]` on statements like `@owner = new_resource.owner || attributes['user'] || defaults['user']`:
```
if node['logstash']['instance'].key?(@instance)
attributes = node['logstash']['instance'][@instance]
defaults = node['logstash']['instance']['default']
else
attributes = node['logstash']['instance']['default']
end
```

I've moved all of the default settings into a separate namespace `node['logstash']['instance_default']` from `node['logstash']['instance']` (this was confusing that it overlapped with regular configs, and you could never name one default). I also moved of those `lwrp_resource_param || attribute || default` into `libraries/logstash_util.rb` into `#deep_fetch` which means the attribute 'default vs. override' decision now happens all in one place.

I also moved the `java_home` default into the regular defaults array (it seems like something where I might not want to repeat it for every LWRP call, though you can still, if needed).

As a bonus, it reduced the repetition and overall size. I also added `vagrant-wrapper` to Gemfile. Bundler was mad that it was needed by `kitchen-vagrant`, but wasn't declared.

/ CC @paulczar @hhoover @lusis