VOL-1917 move to go mod
Change-Id: Ia8de8bd8a4f4d908cc1fa745f6f4ec949629017b
diff --git a/vendor/k8s.io/apimachinery/pkg/api/errors/OWNERS b/vendor/k8s.io/apimachinery/pkg/api/errors/OWNERS
old mode 100755
new mode 100644
index dc6a4c7..6343403
--- a/vendor/k8s.io/apimachinery/pkg/api/errors/OWNERS
+++ b/vendor/k8s.io/apimachinery/pkg/api/errors/OWNERS
@@ -1,3 +1,5 @@
+# See the OWNERS docs at https://go.k8s.io/owners
+
reviewers:
- thockin
- lavalamp
diff --git a/vendor/k8s.io/apimachinery/pkg/api/errors/errors.go b/vendor/k8s.io/apimachinery/pkg/api/errors/errors.go
index 77c91bb..f4201eb 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/errors/errors.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/errors/errors.go
@@ -20,6 +20,7 @@
"encoding/json"
"fmt"
"net/http"
+ "reflect"
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -82,7 +83,20 @@
func FromObject(obj runtime.Object) error {
switch t := obj.(type) {
case *metav1.Status:
- return &StatusError{*t}
+ return &StatusError{ErrStatus: *t}
+ case runtime.Unstructured:
+ var status metav1.Status
+ obj := t.UnstructuredContent()
+ if !reflect.DeepEqual(obj["kind"], "Status") {
+ break
+ }
+ if err := runtime.DefaultUnstructuredConverter.FromUnstructured(t.UnstructuredContent(), &status); err != nil {
+ return err
+ }
+ if status.APIVersion != "v1" && status.APIVersion != "meta.k8s.io/v1" {
+ break
+ }
+ return &StatusError{ErrStatus: status}
}
return &UnexpectedObjectError{obj}
}
@@ -170,6 +184,20 @@
}}
}
+// NewApplyConflict returns an error including details on the requests apply conflicts
+func NewApplyConflict(causes []metav1.StatusCause, message string) *StatusError {
+ return &StatusError{ErrStatus: metav1.Status{
+ Status: metav1.StatusFailure,
+ Code: http.StatusConflict,
+ Reason: metav1.StatusReasonConflict,
+ Details: &metav1.StatusDetails{
+ // TODO: Get obj details here?
+ Causes: causes,
+ },
+ Message: message,
+ }}
+}
+
// NewGone returns an error indicating the item no longer available at the server and no forwarding address is known.
func NewGone(message string) *StatusError {
return &StatusError{metav1.Status{
@@ -366,7 +394,11 @@
case http.StatusNotAcceptable:
reason = metav1.StatusReasonNotAcceptable
// the server message has details about what types are acceptable
- message = serverMessage
+ if len(serverMessage) == 0 || serverMessage == "unknown" {
+ message = "the server was unable to respond with a content type that the client supports"
+ } else {
+ message = serverMessage
+ }
case http.StatusUnsupportedMediaType:
reason = metav1.StatusReasonUnsupportedMediaType
// the server message has details about what types are acceptable
@@ -589,3 +621,46 @@
}
return metav1.StatusReasonUnknown
}
+
+// ErrorReporter converts generic errors into runtime.Object errors without
+// requiring the caller to take a dependency on meta/v1 (where Status lives).
+// This prevents circular dependencies in core watch code.
+type ErrorReporter struct {
+ code int
+ verb string
+ reason string
+}
+
+// NewClientErrorReporter will respond with valid v1.Status objects that report
+// unexpected server responses. Primarily used by watch to report errors when
+// we attempt to decode a response from the server and it is not in the form
+// we expect. Because watch is a dependency of the core api, we can't return
+// meta/v1.Status in that package and so much inject this interface to convert a
+// generic error as appropriate. The reason is passed as a unique status cause
+// on the returned status, otherwise the generic "ClientError" is returned.
+func NewClientErrorReporter(code int, verb string, reason string) *ErrorReporter {
+ return &ErrorReporter{
+ code: code,
+ verb: verb,
+ reason: reason,
+ }
+}
+
+// AsObject returns a valid error runtime.Object (a v1.Status) for the given
+// error, using the code and verb of the reporter type. The error is set to
+// indicate that this was an unexpected server response.
+func (r *ErrorReporter) AsObject(err error) runtime.Object {
+ status := NewGenericServerResponse(r.code, r.verb, schema.GroupResource{}, "", err.Error(), 0, true)
+ if status.ErrStatus.Details == nil {
+ status.ErrStatus.Details = &metav1.StatusDetails{}
+ }
+ reason := r.reason
+ if len(reason) == 0 {
+ reason = "ClientError"
+ }
+ status.ErrStatus.Details.Causes = append(status.ErrStatus.Details.Causes, metav1.StatusCause{
+ Type: metav1.CauseType(reason),
+ Message: err.Error(),
+ })
+ return &status.ErrStatus
+}
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/OWNERS b/vendor/k8s.io/apimachinery/pkg/api/meta/OWNERS
old mode 100755
new mode 100644
index 5f729ff..dd2c0cb
--- a/vendor/k8s.io/apimachinery/pkg/api/meta/OWNERS
+++ b/vendor/k8s.io/apimachinery/pkg/api/meta/OWNERS
@@ -1,3 +1,5 @@
+# See the OWNERS docs at https://go.k8s.io/owners
+
reviewers:
- thockin
- smarterclayton
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/help.go b/vendor/k8s.io/apimachinery/pkg/api/meta/help.go
index c70b3d2..50468b5 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/meta/help.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/meta/help.go
@@ -17,30 +17,76 @@
package meta
import (
+ "errors"
"fmt"
"reflect"
+ "sync"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime"
)
-// IsListType returns true if the provided Object has a slice called Items
+var (
+ // isListCache maintains a cache of types that are checked for lists
+ // which is used by IsListType.
+ // TODO: remove and replace with an interface check
+ isListCache = struct {
+ lock sync.RWMutex
+ byType map[reflect.Type]bool
+ }{
+ byType: make(map[reflect.Type]bool, 1024),
+ }
+)
+
+// IsListType returns true if the provided Object has a slice called Items.
+// TODO: Replace the code in this check with an interface comparison by
+// creating and enforcing that lists implement a list accessor.
func IsListType(obj runtime.Object) bool {
- // if we're a runtime.Unstructured, check whether this is a list.
- // TODO: refactor GetItemsPtr to use an interface that returns []runtime.Object
- if unstructured, ok := obj.(runtime.Unstructured); ok {
- return unstructured.IsList()
+ switch t := obj.(type) {
+ case runtime.Unstructured:
+ return t.IsList()
+ }
+ t := reflect.TypeOf(obj)
+
+ isListCache.lock.RLock()
+ ok, exists := isListCache.byType[t]
+ isListCache.lock.RUnlock()
+
+ if !exists {
+ _, err := getItemsPtr(obj)
+ ok = err == nil
+
+ // cache only the first 1024 types
+ isListCache.lock.Lock()
+ if len(isListCache.byType) < 1024 {
+ isListCache.byType[t] = ok
+ }
+ isListCache.lock.Unlock()
}
- _, err := GetItemsPtr(obj)
- return err == nil
+ return ok
}
+var (
+ errExpectFieldItems = errors.New("no Items field in this object")
+ errExpectSliceItems = errors.New("Items field must be a slice of objects")
+)
+
// GetItemsPtr returns a pointer to the list object's Items member.
// If 'list' doesn't have an Items member, it's not really a list type
// and an error will be returned.
// This function will either return a pointer to a slice, or an error, but not both.
+// TODO: this will be replaced with an interface in the future
func GetItemsPtr(list runtime.Object) (interface{}, error) {
+ obj, err := getItemsPtr(list)
+ if err != nil {
+ return nil, fmt.Errorf("%T is not a list: %v", list, err)
+ }
+ return obj, nil
+}
+
+// getItemsPtr returns a pointer to the list object's Items member or an error.
+func getItemsPtr(list runtime.Object) (interface{}, error) {
v, err := conversion.EnforcePtr(list)
if err != nil {
return nil, err
@@ -48,19 +94,19 @@
items := v.FieldByName("Items")
if !items.IsValid() {
- return nil, fmt.Errorf("no Items field in %#v", list)
+ return nil, errExpectFieldItems
}
switch items.Kind() {
case reflect.Interface, reflect.Ptr:
target := reflect.TypeOf(items.Interface()).Elem()
if target.Kind() != reflect.Slice {
- return nil, fmt.Errorf("items: Expected slice, got %s", target.Kind())
+ return nil, errExpectSliceItems
}
return items.Interface(), nil
case reflect.Slice:
return items.Addr().Interface(), nil
default:
- return nil, fmt.Errorf("items: Expected slice, got %s", items.Kind())
+ return nil, errExpectSliceItems
}
}
@@ -158,6 +204,19 @@
// objectSliceType is the type of a slice of Objects
var objectSliceType = reflect.TypeOf([]runtime.Object{})
+// LenList returns the length of this list or 0 if it is not a list.
+func LenList(list runtime.Object) int {
+ itemsPtr, err := GetItemsPtr(list)
+ if err != nil {
+ return 0
+ }
+ items, err := conversion.EnforcePtr(itemsPtr)
+ if err != nil {
+ return 0
+ }
+ return items.Len()
+}
+
// SetList sets the given list object's Items member have the elements given in
// objects.
// Returns an error if list is not a List type (does not have an Items member),
diff --git a/vendor/k8s.io/apimachinery/pkg/api/meta/meta.go b/vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
index 1c2a83c..086bce0 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/meta/meta.go
@@ -20,14 +20,12 @@
"fmt"
"reflect"
- "github.com/golang/glog"
-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
+ "k8s.io/klog"
)
// errNotList is returned when an object implements the Object style interfaces but not the List style
@@ -115,12 +113,12 @@
// AsPartialObjectMetadata takes the metav1 interface and returns a partial object.
// TODO: consider making this solely a conversion action.
-func AsPartialObjectMetadata(m metav1.Object) *metav1beta1.PartialObjectMetadata {
+func AsPartialObjectMetadata(m metav1.Object) *metav1.PartialObjectMetadata {
switch t := m.(type) {
case *metav1.ObjectMeta:
- return &metav1beta1.PartialObjectMetadata{ObjectMeta: *t}
+ return &metav1.PartialObjectMetadata{ObjectMeta: *t}
default:
- return &metav1beta1.PartialObjectMetadata{
+ return &metav1.PartialObjectMetadata{
ObjectMeta: metav1.ObjectMeta{
Name: m.GetName(),
GenerateName: m.GetGenerateName(),
@@ -132,12 +130,13 @@
CreationTimestamp: m.GetCreationTimestamp(),
DeletionTimestamp: m.GetDeletionTimestamp(),
DeletionGracePeriodSeconds: m.GetDeletionGracePeriodSeconds(),
- Labels: m.GetLabels(),
- Annotations: m.GetAnnotations(),
- OwnerReferences: m.GetOwnerReferences(),
- Finalizers: m.GetFinalizers(),
- ClusterName: m.GetClusterName(),
- Initializers: m.GetInitializers(),
+ Labels: m.GetLabels(),
+ Annotations: m.GetAnnotations(),
+ OwnerReferences: m.GetOwnerReferences(),
+ Finalizers: m.GetFinalizers(),
+ ClusterName: m.GetClusterName(),
+ Initializers: m.GetInitializers(),
+ ManagedFields: m.GetManagedFields(),
},
}
}
@@ -607,7 +606,7 @@
var ret []metav1.OwnerReference
s := a.ownerReferences
if s.Kind() != reflect.Ptr || s.Elem().Kind() != reflect.Slice {
- glog.Errorf("expect %v to be a pointer to slice", s)
+ klog.Errorf("expect %v to be a pointer to slice", s)
return ret
}
s = s.Elem()
@@ -615,7 +614,7 @@
ret = make([]metav1.OwnerReference, s.Len(), s.Len()+1)
for i := 0; i < s.Len(); i++ {
if err := extractFromOwnerReference(s.Index(i), &ret[i]); err != nil {
- glog.Errorf("extractFromOwnerReference failed: %v", err)
+ klog.Errorf("extractFromOwnerReference failed: %v", err)
return ret
}
}
@@ -625,13 +624,13 @@
func (a genericAccessor) SetOwnerReferences(references []metav1.OwnerReference) {
s := a.ownerReferences
if s.Kind() != reflect.Ptr || s.Elem().Kind() != reflect.Slice {
- glog.Errorf("expect %v to be a pointer to slice", s)
+ klog.Errorf("expect %v to be a pointer to slice", s)
}
s = s.Elem()
newReferences := reflect.MakeSlice(s.Type(), len(references), len(references))
for i := 0; i < len(references); i++ {
if err := setOwnerReference(newReferences.Index(i), &references[i]); err != nil {
- glog.Errorf("setOwnerReference failed: %v", err)
+ klog.Errorf("setOwnerReference failed: %v", err)
return
}
}
diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/OWNERS b/vendor/k8s.io/apimachinery/pkg/api/resource/OWNERS
old mode 100755
new mode 100644
index c430067..8454be5
--- a/vendor/k8s.io/apimachinery/pkg/api/resource/OWNERS
+++ b/vendor/k8s.io/apimachinery/pkg/api/resource/OWNERS
@@ -1,3 +1,5 @@
+# See the OWNERS docs at https://go.k8s.io/owners
+
reviewers:
- thockin
- lavalamp
diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go b/vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
index 802f22a..9d7835b 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
@@ -14,9 +14,8 @@
limitations under the License.
*/
-// Code generated by protoc-gen-gogo.
+// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
-// DO NOT EDIT!
/*
Package resource is a generated protocol buffer package.
diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto b/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
index 2c615d5..acc9044 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
+++ b/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
@@ -27,9 +27,9 @@
// Quantity is a fixed-point representation of a number.
// It provides convenient marshaling/unmarshaling in JSON and YAML,
// in addition to String() and Int64() accessors.
-//
+//
// The serialization format is:
-//
+//
// <quantity> ::= <signedNumber><suffix>
// (Note that <suffix> may be empty, from the "" case in <decimalSI>.)
// <digit> ::= 0 | 1 | ... | 9
@@ -43,16 +43,16 @@
// <decimalSI> ::= m | "" | k | M | G | T | P | E
// (Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)
// <decimalExponent> ::= "e" <signedNumber> | "E" <signedNumber>
-//
+//
// No matter which of the three exponent forms is used, no quantity may represent
// a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal
// places. Numbers larger or more precise will be capped or rounded up.
// (E.g.: 0.1m will rounded up to 1m.)
// This may be extended in the future if we require larger or smaller quantities.
-//
+//
// When a Quantity is parsed from a string, it will remember the type of suffix
// it had, and will use the same type again when it is serialized.
-//
+//
// Before serializing, Quantity will be put in "canonical form".
// This means that Exponent/suffix will be adjusted up or down (with a
// corresponding increase or decrease in Mantissa) such that:
@@ -60,22 +60,22 @@
// b. No fractional digits will be emitted
// c. The exponent (or suffix) is as large as possible.
// The sign will be omitted unless the number is negative.
-//
+//
// Examples:
// 1.5 will be serialized as "1500m"
// 1.5Gi will be serialized as "1536Mi"
-//
+//
// Note that the quantity will NEVER be internally represented by a
// floating point number. That is the whole point of this exercise.
-//
+//
// Non-canonical values will still parse as long as they are well formed,
// but will be re-emitted in their canonical form. (So always use canonical
// form, or don't diff.)
-//
+//
// This format is intended to make it difficult to use these numbers without
// writing some sort of special handling code in the hopes that that will
// cause implementors to also use a fixed point implementation.
-//
+//
// +protobuf=true
// +protobuf.embed=string
// +protobuf.options.marshal=false
diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/math.go b/vendor/k8s.io/apimachinery/pkg/api/resource/math.go
index 72d3880..7f63175 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/resource/math.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/resource/math.go
@@ -194,9 +194,9 @@
}
if fraction {
if base > 0 {
- value += 1
+ value++
} else {
- value += -1
+ value--
}
}
return value, !fraction
diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go b/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
index b155a62..93a6c0c 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
@@ -584,6 +584,12 @@
q.d.Dec.Neg(q.d.Dec)
}
+// Equal checks equality of two Quantities. This is useful for testing with
+// cmp.Equal.
+func (q Quantity) Equal(v Quantity) bool {
+ return q.Cmp(v) == 0
+}
+
// int64QuantityExpectedBytes is the expected width in bytes of the canonical string representation
// of most Quantity values.
const int64QuantityExpectedBytes = 18
@@ -680,7 +686,7 @@
}
}
-// Value returns the value of q; any fractional part will be lost.
+// Value returns the unscaled value of q rounded up to the nearest integer away from 0.
func (q *Quantity) Value() int64 {
return q.ScaledValue(0)
}