本文整理汇总了Golang中k8s/io/kubernetes/pkg/api/validation.ValidateServiceName函数的典型用法代码示例。如果您正苦于以下问题:Golang ValidateServiceName函数的具体用法?Golang ValidateServiceName怎么用?Golang ValidateServiceName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ValidateServiceName函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: validateEnforcedName
func validateEnforcedName(name string) error {
// up to 63 characters is nominally possible, however "-1" gets added on the
// end later for the deployment controller. Deduct 5 from 63 to at least
// cover us up to -9999.
if reasons := validation.ValidateServiceName(name, false); (len(reasons) != 0 || len(name) > 58) && !app.IsParameterizableValue(name) {
return fmt.Errorf("invalid name: %s. Must be an a lower case alphanumeric (a-z, and 0-9) string with a maximum length of 58 characters, where the first character is a letter (a-z), and the '-' character is allowed anywhere except the first or last character.", name)
}
return nil
}
开发者ID:xgwang-zte,项目名称:origin,代码行数:9,代码来源:newapp.go
示例2: makeValidServiceName
func makeValidServiceName(name string) (string, string) {
if len(validation.ValidateServiceName(name, false)) == 0 {
return name, ""
}
name = MakeSimpleName(name)
if len(name) == 0 {
return "", "service-"
}
return name, ""
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:10,代码来源:pipeline.go
示例3: validateIngressBackend
// validateIngressBackend tests if a given backend is valid.
func validateIngressBackend(backend *extensions.IngressBackend, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
// All backends must reference a single local service by name, and a single service port by name or number.
if len(backend.ServiceName) == 0 {
return append(allErrs, field.Required(fldPath.Child("serviceName"), ""))
} else {
for _, msg := range apivalidation.ValidateServiceName(backend.ServiceName, false) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("serviceName"), backend.ServiceName, msg))
}
}
allErrs = append(allErrs, apivalidation.ValidatePortNumOrName(backend.ServicePort, fldPath.Child("servicePort"))...)
return allErrs
}
开发者ID:maisem,项目名称:kubernetes,代码行数:15,代码来源:validation.go
示例4: makeValidServiceName
func makeValidServiceName(name string) (string, string) {
if ok, _ := validation.ValidateServiceName(name, false); ok {
return name, ""
}
name = strings.ToLower(name)
name = invalidServiceChars.ReplaceAllString(name, "")
name = strings.TrimFunc(name, func(r rune) bool { return r == '-' })
switch {
case len(name) == 0:
return "", "service-"
case len(name) > kuval.DNS952LabelMaxLength:
name = name[:kuval.DNS952LabelMaxLength]
}
return name, ""
}
开发者ID:rhamilto,项目名称:origin,代码行数:15,代码来源:pipeline.go
示例5: validateIngressBackend
// validateIngressBackend tests if a given backend is valid.
func validateIngressBackend(backend *extensions.IngressBackend, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
// All backends must reference a single local service by name, and a single service port by name or number.
if len(backend.ServiceName) == 0 {
return append(allErrs, field.Required(fldPath.Child("serviceName"), ""))
} else if ok, errMsg := apivalidation.ValidateServiceName(backend.ServiceName, false); !ok {
allErrs = append(allErrs, field.Invalid(fldPath.Child("serviceName"), backend.ServiceName, errMsg))
}
if backend.ServicePort.Type == intstr.String {
if !validation.IsDNS1123Label(backend.ServicePort.StrVal) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("servicePort"), backend.ServicePort.StrVal, apivalidation.DNS1123LabelErrorMsg))
}
if !validation.IsValidPortName(backend.ServicePort.StrVal) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("servicePort"), backend.ServicePort.StrVal, apivalidation.PortNameErrorMsg))
}
} else if !validation.IsValidPortNum(backend.ServicePort.IntValue()) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("servicePort"), backend.ServicePort, apivalidation.PortRangeErrorMsg))
}
return allErrs
}
开发者ID:MisaKondo,项目名称:kubernetes,代码行数:22,代码来源:validation.go
示例6: validateIngressBackend
// validateIngressBackend tests if a given backend is valid.
func validateIngressBackend(backend *extensions.IngressBackend) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
// All backends must reference a single local service by name, and a single service port by name or number.
if len(backend.ServiceName) == 0 {
return append(allErrs, errs.NewFieldRequired("serviceName"))
} else if ok, errMsg := apivalidation.ValidateServiceName(backend.ServiceName, false); !ok {
allErrs = append(allErrs, errs.NewFieldInvalid("serviceName", backend.ServiceName, errMsg))
}
if backend.ServicePort.Kind == util.IntstrString {
if !utilvalidation.IsDNS1123Label(backend.ServicePort.StrVal) {
allErrs = append(allErrs, errs.NewFieldInvalid("servicePort", backend.ServicePort.StrVal, apivalidation.DNS1123LabelErrorMsg))
}
if !utilvalidation.IsValidPortName(backend.ServicePort.StrVal) {
allErrs = append(allErrs, errs.NewFieldInvalid("servicePort", backend.ServicePort.StrVal, portNameErrorMsg))
}
} else if !utilvalidation.IsValidPortNum(backend.ServicePort.IntVal) {
allErrs = append(allErrs, errs.NewFieldInvalid("servicePort", backend.ServicePort, portRangeErrorMsg))
}
return allErrs
}
开发者ID:hloganathan,项目名称:origin,代码行数:22,代码来源:validation.go
示例7: validateEnforcedName
func (c *AppConfig) validateEnforcedName() error {
if ok, _ := validation.ValidateServiceName(c.Name, false); !ok {
return fmt.Errorf("invalid name: %s. Must be an a lower case alphanumeric (a-z, and 0-9) string with a maximum length of 24 characters, where the first character is a letter (a-z), and the '-' character is allowed anywhere except the first or last character.", c.Name)
}
return nil
}
开发者ID:nitintutlani,项目名称:origin,代码行数:6,代码来源:newapp.go
示例8: validateEnforcedName
func validateEnforcedName(name string) error {
if reasons := validation.ValidateServiceName(name, false); len(reasons) != 0 && !app.IsParameterizableValue(name) {
return fmt.Errorf("invalid name: %s. Must be an a lower case alphanumeric (a-z, and 0-9) string with a maximum length of 24 characters, where the first character is a letter (a-z), and the '-' character is allowed anywhere except the first or last character.", name)
}
return nil
}
开发者ID:nak3,项目名称:origin,代码行数:6,代码来源:newapp.go
注:本文中的k8s/io/kubernetes/pkg/api/validation.ValidateServiceName函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论