vendor updates

This commit is contained in:
Serguei Bezverkhi
2018-03-06 17:33:18 -05:00
parent 4b3ebc171b
commit e9033989a0
5854 changed files with 248382 additions and 119809 deletions

View File

@ -12,8 +12,7 @@ go_test(
"cache_test.go",
"lruexpirecache_test.go",
],
importpath = "k8s.io/apimachinery/pkg/util/cache",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//vendor/github.com/golang/groupcache/lru:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/clock:go_default_library",

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["clock_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/clock",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["diff_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/diff",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

22
vendor/k8s.io/apimachinery/pkg/util/duration/BUILD generated vendored Normal file
View File

@ -0,0 +1,22 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["duration.go"],
importpath = "k8s.io/apimachinery/pkg/util/duration",
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,43 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package duration
import (
"fmt"
"time"
)
// ShortHumanDuration returns a succint representation of the provided duration
// with limited precision for consumption by humans.
func ShortHumanDuration(d time.Duration) string {
// Allow deviation no more than 2 seconds(excluded) to tolerate machine time
// inconsistence, it can be considered as almost now.
if seconds := int(d.Seconds()); seconds < -1 {
return fmt.Sprintf("<invalid>")
} else if seconds < 0 {
return fmt.Sprintf("0s")
} else if seconds < 60 {
return fmt.Sprintf("%ds", seconds)
} else if minutes := int(d.Minutes()); minutes < 60 {
return fmt.Sprintf("%dm", minutes)
} else if hours := int(d.Hours()); hours < 24 {
return fmt.Sprintf("%dh", hours)
} else if hours < 24*365 {
return fmt.Sprintf("%dd", hours/24)
}
return fmt.Sprintf("%dy", int(d.Hours()/24/365))
}

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["errors_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/errors",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -21,7 +21,7 @@ import (
"fmt"
)
// MessageCountMap contains occurance for each error message.
// MessageCountMap contains occurrence for each error message.
type MessageCountMap map[string]int
// Aggregate represents an object that contains multiple errors, but does not

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["framer_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/framer",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["httpstream_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/httpstream",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -13,8 +13,7 @@ go_test(
"roundtripper_test.go",
"upgrade_test.go",
],
importpath = "k8s.io/apimachinery/pkg/util/httpstream/spdy",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//vendor/github.com/elazarl/goproxy:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/httpstream:go_default_library",

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["intstr_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/intstr",
library = ":go_default_library",
embed = [":go_default_library"],
deps = ["//vendor/github.com/ghodss/yaml:go_default_library"],
)
@ -22,11 +21,9 @@ go_library(
],
importpath = "k8s.io/apimachinery/pkg/util/intstr",
deps = [
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/google/gofuzz:go_default_library",
"//vendor/k8s.io/kube-openapi/pkg/common:go_default_library",
],
)

View File

@ -24,9 +24,6 @@ import (
"strconv"
"strings"
openapi "k8s.io/kube-openapi/pkg/common"
"github.com/go-openapi/spec"
"github.com/golang/glog"
"github.com/google/gofuzz"
)
@ -120,16 +117,15 @@ func (intstr IntOrString) MarshalJSON() ([]byte, error) {
}
}
func (_ IntOrString) OpenAPIDefinition() openapi.OpenAPIDefinition {
return openapi.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "int-or-string",
},
},
}
}
// OpenAPISchemaType is used by the kube-openapi generator when constructing
// the OpenAPI spec of this type.
//
// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators
func (_ IntOrString) OpenAPISchemaType() []string { return []string{"string"} }
// OpenAPISchemaFormat is used by the kube-openapi generator when constructing
// the OpenAPI spec of this type.
func (_ IntOrString) OpenAPISchemaFormat() string { return "int-or-string" }
func (intstr *IntOrString) Fuzz(c fuzz.Continue) {
if intstr == nil {

View File

@ -15,8 +15,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["json_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/json",
library = ":go_default_library",
embed = [":go_default_library"],
)
filegroup(

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["patch_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/jsonmergepatch",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
"//vendor/github.com/evanphx/json-patch:go_default_library",

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["util_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/mergepatch",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -15,8 +15,7 @@ go_test(
"port_split_test.go",
"util_test.go",
],
importpath = "k8s.io/apimachinery/pkg/util/net",
library = ":go_default_library",
embed = [":go_default_library"],
deps = ["//vendor/github.com/spf13/pflag:go_default_library"],
)

View File

@ -623,7 +623,7 @@ func TestFailGettingIPv4Routes(t *testing.T) {
errStrFrag := "no such file"
_, err := v4File.extract()
if err == nil {
fmt.Errorf("Expected error trying to read non-existent v4 route file")
t.Errorf("Expected error trying to read non-existent v4 route file")
}
if !strings.Contains(err.Error(), errStrFrag) {
t.Errorf("Unable to find %q in error string %q", errStrFrag, err.Error())
@ -638,7 +638,7 @@ func TestFailGettingIPv6Routes(t *testing.T) {
errStrFrag := "no such file"
_, err := v6File.extract()
if err == nil {
fmt.Errorf("Expected error trying to read non-existent v6 route file")
t.Errorf("Expected error trying to read non-existent v6 route file")
}
if !strings.Contains(err.Error(), errStrFrag) {
t.Errorf("Unable to find %q in error string %q", errStrFrag, err.Error())
@ -653,7 +653,7 @@ func TestGetAllDefaultRoutesFailNoV4RouteFile(t *testing.T) {
errStrFrag := "no such file"
_, err := getAllDefaultRoutes()
if err == nil {
fmt.Errorf("Expected error trying to read non-existent v4 route file")
t.Errorf("Expected error trying to read non-existent v4 route file")
}
if !strings.Contains(err.Error(), errStrFrag) {
t.Errorf("Unable to find %q in error string %q", errStrFrag, err.Error())

View File

@ -18,6 +18,8 @@ package net
import (
"net"
"net/url"
"os"
"reflect"
"syscall"
)
@ -38,8 +40,16 @@ func IPNetEqual(ipnet1, ipnet2 *net.IPNet) bool {
// Returns if the given err is "connection reset by peer" error.
func IsConnectionReset(err error) bool {
opErr, ok := err.(*net.OpError)
if ok && opErr.Err.Error() == syscall.ECONNRESET.Error() {
if urlErr, ok := err.(*url.Error); ok {
err = urlErr.Err
}
if opErr, ok := err.(*net.OpError); ok {
err = opErr.Err
}
if osErr, ok := err.(*os.SyscallError); ok {
err = osErr.Err
}
if errno, ok := err.(syscall.Errno); ok && errno == syscall.ECONNRESET {
return true
}
return false

View File

@ -13,8 +13,7 @@ go_test(
"transport_test.go",
"upgradeaware_test.go",
],
importpath = "k8s.io/apimachinery/pkg/util/proxy",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//vendor/github.com/stretchr/testify/assert:go_default_library",
"//vendor/github.com/stretchr/testify/require:go_default_library",

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["rand_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/rand",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -36,7 +36,7 @@ func TestString(t *testing.T) {
}
for _, c := range s {
if !strings.ContainsRune(valid, c) {
t.Errorf("expected valid charaters, got %v", c)
t.Errorf("expected valid characters, got %v", c)
}
}
}

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["runtime_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/runtime",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -43,7 +43,7 @@ var PanicHandlers = []func(interface{}){logPanic}
// TODO: remove this function. We are switching to a world where it's safe for
// apiserver to panic, since it will be restarted by kubelet. At the beginning
// of the Kubernetes project, nothing was going to restart apiserver and so
// catching panics was important. But it's actually much simpler for montoring
// catching panics was important. But it's actually much simpler for monitoring
// software if we just exit when an unexpected panic happens.
func HandleCrash(additionalHandlers ...func(interface{})) {
if r := recover(); r != nil {

View File

@ -51,8 +51,7 @@ $(location //vendor/k8s.io/code-generator/cmd/set-gen) \
go_test(
name = "go_default_test",
srcs = ["set_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/sets",
library = ":go_default_library",
embed = [":go_default_library"],
)
filegroup(

View File

@ -13,8 +13,7 @@ go_test(
"testdata/swagger-merge-item.json",
"testdata/swagger-precision-item.json",
],
importpath = "k8s.io/apimachinery/pkg/util/strategicpatch",
library = ":go_default_library",
embed = [":go_default_library"],
deps = [
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
"//vendor/github.com/ghodss/yaml:go_default_library",

View File

@ -423,7 +423,7 @@ func normalizeElementOrder(patch, serverOnly, patchOrder, serverOrder []interfac
// scan from the place of last insertion in `right` to the end of `right`,
// the place is before the first item that is greater than the item we want to insert.
// example usage: using server-only items as left and patch items as right. We insert server-only items
// to patch list. We use the order of live object as record for comparision.
// to patch list. We use the order of live object as record for comparison.
func mergeSortedSlice(left, right, serverOrder []interface{}, mergeKey string, kind reflect.Kind) []interface{} {
// Returns if l is less than r, and if both have been found.
// If l and r both present and l is in front of r, l is less than r.
@ -1322,23 +1322,23 @@ func mergeMap(original, patch map[string]interface{}, schema LookupPatchMeta, me
// If they're both maps or lists, recurse into the value.
switch originalType.Kind() {
case reflect.Map:
subschema, patchMeta, err := schema.LookupPatchMetadataForStruct(k)
if err != nil {
return nil, err
subschema, patchMeta, err2 := schema.LookupPatchMetadataForStruct(k)
if err2 != nil {
return nil, err2
}
_, patchStrategy, err := extractRetainKeysPatchStrategy(patchMeta.GetPatchStrategies())
if err != nil {
return nil, err
_, patchStrategy, err2 := extractRetainKeysPatchStrategy(patchMeta.GetPatchStrategies())
if err2 != nil {
return nil, err2
}
original[k], err = mergeMapHandler(original[k], patchV, subschema, patchStrategy, mergeOptions)
case reflect.Slice:
subschema, patchMeta, err := schema.LookupPatchMetadataForSlice(k)
if err != nil {
return nil, err
subschema, patchMeta, err2 := schema.LookupPatchMetadataForSlice(k)
if err2 != nil {
return nil, err2
}
_, patchStrategy, err := extractRetainKeysPatchStrategy(patchMeta.GetPatchStrategies())
if err != nil {
return nil, err
_, patchStrategy, err2 := extractRetainKeysPatchStrategy(patchMeta.GetPatchStrategies())
if err2 != nil {
return nil, err2
}
original[k], err = mergeSliceHandler(original[k], patchV, subschema, patchStrategy, patchMeta.GetPatchMergeKey(), isDeleteList, mergeOptions)
default:
@ -2109,7 +2109,7 @@ func sliceTypeAssertion(original, patch interface{}) ([]interface{}, []interface
}
// extractRetainKeysPatchStrategy process patch strategy, which is a string may contains multiple
// patch strategies seperated by ",". It returns a boolean var indicating if it has
// patch strategies separated by ",". It returns a boolean var indicating if it has
// retainKeys strategies and a string for the other strategy.
func extractRetainKeysPatchStrategy(strategies []string) (bool, string, error) {
switch len(strategies) {

View File

@ -654,6 +654,21 @@ mergingIntList:
ExpectedError: "doesn't match",
},
},
{
Description: "missing merge key should error out",
StrategicMergePatchRawTestCaseData: StrategicMergePatchRawTestCaseData{
Original: []byte(`
mergingList:
- name: 1
value: a
`),
TwoWay: []byte(`
mergingList:
- value: b
`),
ExpectedError: "does not contain declared merge key",
},
},
}
func TestCustomStrategicMergePatch(t *testing.T) {

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["validation_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/validation",
library = ":go_default_library",
embed = [":go_default_library"],
deps = ["//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library"],
)

View File

@ -12,8 +12,7 @@ go_test(
"errors_test.go",
"path_test.go",
],
importpath = "k8s.io/apimachinery/pkg/util/validation/field",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -99,7 +99,7 @@ func TestErrorUsefulMessage(t *testing.T) {
"foo", ErrorTypeInvalid.String(),
"Baz", "Qux", "Inner", "KV", "detail",
"1", "aoeu", "Billy", "2",
// "asdf", TODO: reenable once we have a better nested printer
// "asdf", TODO: re-enable once we have a better nested printer
} {
if !strings.Contains(s, part) {
t.Errorf("error message did not contain expected part '%v'", part)

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["wait_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/wait",
library = ":go_default_library",
embed = [":go_default_library"],
deps = ["//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library"],
)

View File

@ -13,8 +13,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["waitgroup_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/waitgroup",
library = ":go_default_library",
embed = [":go_default_library"],
)
filegroup(

View File

@ -37,7 +37,7 @@ func (wg *SafeWaitGroup) Add(delta int) error {
wg.mu.RLock()
defer wg.mu.RUnlock()
if wg.wait && delta > 0 {
return fmt.Errorf("add with postive delta after Wait is forbidden")
return fmt.Errorf("add with positive delta after Wait is forbidden")
}
wg.wg.Add(delta)
return nil

View File

@ -9,8 +9,7 @@ load(
go_test(
name = "go_default_test",
srcs = ["decoder_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/yaml",
library = ":go_default_library",
embed = [":go_default_library"],
)
go_library(

View File

@ -122,12 +122,12 @@ func (d *YAMLDecoder) Read(data []byte) (n int, err error) {
if left <= len(data) {
copy(data, d.remaining)
d.remaining = nil
return len(d.remaining), nil
return left, nil
}
// caller will need to reread
copy(data, d.remaining[:left])
d.remaining = d.remaining[left:]
copy(data, d.remaining[:len(data)])
d.remaining = d.remaining[len(data):]
return len(data), io.ErrShortBuffer
}

View File

@ -22,12 +22,68 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math/rand"
"reflect"
"strings"
"testing"
)
func TestYAMLDecoderReadBytesLength(t *testing.T) {
d := `---
stuff: 1
test-foo: 1
`
testCases := []struct {
bufLen int
expectLen int
expectErr error
}{
{len(d), len(d), nil},
{len(d) + 10, len(d), nil},
{len(d) - 10, len(d) - 10, io.ErrShortBuffer},
}
for i, testCase := range testCases {
r := NewDocumentDecoder(ioutil.NopCloser(bytes.NewReader([]byte(d))))
b := make([]byte, testCase.bufLen)
n, err := r.Read(b)
if err != testCase.expectErr || n != testCase.expectLen {
t.Fatalf("%d: unexpected body: %d / %v", i, n, err)
}
}
}
func TestYAMLDecoderCallsAfterErrShortBufferRestOfFrame(t *testing.T) {
d := `---
stuff: 1
test-foo: 1`
r := NewDocumentDecoder(ioutil.NopCloser(bytes.NewReader([]byte(d))))
b := make([]byte, 12)
n, err := r.Read(b)
if err != io.ErrShortBuffer || n != 12 {
t.Fatalf("expected ErrShortBuffer: %d / %v", n, err)
}
expected := "---\nstuff: 1"
if string(b) != expected {
t.Fatalf("expected bytes read to be: %s got: %s", expected, string(b))
}
b = make([]byte, 13)
n, err = r.Read(b)
if err != nil || n != 13 {
t.Fatalf("expected nil: %d / %v", n, err)
}
expected = "\n\ttest-foo: 1"
if string(b) != expected {
t.Fatalf("expected bytes read to be: '%s' got: '%s'", expected, string(b))
}
b = make([]byte, 15)
n, err = r.Read(b)
if err != io.EOF || n != 0 {
t.Fatalf("expected EOF: %d / %v", n, err)
}
}
func TestSplitYAMLDocument(t *testing.T) {
testCases := []struct {
input string