From ebc39d92a7e005b7c636f152b4cb15328fe4bdb3 Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Wed, 10 Jan 2024 10:23:03 +0000 Subject: [PATCH 1/3] Allow 8 chars for user subdomains --- lib/pull_preview/instance.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pull_preview/instance.rb b/lib/pull_preview/instance.rb index d0f2d04..f9e315b 100644 --- a/lib/pull_preview/instance.rb +++ b/lib/pull_preview/instance.rb @@ -78,8 +78,9 @@ def public_ip end def public_dns + reserved_space_for_user_subdomain = 8 # https://community.letsencrypt.org/t/a-certificate-for-a-63-character-domain/78870/4 - remaining_chars_for_subdomain = 62 - dns.size - public_ip.size - "ip".size - ("." * 3).size + remaining_chars_for_subdomain = 62 - reserved_space_for_user_subdomain - dns.size - public_ip.size - "ip".size - ("." * 3).size [ [subdomain[0..remaining_chars_for_subdomain], "ip", public_ip.gsub(".", "-")].join("-"), dns From 0516d98da145d49639e6704bc2ce954884bea92b Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Wed, 10 Jan 2024 10:35:47 +0000 Subject: [PATCH 2/3] Take last branch component in instance subdomain. e.g. feature/some-new-code would use 'some-new-code' in the subdomain instead of 'feature-some-n' --- lib/pull_preview/github_sync.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pull_preview/github_sync.rb b/lib/pull_preview/github_sync.rb index d70c294..b0c81ad 100644 --- a/lib/pull_preview/github_sync.rb +++ b/lib/pull_preview/github_sync.rb @@ -441,7 +441,7 @@ def instance_subdomain components = [] components.push(deployment_variant) if deployment_variant components.push(*["pr", pr_number]) if pr_number - components.push(branch) + components.push(branch.split("/").last) Instance.normalize_name(components.join("-")) end end From 9e75f744051bea09c5324d2054dbf5791ed45e56 Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Wed, 10 Jan 2024 10:42:04 +0000 Subject: [PATCH 3/3] Fix double dash --- lib/pull_preview/instance.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pull_preview/instance.rb b/lib/pull_preview/instance.rb index f9e315b..d46a575 100644 --- a/lib/pull_preview/instance.rb +++ b/lib/pull_preview/instance.rb @@ -82,7 +82,7 @@ def public_dns # https://community.letsencrypt.org/t/a-certificate-for-a-63-character-domain/78870/4 remaining_chars_for_subdomain = 62 - reserved_space_for_user_subdomain - dns.size - public_ip.size - "ip".size - ("." * 3).size [ - [subdomain[0..remaining_chars_for_subdomain], "ip", public_ip.gsub(".", "-")].join("-"), + [subdomain[0..remaining_chars_for_subdomain], "ip", public_ip.gsub(".", "-")].join("-").squeeze("-"), dns ].join(".") end