Merge pull request #11781 from brendandburns/schema-api

RFC: Add initial plugin schema types.
This commit is contained in:
Brendan Burns
2015-08-14 09:44:12 -07:00
10 changed files with 615 additions and 1 deletions

View File

@@ -1804,3 +1804,26 @@ func ValidateSecurityContext(sc *api.SecurityContext) errs.ValidationErrorList {
}
return allErrs
}
func ValidateThirdPartyResource(obj *api.ThirdPartyResource) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
if len(obj.Name) == 0 {
allErrs = append(allErrs, errs.NewFieldInvalid("name", obj.Name, "name must be non-empty"))
}
versions := util.StringSet{}
for ix := range obj.Versions {
version := &obj.Versions[ix]
if len(version.Name) == 0 {
allErrs = append(allErrs, errs.NewFieldInvalid("name", version, "name can not be empty"))
}
if versions.Has(version.Name) {
allErrs = append(allErrs, errs.NewFieldDuplicate("version", version))
}
versions.Insert(version.Name)
}
return allErrs
}
func ValidateSchemaUpdate(oldResource, newResource *api.ThirdPartyResource) errs.ValidationErrorList {
return errs.ValidationErrorList{fmt.Errorf("Schema update is not supported.")}
}