From 16ff5e02122a0fd7b630223a2d7949886ed6b71e Mon Sep 17 00:00:00 2001 From: Sda79 Date: Mon, 19 Aug 2024 10:01:39 +0200 Subject: [PATCH] add Postgresql task (#27) Co-authored-by: Sylvain Daste --- sipssert/tasks/postgresql.py | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 sipssert/tasks/postgresql.py diff --git a/sipssert/tasks/postgresql.py b/sipssert/tasks/postgresql.py new file mode 100644 index 0000000..7727bf3 --- /dev/null +++ b/sipssert/tasks/postgresql.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +## +## This file is part of the SIPssert Testing Framework project +## Copyright (C) 2023 OpenSIPS Solutions +## +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see . +## + +from sipssert.task import Task + +class PostgresqlTask(Task): + + postgresql_default_env = {"POSTGRES_PASSWORD":"postgres"} + default_image = "postgres" + default_daemon = True + default_mount_point = "/docker-entrypoint-initdb.d" + + def get_task_env(self): + + env_dict = {} + + if "postgres_password" in self.config: + self.root_password = self.config["postgres_password"] + + if self.root_password: + env_dict["POSTGRES_PASSWORD"] = self.root_password + else: + env_dict = self.postgresql_default_env + + return env_dict + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4