support 'admin update' for hotfix versions (#15308)

hotfixed versions are rejected as invalid,
allow `mc admin update` from hotfix repos.
This commit is contained in:
Harshavardhana 2022-07-15 16:00:34 -07:00 committed by GitHub
parent 1cd6713e24
commit 5ac6d91525
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -76,7 +76,7 @@ func releaseTimeToReleaseTag(releaseTime time.Time) string {
// releaseTagToReleaseTime - reverse of `releaseTimeToReleaseTag()`
func releaseTagToReleaseTime(releaseTag string) (releaseTime time.Time, err error) {
fields := strings.Split(releaseTag, ".")
if len(fields) < 2 || len(fields) > 3 {
if len(fields) < 2 || len(fields) > 4 {
return releaseTime, fmt.Errorf("%s is not a valid release tag", releaseTag)
}
if fields[0] != "RELEASE" {

View File

@ -72,6 +72,14 @@ func TestReleaseTagToNFromTimeConversion(t *testing.T) {
time.Now().UTC(), "DEVELOPMENT.GOGET",
"DEVELOPMENT.GOGET is not a valid release tag",
},
{
time.Date(2017, time.August, 5, 0, 0, 53, 0, utcLoc),
"RELEASE.2017-08-05T00-00-53Z.hotfix", "",
},
{
time.Date(2017, time.August, 5, 0, 0, 53, 0, utcLoc),
"RELEASE.2017-08-05T00-00-53Z.hotfix.aaaa", "",
},
}
for i, testCase := range testCases {
if testCase.errStr != "" {