Skip to content

Commit e932f9b

Browse files
committed
fix: ensuring resourcequota name doesn't break DNS-1123
Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>
1 parent 2465b66 commit e932f9b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

api/v1beta2/tenant_annotations.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"crypto/md5" //#nosec
88
"encoding/hex"
99
"fmt"
10+
"strings"
1011
)
1112

1213
const (
@@ -18,13 +19,13 @@ const (
1819
)
1920

2021
func createAnnotation(format string, resource fmt.Stringer) (string, error) {
21-
suffix := resource.String()
22+
resourceStr := strings.ReplaceAll(resource.String(), "/", "_")
2223

23-
hash := md5.Sum([]byte(resource.String())) //#nosec
24+
hash := md5.Sum([]byte(resourceStr)) //#nosec
2425

2526
hashed := hex.EncodeToString(hash[:])
2627
capsuleHashed := format + hashed
27-
capsuleAnnotation := format + suffix
28+
capsuleAnnotation := format + resourceStr
2829

2930
switch {
3031
case len(capsuleAnnotation) <= maxAnnotationLength:

0 commit comments

Comments
 (0)