Convert Secret registry to use update/create strategy, allow filtering by Type

This commit is contained in:
Jordan Liggitt
2015-04-27 23:50:56 -04:00
parent c2a78483b4
commit ac67fff1cf
14 changed files with 391 additions and 524 deletions

View File

@@ -1242,6 +1242,29 @@ func ValidateSecret(secret *api.Secret) errs.ValidationErrorList {
allErrs = append(allErrs, errs.NewFieldForbidden("data", "Maximum secret size exceeded"))
}
switch secret.Type {
case api.SecretTypeOpaque, "":
// no-op
default:
// no-op
}
return allErrs
}
// ValidateSecretUpdate tests if required fields in the Secret are set.
func ValidateSecretUpdate(oldSecret, newSecret *api.Secret) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldSecret.ObjectMeta, &newSecret.ObjectMeta).Prefix("metadata")...)
if len(newSecret.Type) == 0 {
newSecret.Type = oldSecret.Type
}
if newSecret.Type != oldSecret.Type {
allErrs = append(allErrs, errs.NewFieldInvalid("type", newSecret.Type, "field is immutable"))
}
allErrs = append(allErrs, ValidateSecret(newSecret)...)
return allErrs
}