Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Marigold committed Dec 18, 2024
1 parent 0092f3b commit 43e6e43
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion etl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,30 @@ def _normalise_branch(branch_name):
return re.sub(r"[\/\._]", "-", branch_name)


# NOTE: If you edit this function, make sure to update `get_container_name` in ops repo as well
def get_container_name(branch_name):
normalized_branch = _normalise_branch(branch_name)

# Strip staging-site- prefix to add it back later
normalized_branch = normalized_branch.replace("staging-site-", "")

# Ensure the container name is less than 63 characters
container_name = f"staging-site-{normalized_branch[:50]}"
# however, we truncate it to 28 characters to be consistent with Cloudflare's
# 28 character limit (see https://community.cloudflare.com/t/algorithm-to-generate-a-preview-dns-subdomain-from-a-branch-name/477633)
# TODO: these ifs were added to be backward compatible with existing branches that are longer than 28 characters
# remove them once they get merged
if normalized_branch in (
"variable-selector-catalog-path",
"grapher-page-dynamic-thumbnail",
"data-fertility-rate-effective",
"add-reset-metadata-origin-option",
"data-battery-cell-prices-private",
):
limit = 50
else:
limit = 28

container_name = f"staging-site-{normalized_branch[:limit]}"
# Remove trailing hyphens
return container_name.rstrip("-")

Expand Down

0 comments on commit 43e6e43

Please sign in to comment.