fix(region): avoid hostname has '-' suffix (#18485)

This commit is contained in:
屈轩
2023-10-30 17:02:20 +08:00
committed by GitHub
parent 1858a2983f
commit 413e60c32a
+3
View File
@@ -73,6 +73,9 @@ func (manager *SHostnameResourceBaseManager) ValidateHostname(name string, osTyp
input.Hostname = input.Hostname[:15]
}
}
for strings.HasSuffix(input.Hostname, "-") {
input.Hostname = strings.TrimSuffix(input.Hostname, "-")
}
if len(input.Hostname) < 2 {
return input, httperrors.NewInputParameterError("the hostname length must be greater than or equal to 2")
}