-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add mocked custom facts based on metadata #19
Conversation
I suppose it's not practical to look up a module's complete list of dependencies (ie dependencies of the dependencies listed in metadata.json)?? |
In theory we could look at the fixtures I guess. That might be the closest you get. |
|
||
# Rough conversion of grepping in the puppet source: | ||
# grep defaultfor lib/puppet/provider/service/*.rb | ||
add_custom_fact :service_provider, ->(os, facts) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rubocop was complaining that I should use the lambda syntax, that is the reason why puppet/caddy
looks different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I know. As you can see by the date on the commit this has been around for a while. This repo probably should also gain rubocop.
metadata['dependencies'].each do |dependency| | ||
case normalize_module_name(dependency['name']) | ||
when 'camptocamp/systemd' | ||
add_custom_fact :systemd, ->(os, facts) { facts[:service_provider] == 'systemd' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add the fact systemd_version
. Sometimes a parameter requires a specific version of Systemd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not opposed, but at this point I'm very busy since the Foreman is getting close to the 2.1 release cycle and a lot has to be done on my end. My goal of this PR was to share my intent so people don't develop the same thing again. I'm happy it did, but right now I don't really have time to test it and push for the major cleanup.
If someone wants to do so, I'd be happy if they could confirm. What I'd normally do is use modulesync to check out all modules, then grep for service_provider
in modules/vopupuli/puppet-*/spec
and see where it is already mocked. Update those modules to use this change, see if tests pass. If they do, get this merged, released and do a modulesync.
yes, that would probably work a bit better as .fixtures.yml has to include all of those dependencies anyway. |
We can actually assume fixtures are checked out since rspec requires them. I think we actually have a variable for the module paths somewhere that we can read. Good idea. |
Rebased and opened voxpupuli/puppet-redis#380 to see if it works. Looks like it does so I'm marking this ready for review. |
No description provided.