Skip to content

Commit

Permalink
Merge pull request #540 from openshift-cherrypick-robot/cherry-pick-5…
Browse files Browse the repository at this point in the history
…39-to-release-4.4

[release-4.4] Bug 1832140: Assure storage bucket names in lowercase
  • Loading branch information
openshift-merge-robot committed Jun 3, 2020
2 parents f7914ab + 0b4ec97 commit 7081ab0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/storage/util/util.go
Expand Up @@ -159,6 +159,6 @@ func GenerateStorageName(listers *regopclient.Listers, additionalInfo ...string)
}
}

return name, nil
return strings.ToLower(name), nil

}
12 changes: 10 additions & 2 deletions pkg/storage/util/util_test.go
@@ -1,7 +1,6 @@
package util

import (
"fmt"
"regexp"
"strings"
"testing"
Expand Down Expand Up @@ -83,6 +82,11 @@ func TestGenerateStorageName(t *testing.T) {
infraName: "invalid-infra-name---",
additionalInfo: []string{"test1", "test2"},
},
{
name: "upper case on infra name",
infraName: "MY-INFRA",
additionalInfo: []string{"test1", "test2"},
},
} {
t.Run(tt.name, func(t *testing.T) {
l := regopclient.Listers{Infrastructures: MockInfrastructureLister{
Expand All @@ -94,7 +98,7 @@ func TestGenerateStorageName(t *testing.T) {
t.Errorf("%v", err)
}

rawPrefix := fmt.Sprintf("%s-%s", tt.infraName, defaults.ImageRegistryName)
rawPrefix := strings.ToLower(tt.infraName + "-" + defaults.ImageRegistryName)
wantedPrefix := replaceMultiDash.ReplaceAllString(rawPrefix, "-")
if len(wantedPrefix) > 62 {
wantedPrefix = wantedPrefix[0:62]
Expand All @@ -114,6 +118,10 @@ func TestGenerateStorageName(t *testing.T) {
if multiDash.MatchString(n) {
t.Errorf("name should not include a double dash: %s", n)
}

if n != strings.ToLower(n) {
t.Errorf("name should not contain upper case: %s", n)
}
})
}
}

0 comments on commit 7081ab0

Please sign in to comment.