From e5501d7b98e4d057d3234f7b6633c4adec37c9cc Mon Sep 17 00:00:00 2001 From: Oliver Kurz Date: Mon, 20 Dec 2021 13:34:30 +0100 Subject: [PATCH] Move 'dsn' function to only place used' Tests did not cover the 'dsn' function anyway. --- lib/OpenQA/Schema.pm | 5 ----- lib/OpenQA/Shared/Plugin/Gru.pm | 9 +++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/OpenQA/Schema.pm b/lib/OpenQA/Schema.pm index 3cc3e8ad7e92..e5c6283dd85d 100644 --- a/lib/OpenQA/Schema.pm +++ b/lib/OpenQA/Schema.pm @@ -51,11 +51,6 @@ sub disconnect_db () { $SINGLETON = undef; } -sub dsn { - my $self = shift; - return $self->storage->connect_info->[0]->{dsn}; -} - sub deploy ($self, $force_overwrite = 0) { # lock config file to ensure only one thing will deploy/upgrade DB at once # we use a file in prjdir/db as the lock file as the install process and diff --git a/lib/OpenQA/Shared/Plugin/Gru.pm b/lib/OpenQA/Shared/Plugin/Gru.pm index ae2625e41e48..4fb0720e61b4 100644 --- a/lib/OpenQA/Shared/Plugin/Gru.pm +++ b/lib/OpenQA/Shared/Plugin/Gru.pm @@ -45,13 +45,14 @@ sub register ($self, $app, $config) { my $schema = $app->schema; my $conn = Mojo::Pg->new; - if (ref $schema->storage->connect_info->[0] eq 'HASH') { + my $connect_info = $schema->storage->connect_info->[0]; + if (ref $connect_info eq 'HASH') { $self->dsn($schema->dsn); - $conn->username($schema->storage->connect_info->[0]->{user}); - $conn->password($schema->storage->connect_info->[0]->{password}); + $conn->username($connect_info->{user}); + $conn->password($connect_info->{password}); } else { - $self->dsn($schema->storage->connect_info->[0]); + $self->dsn($connect_info); } $conn->dsn($self->dsn());