lib/gitlab_exporter/cli.rb in gitlab-exporter-13.0.0 vs lib/gitlab_exporter/cli.rb in gitlab-exporter-13.0.3

- old
+ new

@@ -1,7 +1,21 @@ require "yaml" +# TODO: Remove this once we're on Ruby 3 +# https://gitlab.com/gitlab-org/gitlab/-/issues/393651 +unless YAML.respond_to?(:safe_load_file) + module YAML # rubocop:disable Style/Documentation + # Temporary Ruby 2 back-compat workaround. + # + # This method only exists as of stdlib 3.0.0: + # https://ruby-doc.org/stdlib-3.0.0/libdoc/psych/rdoc/Psych.html + def self.safe_load_file(path, **options) + YAML.safe_load(File.read(path), **options) + end + end +end + module GitLab module Exporter # Stores runner classes in a single place # # The entry point is the module method "for" which takes the name of a runner. @@ -182,10 +196,10 @@ end def run validate! - config = Utils.deep_symbolize_hash_keys(YAML.load_file(@config_file)) + config = Utils.deep_symbolize_hash_keys(YAML.safe_load_file(@config_file, aliases: true)) WebExporter.setup(config) WebExporter.run! end