OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
remove deprecation warning when using nested hash in env var names
Christophe Bliard7d0d812b3578
diff --git a/config/constants/settings/definition.rb b/config/constants/settings/definition.rbindex b21da1d496f..67263ffe260 100644--- a/config/constants/settings/definition.rb+++ b/config/constants/settings/definition.rb@@ -253,24 +253,9 @@ module Settingsendreturn if merged_hash.empty?- Rails.logger.warn(env_hash_name_deprecation_message(definition))definition.override_value(merged_hash)end- def env_hash_name_deprecation_message(definition)- redacted_hash = {}- env_var_names = []- each_env_var_hash_override(definition) do |env_var_name, _env_var_value, env_var_hash_part|- env_var_names << env_var_name- redacted_value = extract_hash_from_env(env_var_name, 'xxx', env_var_hash_part)- redacted_hash.deep_merge!(redacted_value)- end-- "Using environment variables with special names to set nested hash values is deprecated. " \- "Please use #{env_name(definition)}='#{redacted_hash.to_json}' " \- "instead of #{env_var_names.to_sentence}"- end-def extract_hash_from_env(env_var_name, env_var_value, env_var_hash_part)value = extract_value_from_env(env_var_name, env_var_value)path_to_hash(*hash_path(env_var_hash_part), value)diff --git a/spec/constants/settings/definition_spec.rb b/spec/constants/settings/definition_spec.rbindex a1251e044f0..268be499c2b 100644--- a/spec/constants/settings/definition_spec.rb+++ b/spec/constants/settings/definition_spec.rb@@ -201,35 +201,6 @@ describe Settings::Definition do})end- it 'logs a deprecation warning when overriding configuration from ENV with nested hash in env var name' do- allow(Rails.logger).to receive(:warn)- stub_const(- 'ENV',- {- 'OPENPROJECT_REPOSITORY__CHECKOUT__DATA' => '{hg: {enabled: 0}}',- 'OPENPROJECT_REPOSITORY__CHECKOUT__DATA_CVS_ENABLED' => '0',- 'OPENPROJECT_REPOSITORY_CHECKOUT_DATA_GIT_ENABLED' => '1',- 'OPENPROJECT_REPOSITORY_CHECKOUT_DATA_GIT_MINIMUM__VERSION' => '42',- 'OPENPROJECT_REPOSITORY_CHECKOUT_DATA_SUBVERSION_ENABLED' => 'should be redacted'- }- )-- expect(value_for('repository_checkout_data')).to be_an_instance_of(Hash)- expect(Rails.logger)- .to have_received(:warn).once do |message|- expect(message).to include('Please use OPENPROJECT_REPOSITORY_CHECKOUT_DATA=\'{')- expect(message).to include('"cvs":{"enabled":"xxx"}')- expect(message).to include('"subversion":{"enabled":"xxx"}')- expect(message).to include('instead of')- expect(message).to include('OPENPROJECT_REPOSITORY__CHECKOUT__DATA_CVS_ENABLED')- expect(message).to include('OPENPROJECT_REPOSITORY_CHECKOUT_DATA_GIT_ENABLED')- expect(message).to include('OPENPROJECT_REPOSITORY_CHECKOUT_DATA_GIT_MINIMUM__VERSION')- expect(message).to include('OPENPROJECT_REPOSITORY_CHECKOUT_DATA_SUBVERSION_ENABLED')- expect(message).not_to include(ENV.fetch('OPENPROJECT_REPOSITORY_CHECKOUT_DATA_GIT_MINIMUM__VERSION'))- expect(message).not_to include('should be redacted')- end- end-it 'allows overriding settings hash fully from ENV with yaml data' dostub_const('ENV',