Skip to content

Commit

Permalink
Rename the environment if it's duplicated by secrets compose-x#707
Browse files Browse the repository at this point in the history
  • Loading branch information
thorfi committed Nov 14, 2023
1 parent ae56a14 commit 5c1c204
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions ecs_composex/ecs/ecs_family/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,16 +528,17 @@ def sort_env_vars_alphabetically(self):
secret_names = frozenset()
environment = getattr(service.container_definition, "Environment")
if environment:
original = [
_env for _env in environment if isinstance(_env, Environment)
]
remove_secrets = [
_env for _env in original if _env.Name not in secret_names
]
sorted_env = sorted(remove_secrets, key=lambda x: x.Name)
original = []
extras = []
for _env in environment:
if not isinstance(_env, Environment):
sorted_env.append(_env)
if isinstance(_env, Environment):
while _env.Name in secret_names:
_env.Name += "_IN_SECRETS"
original.append(_env)
else:
extras.append(_env)
sorted_env = sorted(original, key=lambda x: x.Name)
sorted_env.extend(extras)
setattr(service.container_definition, "Environment", sorted_env)

def set_services_to_services_dependencies(self):
Expand Down

0 comments on commit 5c1c204

Please sign in to comment.