mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-06 03:33:26 +00:00
Add more tests around JSON/YAML decoding from the CLI
Switch the ignore stream errors behavior to print a Warningf on failure to parse, not v(2)
This commit is contained in:
@@ -337,7 +337,10 @@ type StreamVisitor struct {
|
||||
}
|
||||
|
||||
// NewStreamVisitor creates a visitor that will return resources that were encoded into the provided
|
||||
// stream. If ignoreErrors is set, unrecognized or invalid objects will be skipped and logged.
|
||||
// stream. If ignoreErrors is set, unrecognized or invalid objects will be skipped and logged. An
|
||||
// empty stream is treated as an error for now.
|
||||
// TODO: convert ignoreErrors into a func(data, error, count) bool that consumers can use to decide
|
||||
// what to do with ignored errors.
|
||||
func NewStreamVisitor(r io.Reader, mapper *Mapper, source string, ignoreErrors bool) Visitor {
|
||||
return &StreamVisitor{r, mapper, source, ignoreErrors}
|
||||
}
|
||||
@@ -356,7 +359,7 @@ func (v *StreamVisitor) Visit(fn VisitorFunc) error {
|
||||
info, err := v.InfoForData(ext.RawJSON, v.Source)
|
||||
if err != nil {
|
||||
if v.IgnoreErrors {
|
||||
glog.V(2).Infof("Unable to read item from stream %q: %v", err)
|
||||
glog.Warningf("Could not read an encoded object from %s: %v", v.Source, err)
|
||||
glog.V(4).Infof("Unreadable: %s", string(ext.RawJSON))
|
||||
continue
|
||||
}
|
||||
|
Reference in New Issue
Block a user