Skip to content

Commit

Permalink
Add check to return hostname if it is in size limit
Browse files Browse the repository at this point in the history
Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com>
  • Loading branch information
Rizwana777 committed Feb 14, 2024
1 parent 117a866 commit b0cf666
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion controllers/argocd/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,18 @@ func (r *ReconcileArgoCD) reconcileApplicationSetControllerWebhookRoute(cr *argo
// - If the FIRST label ("console-openshift-console" in the above case) is longer than 63 characters, shorten (truncate the end) it to 63.
// - If any other label is longer than 63 characters, return an error
// - After all the labels are 63 characters or less, check the length of the overall hostname:
// - If the overall hostname is > 255, then shorten the FIRST label until the host name is < 255
// - If the overall hostname is > 253, then shorten the FIRST label until the host name is < 253
// - After the FIRST label has been shortened, if it is < 20, then return an error (this is a sanity test to ensure the label is likely to be unique)
func shortenHostname(hostname string) (string, error) {
if hostname == "" {
return "", nil
}

// Return the hostname as it is if hostname is already within the size limit
if len(hostname) <= maxHostnameLength {
return hostname, nil
}

// Split the hostname into labels
labels := strings.Split(hostname, ".")

Expand Down

0 comments on commit b0cf666

Please sign in to comment.