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

Support fact stringyfication #908

Merged
merged 1 commit into from
Jun 15, 2024
Merged

Conversation

bastelfreak
Copy link
Member

FacterDB/rspec-puppet-facts have an option switch the symbolized first-level keys in a factset to strings (all following/nested keys are always strings). This PR makes this configuration opt-in so we can switch over modules from symbols to strings in their spec files.

@bastelfreak
Copy link
Member Author

Tested at voxpupuli/puppet-allknowingdns#64

moduleroot/spec/spec_helper.rb.erb Outdated Show resolved Hide resolved
moduleroot/spec/spec_helper.rb.erb Outdated Show resolved Hide resolved
@@ -20,6 +21,12 @@ RSpec.configure do |c|
c.hiera_config = <%= @configs['hiera_config'] %>
end
<%- end -%>
<%- if @configs['facterdb_string_keys'] -%>
Copy link
Member

Choose a reason for hiding this comment

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

I'd tempted to always write it out to become independent of the default in the gem. That way we can just flip the default without breaking things.

Copy link
Member Author

Choose a reason for hiding this comment

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

that's why I added a default to config_defaults.yml. But I can remove the if condition here if you like.

Copy link
Member

Choose a reason for hiding this comment

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

but the default is false. If you want it unconditionally, you should check for .nil?

Copy link
Member Author

@bastelfreak bastelfreak Jun 15, 2024

Choose a reason for hiding this comment

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

I'm not sure if I can follow your thoughts. My idea was to always add the facterdb_string_keys option with a default of false and individual modules can switch to true. And if we ever want to, we can set the default to true in rspec-puppet-facts and that works with the current code. Did you have something else in mind?

@bastelfreak bastelfreak force-pushed the facterdb branch 2 times, most recently from 366a5fb to 870fcd3 Compare June 15, 2024 12:22
@bastelfreak bastelfreak requested a review from ekohl June 15, 2024 12:26
@bastelfreak
Copy link
Member Author

moduleroot/spec/spec_helper.rb.erb Outdated Show resolved Hide resolved
moduleroot/spec/spec_helper.rb.erb Outdated Show resolved Hide resolved
moduleroot/spec/spec_helper.rb.erb Outdated Show resolved Hide resolved
FacterDB/rspec-puppet-facts have an option switch the symbolized
first-level keys in a factset to strings (all following/nested keys are
always strings). This PR makes this configuration opt-in so we can
switch over modules from symbols to strings in their spec files.
@bastelfreak bastelfreak merged commit 6673963 into voxpupuli:master Jun 15, 2024
4 checks passed
@bastelfreak bastelfreak deleted the facterdb branch June 15, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants