From f86d423e5cdb0f496400f9055598800916fe4f24 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Fri, 18 Oct 2024 12:46:56 +0200 Subject: [PATCH] Fixes #37940 - pass PGPASSWORD via environment variable --- hooks/pre/10-reset_data.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hooks/pre/10-reset_data.rb b/hooks/pre/10-reset_data.rb index 88a424aa..3e6e8c22 100644 --- a/hooks/pre/10-reset_data.rb +++ b/hooks/pre/10-reset_data.rb @@ -57,7 +57,11 @@ def reset_candlepin end def pg_command_base(config, command, args) - "PGPASSWORD='#{config[:password]}' #{command} -U #{config[:username]} -h #{config[:host]} -p #{config[:port]} #{args}" + "#{command} -U #{config[:username]} -h #{config[:host]} -p #{config[:port]} #{args}" +end + +def pg_env(config) + { 'PGPASSWORD' => config[:password] } end def pg_sql_statement(config, statement) @@ -67,7 +71,7 @@ def pg_sql_statement(config, statement) # WARNING: deletes all the data owned by the user. No warnings. No confirmations. def empty_database!(config) delete_statement = 'DROP OWNED BY CURRENT_USER CASCADE;' - execute!(pg_sql_statement(config, delete_statement), false, true) + execute!(pg_sql_statement(config, delete_statement), false, true, pg_env(config)) end def clear_pulpcore_content(content_dir)