From c3ffb4bea1cd86a225b0c4bc6e9a9bfaa1091712 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Thu, 31 Oct 2024 18:42:58 +0200 Subject: [PATCH] v1-lib: fix $ escaping (#756) * fix $ symbol escaping * we dont need to escape it here, it is done globally --- library/{1.1.4 => 1.1.5}/__init__.py | 0 library/{1.1.4 => 1.1.5}/environment.py | 0 library/{1.1.4 => 1.1.5}/healthchecks.py | 0 library/{1.1.4 => 1.1.5}/mariadb.py | 0 library/{1.1.4 => 1.1.5}/metadata.py | 0 library/{1.1.4 => 1.1.5}/network.py | 0 library/{1.1.4 => 1.1.5}/permissions.py | 0 library/{1.1.4 => 1.1.5}/ports.py | 0 library/{1.1.4 => 1.1.5}/postgres.py | 0 library/{1.1.4 => 1.1.5}/redis.py | 0 library/{1.1.4 => 1.1.5}/resources.py | 0 library/{1.1.4 => 1.1.5}/security.py | 0 library/{1.1.4 => 1.1.5}/storage.py | 0 library/{1.1.4 => 1.1.5}/utils.py | 21 +++++---------------- library/hashes.yaml | 2 +- 15 files changed, 6 insertions(+), 17 deletions(-) rename library/{1.1.4 => 1.1.5}/__init__.py (100%) rename library/{1.1.4 => 1.1.5}/environment.py (100%) rename library/{1.1.4 => 1.1.5}/healthchecks.py (100%) rename library/{1.1.4 => 1.1.5}/mariadb.py (100%) rename library/{1.1.4 => 1.1.5}/metadata.py (100%) rename library/{1.1.4 => 1.1.5}/network.py (100%) rename library/{1.1.4 => 1.1.5}/permissions.py (100%) rename library/{1.1.4 => 1.1.5}/ports.py (100%) rename library/{1.1.4 => 1.1.5}/postgres.py (100%) rename library/{1.1.4 => 1.1.5}/redis.py (100%) rename library/{1.1.4 => 1.1.5}/resources.py (100%) rename library/{1.1.4 => 1.1.5}/security.py (100%) rename library/{1.1.4 => 1.1.5}/storage.py (100%) rename library/{1.1.4 => 1.1.5}/utils.py (77%) diff --git a/library/1.1.4/__init__.py b/library/1.1.5/__init__.py similarity index 100% rename from library/1.1.4/__init__.py rename to library/1.1.5/__init__.py diff --git a/library/1.1.4/environment.py b/library/1.1.5/environment.py similarity index 100% rename from library/1.1.4/environment.py rename to library/1.1.5/environment.py diff --git a/library/1.1.4/healthchecks.py b/library/1.1.5/healthchecks.py similarity index 100% rename from library/1.1.4/healthchecks.py rename to library/1.1.5/healthchecks.py diff --git a/library/1.1.4/mariadb.py b/library/1.1.5/mariadb.py similarity index 100% rename from library/1.1.4/mariadb.py rename to library/1.1.5/mariadb.py diff --git a/library/1.1.4/metadata.py b/library/1.1.5/metadata.py similarity index 100% rename from library/1.1.4/metadata.py rename to library/1.1.5/metadata.py diff --git a/library/1.1.4/network.py b/library/1.1.5/network.py similarity index 100% rename from library/1.1.4/network.py rename to library/1.1.5/network.py diff --git a/library/1.1.4/permissions.py b/library/1.1.5/permissions.py similarity index 100% rename from library/1.1.4/permissions.py rename to library/1.1.5/permissions.py diff --git a/library/1.1.4/ports.py b/library/1.1.5/ports.py similarity index 100% rename from library/1.1.4/ports.py rename to library/1.1.5/ports.py diff --git a/library/1.1.4/postgres.py b/library/1.1.5/postgres.py similarity index 100% rename from library/1.1.4/postgres.py rename to library/1.1.5/postgres.py diff --git a/library/1.1.4/redis.py b/library/1.1.5/redis.py similarity index 100% rename from library/1.1.4/redis.py rename to library/1.1.5/redis.py diff --git a/library/1.1.4/resources.py b/library/1.1.5/resources.py similarity index 100% rename from library/1.1.4/resources.py rename to library/1.1.5/resources.py diff --git a/library/1.1.4/security.py b/library/1.1.5/security.py similarity index 100% rename from library/1.1.4/security.py rename to library/1.1.5/security.py diff --git a/library/1.1.4/storage.py b/library/1.1.5/storage.py similarity index 100% rename from library/1.1.4/storage.py rename to library/1.1.5/storage.py diff --git a/library/1.1.4/utils.py b/library/1.1.5/utils.py similarity index 77% rename from library/1.1.4/utils.py rename to library/1.1.5/utils.py index 3d76208ff1..8a7c0815c6 100644 --- a/library/1.1.4/utils.py +++ b/library/1.1.5/utils.py @@ -27,12 +27,8 @@ def basic_auth_header(username, password): return f"Basic {security.basic_auth(username, password)}" -def bcrypt_hash(password, escape=True): - hashed = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8") - if escape: - # Docker compose will try to expand the value, so we need to escape it - return hashed.replace("$", "$$") - return hashed +def bcrypt_hash(password): + return bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8") def match_regex(value, regex): @@ -88,9 +84,7 @@ def get_image(images={}, name=""): if name not in images: throw_error(f"Expected [images.{name}] to be set") if not images[name].get("repository") or not images[name].get("tag"): - throw_error( - f"Expected [images.{name}.repository] and [images.{name}.tag] to be set" - ) + throw_error(f"Expected [images.{name}.repository] and [images.{name}.tag] to be set") return f"{images[name]['repository']}:{images[name]['tag']}" @@ -109,13 +103,8 @@ def copy_dict(dict): return dict.copy() -# Replaces all single dollar signs with double dollar signs -# Docker tries to expand shell variables, so we need to -# escape them in multiple places -# It will not replace dollar signs that are already escaped -def escape_dollar(text): - # https://regex101.com/r/tdbI7y/1 - return re.sub(r"(? str: + return text.replace("$", "$$") def auto_cast(value): diff --git a/library/hashes.yaml b/library/hashes.yaml index 006d1d119f..524ecfe187 100644 --- a/library/hashes.yaml +++ b/library/hashes.yaml @@ -1,3 +1,3 @@ 0.0.1: f074617a82a86d2a6cc78a4c8a4296fc9d168e456f12713e50c696557b302133 -1.1.4: 6e32ff5969906d9c3a10fea2b17fdd3197afb052d3432344da03188d8a907113 +1.1.5: 51332f2b032a0c473693458cd93daa96d56604241878e538c07cb85b8be66727 2.0.4: 0e79e3390d3ea73649ee2ac05a4af9ed944a02e95289b5c7e2eb047d475a4651