Update go dependencies for kubernetes 1.16.0

This commit is contained in:
Manuel Alejandro de Brito Fontes 2019-09-19 11:01:00 -03:00
parent 280920980d
commit d7b530cb0a
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
510 changed files with 107206 additions and 52551 deletions

View file

@ -130,6 +130,10 @@ func (o *ResourceBuilderFlags) ToBuilder(restClientGetter RESTClientGetter, reso
builder := resource.NewBuilder(restClientGetter).
NamespaceParam(namespace).DefaultNamespace()
if o.AllNamespaces != nil {
builder.AllNamespaces(*o.AllNamespaces)
}
if o.Scheme != nil {
builder.WithScheme(o.Scheme, o.Scheme.PrioritizedVersionsAllGroups()...)
} else {

View file

@ -22,7 +22,9 @@ import (
"fmt"
"io"
"reflect"
"sync/atomic"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/yaml"
@ -41,6 +43,20 @@ func (p *JSONPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
}
switch obj := obj.(type) {
case *metav1.WatchEvent:
if InternalObjectPreventer.IsForbidden(reflect.Indirect(reflect.ValueOf(obj.Object.Object)).Type().PkgPath()) {
return fmt.Errorf(InternalObjectPrinterErr)
}
data, err := json.Marshal(obj)
if err != nil {
return err
}
_, err = w.Write(data)
if err != nil {
return err
}
_, err = w.Write([]byte{'\n'})
return err
case *runtime.Unknown:
var buf bytes.Buffer
err := json.Indent(&buf, obj.Raw, "", " ")
@ -68,7 +84,10 @@ func (p *JSONPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
// YAMLPrinter is an implementation of ResourcePrinter which outputs an object as YAML.
// The input object is assumed to be in the internal version of an API and is converted
// to the given version first.
type YAMLPrinter struct{}
// If PrintObj() is called multiple times, objects are separated with a '---' separator.
type YAMLPrinter struct {
printCount int64
}
// PrintObj prints the data as YAML.
func (p *YAMLPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
@ -79,7 +98,28 @@ func (p *YAMLPrinter) PrintObj(obj runtime.Object, w io.Writer) error {
return fmt.Errorf(InternalObjectPrinterErr)
}
count := atomic.AddInt64(&p.printCount, 1)
if count > 1 {
if _, err := w.Write([]byte("---\n")); err != nil {
return err
}
}
switch obj := obj.(type) {
case *metav1.WatchEvent:
if InternalObjectPreventer.IsForbidden(reflect.Indirect(reflect.ValueOf(obj.Object.Object)).Type().PkgPath()) {
return fmt.Errorf(InternalObjectPrinterErr)
}
data, err := json.Marshal(obj)
if err != nil {
return err
}
data, err = yaml.JSONToYAML(data)
if err != nil {
return err
}
_, err = w.Write(data)
return err
case *runtime.Unknown:
data, err := yaml.JSONToYAML(obj.Raw)
if err != nil {

View file

@ -23,6 +23,7 @@ import (
"strings"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
@ -42,6 +43,11 @@ type NamePrinter struct {
// PrintObj is an implementation of ResourcePrinter.PrintObj which decodes the object
// and print "resource/name" pair. If the object is a List, print all items in it.
func (p *NamePrinter) PrintObj(obj runtime.Object, w io.Writer) error {
switch castObj := obj.(type) {
case *metav1.WatchEvent:
obj = castObj.Object.Object
}
// we use reflect.Indirect here in order to obtain the actual value from a pointer.
// using reflect.Indirect indiscriminately is valid here, as all runtime.Objects are supposed to be pointers.
// we need an actual value in order to retrieve the package path for an object.

View file

@ -44,8 +44,8 @@ import (
)
const (
constSTDINstr string = "STDIN"
stopValidateMessage = "if you choose to ignore these errors, turn validation off with --validate=false"
constSTDINstr = "STDIN"
stopValidateMessage = "if you choose to ignore these errors, turn validation off with --validate=false"
)
// Watchable describes a resource that can be watched for changes that occur on the server,
@ -372,10 +372,9 @@ func (v ContinueOnErrorVisitor) Visit(fn VisitorFunc) error {
// FlattenListVisitor flattens any objects that runtime.ExtractList recognizes as a list
// - has an "Items" public field that is a slice of runtime.Objects or objects satisfying
// that interface - into multiple Infos. An error on any sub item (for instance, if a List
// contains an object that does not have a registered client or resource) will terminate
// the visit.
// TODO: allow errors to be aggregated?
// that interface - into multiple Infos. Returns nil in the case of no errors.
// When an error is hit on sub items (for instance, if a List contains an object that does
// not have a registered client or resource), returns an aggregate error.
type FlattenListVisitor struct {
visitor Visitor
typer runtime.ObjectTyper
@ -425,20 +424,22 @@ func (v FlattenListVisitor) Visit(fn VisitorFunc) error {
if info.Mapping != nil && !info.Mapping.GroupVersionKind.Empty() {
preferredGVKs = append(preferredGVKs, info.Mapping.GroupVersionKind)
}
errs := []error{}
for i := range items {
item, err := v.mapper.infoForObject(items[i], v.typer, preferredGVKs)
if err != nil {
return err
errs = append(errs, err)
continue
}
if len(info.ResourceVersion) != 0 {
item.ResourceVersion = info.ResourceVersion
}
if err := fn(item, nil); err != nil {
return err
errs = append(errs, err)
}
}
return nil
return utilerrors.NewAggregate(errs)
})
}