From 9ae45d8ebb6e3381246217bc9a030a0ad887d422 Mon Sep 17 00:00:00 2001 From: Graham Esau Date: Thu, 9 Nov 2023 19:38:33 +0000 Subject: [PATCH] If elasticsearch persistence is enabled, also persist opensearch --- src/localstack_persist/config.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/localstack_persist/config.py b/src/localstack_persist/config.py index c7ca589..7a6bc3e 100644 --- a/src/localstack_persist/config.py +++ b/src/localstack_persist/config.py @@ -9,7 +9,7 @@ def normalise_service_name(n: str): - return ( + service_name = ( n.strip() .lower() .replace( @@ -21,6 +21,9 @@ def normalise_service_name(n: str): "", ) ) + if service_name == "elasticsearch": + return "es" + return service_name PERSISTED_SERVICES = {"default": True} @@ -42,6 +45,10 @@ def normalise_service_name(n: str): def is_persistence_enabled(service_name: str): - return PERSISTED_SERVICES.get( - normalise_service_name(service_name), PERSISTED_SERVICES["default"] - ) + service_name = normalise_service_name(service_name) + + # elasticsearch requires opensearch + if service_name == "opensearch" and is_persistence_enabled("es"): + return True + + return PERSISTED_SERVICES.get(service_name, PERSISTED_SERVICES["default"])