-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Allow loading of external fact hashes #62
Conversation
2 similar comments
f56468c
to
fd30a03
Compare
fd30a03
to
c3b14c3
Compare
2 similar comments
c3b14c3
to
22d0c11
Compare
Gemfile
Outdated
@@ -7,3 +7,7 @@ if facterversion = ENV['FACTER_GEM_VERSION'] | |||
else | |||
gem 'facter', :require => false | |||
end | |||
|
|||
group :dev do | |||
gem 'pry' |
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.
Can you add this to the gemspec as a development dependency instead of here?
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.
added to gemspec
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.
then you can remove it here?
lib/facterdb.rb
Outdated
def self.external_fact_files(fact_paths = ENV['FACTERDB_SEARCH_PATH']) | ||
fact_paths ||= '' | ||
return [] if fact_paths.empty? | ||
paths = fact_paths.split(',').map do |fact_path| |
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.
Rather than splitting by ,
, can we change this to File::PATH_SEPARATOR
which will be a bit more idiomatic to users (:
on Linux/BSD/etc, ;
on Windows)
lib/facterdb.rb
Outdated
end | ||
File.join(fact_path.strip, '**', '*.facts') | ||
end.compact | ||
Dir.glob(paths) |
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.
Dir.glob
behaves badly when passed Windows style backslash delimited paths, so I'd recommend adding the following line to the above map before the final File.join
to convert the backslashes.
fact_path = fact_path.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
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.
These are great suggestions. Fixed in latest push.
22d0c11
to
e95cb33
Compare
1 similar comment
This is ready to go after adding the suggested fixes. @rodjek |
I like the idea, and given that there is already https://github.com/mcanevet/rspec-puppet-facts#set-global-custom-facts there is surely a need for it, too. In the light of #61 , I wonder if it wouldn't make sense to extend this even further and make the first/default entry of |
@DavidS we can do something like this:
|
Also now that I look at this. I am going to change |
Re the default search path, I've spent some more time on that, and I think we should optimize strongly for the default case of folks using the built-in facts. What about |
* previously there was no way to supply facterdb with external facts that contain sensitive information. This fixes that by allowing the user to set an environment variable that take precedence over the facts from this gem.
e95cb33
to
695e103
Compare
3 similar comments
I have added @DavidS suggestions and updated the readme to include this additional info on how to skip the default database. I think this feature will be a big hit. |
@@ -6,4 +6,4 @@ if facterversion = ENV['FACTER_GEM_VERSION'] | |||
gem 'facter', facterversion, :require => false | |||
else | |||
gem 'facter', :require => false | |||
end | |||
end |
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.
:-(
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 didn't want to get rubocop involved as it would have changed a whole lot of code. But now that this is merged, let the games begin. Also we need to bump the version.
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++, and I would suggest the PDK template, obviously. But final say is with @mcanevet and @raphink .
the version gets bumped during release-prep in accordance with the changes in the release.
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.
@DavidS I didn't have time to check PDK yet but feel free to add this in this module. Ping me onde it's OK for release.
external facts that contain sensitive information. This
fixes that by allowing the user to set an environment variable
that take precedence over the facts from this gem.