本文整理匯總了Golang中revision/aeip/apigee/net/spatel/k8s-influxdb/influxdb/Godeps/_workspace/src/k8s/io/kubernetes/pkg/util/validation/field.Path.Index方法的典型用法代碼示例。如果您正苦於以下問題:Golang Path.Index方法的具體用法?Golang Path.Index怎麽用?Golang Path.Index使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類revision/aeip/apigee/net/spatel/k8s-influxdb/influxdb/Godeps/_workspace/src/k8s/io/kubernetes/pkg/util/validation/field.
的用法示例。
在下文中一共展示了Path.Index方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: validateIngressRules
func validateIngressRules(IngressRules []extensions.IngressRule, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if len(IngressRules) == 0 {
return append(allErrs, field.Required(fldPath, ""))
}
for i, ih := range IngressRules {
if len(ih.Host) > 0 {
// TODO: Ports and ips are allowed in the host part of a url
// according to RFC 3986, consider allowing them.
if valid, errMsg := apivalidation.NameIsDNSSubdomain(ih.Host, false); !valid {
allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("host"), ih.Host, errMsg))
}
if isIP := (net.ParseIP(ih.Host) != nil); isIP {
allErrs = append(allErrs, field.Invalid(fldPath.Index(i).Child("host"), ih.Host, "must be a DNS name, not an IP address"))
}
}
allErrs = append(allErrs, validateIngressRuleValue(&ih.IngressRuleValue, fldPath.Index(0))...)
}
return allErrs
}