Skip to content

Commit

Permalink
Add comment for shortenHostname function
Browse files Browse the repository at this point in the history
  • Loading branch information
Rizwana777 committed Feb 5, 2024
1 parent 4d903d6 commit 9e61565
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions controllers/argocd/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ func (r *ReconcileArgoCD) reconcileApplicationSetControllerWebhookRoute(cr *argo
return r.Client.Update(context.TODO(), route)
}

// The algorithm used by this function is:
// - 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
// - 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
Expand Down

0 comments on commit 9e61565

Please sign in to comment.