Optimized logic for central databases

This commit is contained in:
Kevin Veen-Birkenbach 2024-01-11 20:51:55 +01:00
parent 7f6f5f6dc8
commit b7dcb17fd5
1 changed files with 3 additions and 4 deletions

View File

@ -71,11 +71,10 @@ def get_instance(container):
# This line uses regular expressions to split the 'container' string.
# 're.split' is a method that divides a string into a list, based on the occurrences of a pattern.
instance_name_elements = re.split("(_|-)(database|db|postgres)", container)
if instance_name_elements[0] == 'central':
instance_name = f"{instance_name_elements[0]}-{instance_name_elements[1]}"
if container in ['central-mariadb', 'central-postgres']:
instance_name = container
else:
instance_name = instance_name_elements[0]
instance_name = re.split("(_|-)(database|db|postgres)", container)[0]
# The pattern "(_|-)(database|db|postgres)" is explained as follows:
# - "(_|-)": Matches an underscore '_' or a hyphen '-'.