Removing instead of deprecating Namespace attr

- Per discussion, there is no reason to deal
with the complexity of backwards compatibility
with the Namespace attribute on the Restore
domain.

- Also noticed there was an error on the
validation of the BackupController where
the message would actually just be the index
of the error and not the contents of the message
itself.

Signed-off-by: Justin Nauman <justin.r.nauman@gmail.com>
This commit is contained in:
Justin Nauman
2017-09-05 17:06:15 -05:00
parent b50a046370
commit 2457d8f116
5 changed files with 11 additions and 33 deletions

View File

@@ -220,22 +220,15 @@ func (controller *restoreController) processRestore(key string) error {
return err
}
if len(restore.Spec.IncludedNamespaces) == 0 {
restore.Spec.IncludedNamespaces = []string{"*"}
}
// validation
if restore.Status.ValidationErrors = controller.getValidationErrors(restore); len(restore.Status.ValidationErrors) > 0 {
restore.Status.Phase = api.RestorePhaseFailedValidation
} else {
restore.Status.Phase = api.RestorePhaseInProgress
if len(restore.Spec.Namespaces) != 0 {
glog.V(4).Info("the restore.Spec.Namespaces field has been deprecated. Please use the IncludedNamespaces and ExcludedNamespaces feature instead")
restore.Spec.IncludedNamespaces = restore.Spec.Namespaces
restore.Spec.Namespaces = nil
}
if len(restore.Spec.IncludedNamespaces) == 0 {
restore.Spec.IncludedNamespaces = []string{"*"}
}
}
// update status
@@ -286,11 +279,7 @@ func (controller *restoreController) getValidationErrors(itm *api.Restore) []str
validationErrors = append(validationErrors, "BackupName must be non-empty and correspond to the name of a backup in object storage.")
}
if len(itm.Spec.Namespaces) > 0 && len(itm.Spec.IncludedNamespaces) > 0 {
validationErrors = append(validationErrors, "Namespaces and IncludedNamespaces can not both be defined on the backup spec.")
}
for err := range collections.ValidateIncludesExcludes(itm.Spec.IncludedNamespaces, itm.Spec.ExcludedNamespaces) {
for _, err := range collections.ValidateIncludesExcludes(itm.Spec.IncludedNamespaces, itm.Spec.ExcludedNamespaces) {
validationErrors = append(validationErrors, fmt.Sprintf("Invalid included/excluded namespace lists: %v", err))
}