From 17bd778bd2b1f0d99f90f15bfc729e693be6b5c6 Mon Sep 17 00:00:00 2001 From: Marco Dinis Date: Wed, 4 Dec 2024 09:13:58 +0000 Subject: [PATCH] Hostname validation: document invalid hostnames (#49653) --- docs/pages/admin-guides/management/guides/ec2-tags.mdx | 2 +- docs/pages/admin-guides/management/guides/gcp-tags.mdx | 2 +- lib/utils/utils_test.go | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/pages/admin-guides/management/guides/ec2-tags.mdx b/docs/pages/admin-guides/management/guides/ec2-tags.mdx index 6c4c64cb381df..31d857d523724 100644 --- a/docs/pages/admin-guides/management/guides/ec2-tags.mdx +++ b/docs/pages/admin-guides/management/guides/ec2-tags.mdx @@ -10,7 +10,7 @@ this way will have the `aws/` prefix. When the Teleport process starts, it fetch the instance metadata service and adds them as labels. The process will update the tags every hour, so newly created or deleted tags will be reflected in the labels. -If the tag `TeleportHostname` (case-sensitive) is present, its value will override the node's hostname. +If the tag `TeleportHostname` is present, its value (must be lower case) will override the node's hostname. ```bash $ tsh ls diff --git a/docs/pages/admin-guides/management/guides/gcp-tags.mdx b/docs/pages/admin-guides/management/guides/gcp-tags.mdx index 163756435f433..36aedd0e0218c 100644 --- a/docs/pages/admin-guides/management/guides/gcp-tags.mdx +++ b/docs/pages/admin-guides/management/guides/gcp-tags.mdx @@ -17,7 +17,7 @@ When the Teleport process starts, it fetches all tags and labels from the GCP API and adds them as labels. The process will update the tags every hour, so newly created or deleted tags will be reflected in the labels. -If the GCP label `TeleportHostname` (case-sensitive) is present, its value will override the node's hostname. This +If the GCP label `TeleportHostname` is present, its value (must be lower case) will override the node's hostname. This does not apply to GCP tags. ```bash diff --git a/lib/utils/utils_test.go b/lib/utils/utils_test.go index e1625915bb204..075d99b3f9e98 100644 --- a/lib/utils/utils_test.go +++ b/lib/utils/utils_test.go @@ -234,6 +234,16 @@ func TestIsValidHostname(t *testing.T) { hostname: "some-host-1.example.com", assert: require.True, }, + { + name: "only lower case works", + hostname: "only-lower-case-works", + assert: require.True, + }, + { + name: "mixed upper case fails", + hostname: "mixed-UPPER-CASE-fails", + assert: require.False, + }, { name: "one component", hostname: "example",