]> git.proxmox.com Git - pmg-api.git/commitdiff
utils: do not hardcode postgres version
authorStoiko Ivanov <s.ivanov@proxmox.com>
Mon, 31 May 2021 13:53:05 +0000 (13:53 +0000)
committerStoiko Ivanov <s.ivanov@proxmox.com>
Fri, 11 Jun 2021 14:53:45 +0000 (14:53 +0000)
PMG::Utils::lookup_real_service_name is only called
for translating the service names provided as arguments
to PMG::API2::Nodes::syslog (for fetching the journal
for specific units). Instead of hardcoding the
version getting it with a call to `psql` seems justified.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
src/PMG/Utils.pm

index 43a866dd4c17a148ef9ca58be49039f116ebdd80..318c7b3cce1f6f949b280194de321d3c2296ffdb 100644 (file)
@@ -710,12 +710,16 @@ sub find_local_network_for_ip {
 
 my $service_aliases = {
     'postfix' =>  'postfix@-',
-    'postgres' => 'postgresql@11-main',
 };
 
 sub lookup_real_service_name {
     my $alias = shift;
 
+    if ($alias eq 'postgres') {
+       my $pg_ver = get_pg_server_version();
+       return "postgresl\@${pg_ver}-main";
+    }
+
     return $service_aliases->{$alias} // $alias;
 }