本文整理匯總了Golang中k8s/io/kubernetes/pkg/util/validation/field.Path.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang Path.String方法的具體用法?Golang Path.String怎麽用?Golang Path.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/util/validation/field.Path
的用法示例。
在下文中一共展示了Path.String方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: validatePSPCapsAgainstDrops
// validatePSPCapsAgainstDrops ensures an allowed cap is not listed in the required drops.
func validatePSPCapsAgainstDrops(requiredDrops []api.Capability, capsToCheck []api.Capability, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if requiredDrops == nil {
return allErrs
}
for _, cap := range capsToCheck {
if hasCap(cap, requiredDrops) {
allErrs = append(allErrs, field.Invalid(fldPath, cap,
fmt.Sprintf("capability is listed in %s and requiredDropCapabilities", fldPath.String())))
}
}
return allErrs
}
示例2: TestNilPath
// Ensures that `nil` can be passed to validation functions validating top-level objects
func TestNilPath(t *testing.T) {
var nilPath *field.Path = nil
if s := nilPath.String(); s != "" {
t.Errorf("Unexpected nil path: %q", s)
}
child := nilPath.Child("child")
if s := child.String(); s != "child" {
t.Errorf("Unexpected child path: %q", s)
}
key := nilPath.Key("key")
if s := key.String(); s != "[key]" {
t.Errorf("Unexpected key path: %q", s)
}
index := nilPath.Index(1)
if s := index.String(); s != "[1]" {
t.Errorf("Unexpected index path: %q", s)
}
}