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

Fixes #37979 - Fix puppet classes import filter when using Ruby 3+ and Regexp/Symbol in YAML file #411

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

neomilium
Copy link

@nadjaheitmann
Copy link
Collaborator

Is this compatible with older Ruby versions?

@neomilium
Copy link
Author

neomilium commented Nov 8, 2024

Is this compatible with older Ruby versions?

I just amended my commit, this should now be compatible with older Ruby versions.

@neomilium
Copy link
Author

neomilium commented Nov 21, 2024

@nadjaheitmann Is there is anything I could do to help here?

@stejskalleos stejskalleos self-assigned this Dec 3, 2024
@stejskalleos
Copy link
Contributor

@neomilium hi, can you fix the rubocop findings and rebase the branch over the master? This should give us green CI

@neomilium
Copy link
Author

@stejskalleos Done. Thanks.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

A difference is that they changed the load_file method to really be the safe_load_file method. Sadly on Psych bundled in Ruby 2.7, safe_load_file doesn't exist.

A way to avoid a specific version check is:

if File.exist?(ignored_file_path)
  # Ruby 3+
  if YAML.respond_to(:safe_load_file)
    YAML.safe_load_file(ignored_file_path, permitted_classes: [Symbol, Regexp])
  else
    YAML.load_file(ignored_file_path)
  end
else
  {}
end

Once we drop Ruby 2.7 support, you can drop the load_file call.

@neomilium
Copy link
Author

@ekohl Your suggestion is now applied. Thanks.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I'll admit I haven't tested this myself, but I'm approving CI to run.

Romuald Conty and others added 2 commits December 17, 2024 16:05
Updated using `bundle exec rubocop --auto-gen-config`
…bol in YAML file

Co-authored-by: Ewoud Kohl van Wijngaarden <[email protected]>
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.

4 participants