Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #19792 - cryptic error when missing deep_merge gem #124

Merged
merged 1 commit into from
Mar 27, 2013
Merged

Fix #19792 - cryptic error when missing deep_merge gem #124

merged 1 commit into from
Mar 27, 2013

Conversation

justenwalker
Copy link
Contributor

The configuration loader will try to pre-emptively load 'deep_merge' if
the 'deep' or 'deeper' options were given to :merge_behavior.

If the load fails, it will warn the user and revert back to 'native'.

WARN: Tue Mar 26 18:02:33 -0400 2013: Ignoring configured merge_behavior
WARN: Tue Mar 26 18:02:33 -0400 2013: Must have 'deep_merge' gem installed.

rescue LoadError
Hiera.warn "Ignoring configured merge_behavior"
Hiera.warn "Must have 'deep_merge' gem installed."
@config[:merge_behavior] = :native
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Falling back to :native for the merge behavior is the right behavior, but I think this is introducing test failures (https://travis-ci.org/puppetlabs/hiera/jobs/5823971#L215). This implementation means that there's no way to leave deep merging on for the purposes of testing. This means means that unit tests around deep merging either have to be disabled if the deep_merge gem isn't installed, we have to mock out require (which is incredibly dangerous) or this needs to be extracted out. If this was extracted into a method then this could simply be stubbed out for the purposes of tests.

@justenwalker
Copy link
Contributor Author

d6cf021 solves this problem.

This also allows us to stub out any other config validation logic that may have side-effects.

The configuration loader will try to pre-emptively load 'deep_merge' if
the 'deep' or 'deeper' options were given to :merge_behavior.

If the load fails, it will warn the user and revert back to 'native'.
@justenwalker
Copy link
Contributor Author

I've cleaned up the branch history since it really only deserves one commit - they are all related changes.

@adrienthebo
Copy link
Contributor

@justenwalker looks great!

I'm merging this into master, but I want to note that as of 2013-03-27 we have a 1.x branch. It's identical to master so we might want to cut the 1.2 release from master, but that's release eng's job to make the call.

adrienthebo added a commit that referenced this pull request Mar 27, 2013
Fix #19792 - cryptic error when missing deep_merge gem
@adrienthebo adrienthebo merged commit 995a021 into puppetlabs:master Mar 27, 2013
@adrienthebo
Copy link
Contributor

Merged into master as 995a021.

This should be released in 1.2.0.

Thanks again for the contribution!

-Adrien

@justenwalker justenwalker deleted the bug-19792 branch March 27, 2013 18:27
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