Skip to content

Commit

Permalink
fix: ensuring resourcequota name doesn't break DNS-1123
Browse files Browse the repository at this point in the history
Signed-off-by: Dario Tranchitella <[email protected]>
  • Loading branch information
prometherion committed Nov 21, 2023
1 parent 2465b66 commit 34977aa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/v1beta2/tenant_annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"crypto/md5" //#nosec
"encoding/hex"
"fmt"
"strings"
)

const (
Expand All @@ -18,13 +19,13 @@ const (
)

func createAnnotation(format string, resource fmt.Stringer) (string, error) {
suffix := resource.String()
resourceStr := strings.ReplaceAll(resource.String(), "/", "_")

hash := md5.Sum([]byte(resource.String())) //#nosec
hash := md5.Sum([]byte(resourceStr)) //#nosec

hashed := hex.EncodeToString(hash[:])
capsuleHashed := format + hashed
capsuleAnnotation := format + suffix
capsuleAnnotation := format + resourceStr

switch {
case len(capsuleAnnotation) <= maxAnnotationLength:
Expand Down

0 comments on commit 34977aa

Please sign in to comment.