Merge pull request #33973 from ymqytw/fix_edit

Automatic merge from submit-queue

Improve edit experience

Improve edit experience a bit according [#26050(comment)](https://github.com/kubernetes/kubernetes/issues/26050#issuecomment-246089751)
> a) always go back to the editor
b) always retain what I hand-edited, even if that has to be in comments


@janetkuo
This commit is contained in:
Kubernetes Submit Queue 2016-10-14 06:41:36 -07:00 committed by GitHub
commit 1efdf72e23

View File

@ -39,6 +39,7 @@ import (
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/crlf"
"k8s.io/kubernetes/pkg/util/strategicpatch"
"k8s.io/kubernetes/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/util/yaml"
"github.com/golang/glog"
@ -216,7 +217,12 @@ func RunEdit(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args
}
err = schema.ValidateBytes(stripComments(edited))
if err != nil {
return preservedFile(err, file, errOut)
results = editResults{
file: file,
}
containsError = true
fmt.Fprintln(out, results.addError(errors.NewInvalid(api.Kind(""), "", field.ErrorList{field.Invalid(nil, "The edited file failed validation", fmt.Sprintf("%v", err))}), info))
continue
}
// Compare content without comments
@ -295,8 +301,9 @@ func RunEdit(f cmdutil.Factory, out, errOut io.Writer, cmd *cobra.Command, args
return nil
}
// loop again and edit the remaining items
infos = results.edit
if len(results.header.reasons) > 0 {
containsError = true
}
}
})
return err