Bumping k8s dependencies to 1.13

This commit is contained in:
Cheng Xing
2018-11-16 14:08:25 -08:00
parent 305407125c
commit b4c0b68ec7
8002 changed files with 884099 additions and 276228 deletions

View File

@@ -8,50 +8,17 @@ go_library(
name = "go_default_library",
srcs = [
"service_port.go",
"umask.go",
"umask_windows.go",
"util.go",
] + select({
"@io_bazel_rules_go//go/platform:android": [
"umask.go",
],
"@io_bazel_rules_go//go/platform:darwin": [
"umask.go",
],
"@io_bazel_rules_go//go/platform:dragonfly": [
"umask.go",
],
"@io_bazel_rules_go//go/platform:freebsd": [
"umask.go",
],
"@io_bazel_rules_go//go/platform:linux": [
"umask.go",
],
"@io_bazel_rules_go//go/platform:nacl": [
"umask.go",
],
"@io_bazel_rules_go//go/platform:netbsd": [
"umask.go",
],
"@io_bazel_rules_go//go/platform:openbsd": [
"umask.go",
],
"@io_bazel_rules_go//go/platform:plan9": [
"umask.go",
],
"@io_bazel_rules_go//go/platform:solaris": [
"umask.go",
],
"@io_bazel_rules_go//go/platform:windows": [
"umask_windows.go",
],
"//conditions:default": [],
}),
],
importpath = "k8s.io/kubernetes/pkg/kubectl/util",
visibility = ["//build/visible_to:pkg_kubectl_util_CONSUMERS"],
deps = [
"//pkg/apis/core:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
] + select({
"@io_bazel_rules_go//go/platform:android": [
"//vendor/golang.org/x/sys/unix:go_default_library",
@@ -116,7 +83,7 @@ go_test(
],
embed = [":go_default_library"],
deps = [
"//pkg/apis/core:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
],
)

View File

@@ -10,14 +10,14 @@ go_test(
name = "go_default_test",
srcs = ["hash_test.go"],
embed = [":go_default_library"],
deps = ["//vendor/k8s.io/api/core/v1:go_default_library"],
deps = ["//staging/src/k8s.io/api/core/v1:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = ["hash.go"],
importpath = "k8s.io/kubernetes/pkg/kubectl/util/hash",
deps = ["//vendor/k8s.io/api/core/v1:go_default_library"],
deps = ["//staging/src/k8s.io/api/core/v1:go_default_library"],
)
filegroup(

View File

@@ -10,9 +10,9 @@ go_library(
srcs = ["logs.go"],
importpath = "k8s.io/kubernetes/pkg/kubectl/util/logs",
deps = [
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
],
)

View File

@@ -38,7 +38,7 @@ type GlogWriter struct{}
// Write implements the io.Writer interface.
func (writer GlogWriter) Write(data []byte) (n int, err error) {
glog.Info(string(data))
glog.InfoDepth(1, string(data))
return len(data), nil
}

View File

@@ -19,12 +19,12 @@ package util
import (
"fmt"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/intstr"
api "k8s.io/kubernetes/pkg/apis/core"
)
// Lookup containerPort number by its named port name
func LookupContainerPortNumberByName(pod api.Pod, name string) (int32, error) {
func lookupContainerPortNumberByName(pod v1.Pod, name string) (int32, error) {
for _, ctr := range pod.Spec.Containers {
for _, ctrportspec := range ctr.Ports {
if ctrportspec.Name == name {
@@ -40,12 +40,12 @@ func LookupContainerPortNumberByName(pod api.Pod, name string) (int32, error) {
// It implements the handling of resolving container named port, as well as ignoring targetPort when clusterIP=None
// It returns an error when a named port can't find a match (with -1 returned), or when the service does not
// declare such port (with the input port number returned).
func LookupContainerPortNumberByServicePort(svc api.Service, pod api.Pod, port int32) (int32, error) {
func LookupContainerPortNumberByServicePort(svc v1.Service, pod v1.Pod, port int32) (int32, error) {
for _, svcportspec := range svc.Spec.Ports {
if svcportspec.Port != port {
continue
}
if svc.Spec.ClusterIP == api.ClusterIPNone {
if svc.Spec.ClusterIP == v1.ClusterIPNone {
return port, nil
}
if svcportspec.TargetPort.Type == intstr.Int {
@@ -56,7 +56,7 @@ func LookupContainerPortNumberByServicePort(svc api.Service, pod api.Pod, port i
return int32(svcportspec.TargetPort.IntValue()), nil
}
} else {
return LookupContainerPortNumberByName(pod, svcportspec.TargetPort.String())
return lookupContainerPortNumberByName(pod, svcportspec.TargetPort.String())
}
}
return port, fmt.Errorf("Service %s does not have a service port %d", svc.Name, port)

View File

@@ -19,25 +19,25 @@ package util
import (
"testing"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/intstr"
api "k8s.io/kubernetes/pkg/apis/core"
)
func TestLookupContainerPortNumberByName(t *testing.T) {
cases := []struct {
tests := []struct {
name string
pod api.Pod
pod v1.Pod
portname string
portnum int32
err bool
}{
{
name: "test success 1",
pod: api.Pod{
Spec: api.PodSpec{
Containers: []api.Container{
pod: v1.Pod{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Ports: []api.ContainerPort{
Ports: []v1.ContainerPort{
{
Name: "https",
ContainerPort: int32(443)},
@@ -55,11 +55,11 @@ func TestLookupContainerPortNumberByName(t *testing.T) {
},
{
name: "test faulure 1",
pod: api.Pod{
Spec: api.PodSpec{
Containers: []api.Container{
pod: v1.Pod{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Ports: []api.ContainerPort{
Ports: []v1.ContainerPort{
{
Name: "https",
ContainerPort: int32(443)},
@@ -74,42 +74,44 @@ func TestLookupContainerPortNumberByName(t *testing.T) {
},
}
for _, tc := range cases {
portnum, err := LookupContainerPortNumberByName(tc.pod, tc.portname)
if err != nil {
if tc.err {
continue
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
portnum, err := lookupContainerPortNumberByName(tt.pod, tt.portname)
if err != nil {
if tt.err {
return
}
t.Errorf("%v: unexpected error: %v", tt.name, err)
return
}
t.Errorf("%v: unexpected error: %v", tc.name, err)
continue
}
if tt.err {
t.Errorf("%v: unexpected success", tt.name)
return
}
if tc.err {
t.Errorf("%v: unexpected success", tc.name)
continue
}
if portnum != tc.portnum {
t.Errorf("%v: expected port number %v; got %v", tc.name, tc.portnum, portnum)
}
if portnum != tt.portnum {
t.Errorf("%v: expected port number %v; got %v", tt.name, tt.portnum, portnum)
}
})
}
}
func TestLookupContainerPortNumberByServicePort(t *testing.T) {
cases := []struct {
tests := []struct {
name string
svc api.Service
pod api.Pod
svc v1.Service
pod v1.Pod
port int32
containerPort int32
err bool
}{
{
name: "test success 1 (int port)",
svc: api.Service{
Spec: api.ServiceSpec{
Ports: []api.ServicePort{
svc: v1.Service{
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromInt(8080),
@@ -117,11 +119,11 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
},
},
pod: api.Pod{
Spec: api.PodSpec{
Containers: []api.Container{
pod: v1.Pod{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Ports: []api.ContainerPort{
Ports: []v1.ContainerPort{
{
Name: "http",
ContainerPort: int32(8080)},
@@ -136,10 +138,10 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
{
name: "test success 2 (clusterIP: None)",
svc: api.Service{
Spec: api.ServiceSpec{
ClusterIP: api.ClusterIPNone,
Ports: []api.ServicePort{
svc: v1.Service{
Spec: v1.ServiceSpec{
ClusterIP: v1.ClusterIPNone,
Ports: []v1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromInt(8080),
@@ -147,11 +149,11 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
},
},
pod: api.Pod{
Spec: api.PodSpec{
Containers: []api.Container{
pod: v1.Pod{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Ports: []api.ContainerPort{
Ports: []v1.ContainerPort{
{
Name: "http",
ContainerPort: int32(8080)},
@@ -166,9 +168,9 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
{
name: "test success 3 (named port)",
svc: api.Service{
Spec: api.ServiceSpec{
Ports: []api.ServicePort{
svc: v1.Service{
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromString("http"),
@@ -176,11 +178,11 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
},
},
pod: api.Pod{
Spec: api.PodSpec{
Containers: []api.Container{
pod: v1.Pod{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Ports: []api.ContainerPort{
Ports: []v1.ContainerPort{
{
Name: "http",
ContainerPort: int32(8080)},
@@ -195,20 +197,20 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
{
name: "test success (targetPort omitted)",
svc: api.Service{
Spec: api.ServiceSpec{
Ports: []api.ServicePort{
svc: v1.Service{
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Port: 80,
},
},
},
},
pod: api.Pod{
Spec: api.PodSpec{
Containers: []api.Container{
pod: v1.Pod{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Ports: []api.ContainerPort{
Ports: []v1.ContainerPort{
{
Name: "http",
ContainerPort: int32(80)},
@@ -223,9 +225,9 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
{
name: "test failure 1 (cannot find a matching named port)",
svc: api.Service{
Spec: api.ServiceSpec{
Ports: []api.ServicePort{
svc: v1.Service{
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromString("http"),
@@ -233,11 +235,11 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
},
},
pod: api.Pod{
Spec: api.PodSpec{
Containers: []api.Container{
pod: v1.Pod{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Ports: []api.ContainerPort{
Ports: []v1.ContainerPort{
{
Name: "https",
ContainerPort: int32(443)},
@@ -252,9 +254,9 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
{
name: "test failure 2 (cannot find a matching service port)",
svc: api.Service{
Spec: api.ServiceSpec{
Ports: []api.ServicePort{
svc: v1.Service{
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromString("http"),
@@ -262,11 +264,11 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
},
},
pod: api.Pod{
Spec: api.PodSpec{
Containers: []api.Container{
pod: v1.Pod{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Ports: []api.ContainerPort{
Ports: []v1.ContainerPort{
{
Name: "https",
ContainerPort: int32(443)},
@@ -281,10 +283,10 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
{
name: "test failure 2 (cannot find a matching service port, but ClusterIP: None)",
svc: api.Service{
Spec: api.ServiceSpec{
ClusterIP: api.ClusterIPNone,
Ports: []api.ServicePort{
svc: v1.Service{
Spec: v1.ServiceSpec{
ClusterIP: v1.ClusterIPNone,
Ports: []v1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromString("http"),
@@ -292,11 +294,11 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
},
},
pod: api.Pod{
Spec: api.PodSpec{
Containers: []api.Container{
pod: v1.Pod{
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Ports: []api.ContainerPort{
Ports: []v1.ContainerPort{
{
Name: "http",
ContainerPort: int32(80)},
@@ -311,27 +313,29 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
},
}
for _, tc := range cases {
containerPort, err := LookupContainerPortNumberByServicePort(tc.svc, tc.pod, tc.port)
if err != nil {
if tc.err {
if containerPort != tc.containerPort {
t.Errorf("%v: expected port %v; got %v", tc.name, tc.containerPort, containerPort)
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
containerPort, err := LookupContainerPortNumberByServicePort(tt.svc, tt.pod, tt.port)
if err != nil {
if tt.err {
if containerPort != tt.containerPort {
t.Errorf("%v: expected port %v; got %v", tt.name, tt.containerPort, containerPort)
}
return
}
continue
t.Errorf("%v: unexpected error: %v", tt.name, err)
return
}
t.Errorf("%v: unexpected error: %v", tc.name, err)
continue
}
if tt.err {
t.Errorf("%v: unexpected success", tt.name)
return
}
if tc.err {
t.Errorf("%v: unexpected success", tc.name)
continue
}
if containerPort != tc.containerPort {
t.Errorf("%v: expected port %v; got %v", tc.name, tc.containerPort, containerPort)
}
if containerPort != tt.containerPort {
t.Errorf("%v: expected port %v; got %v", tt.name, tt.containerPort, containerPort)
}
})
}
}

View File

@@ -10,51 +10,18 @@ go_library(
name = "go_default_library",
srcs = [
"resize.go",
"resizeevents.go",
"resizeevents_windows.go",
"term.go",
"term_writer.go",
] + select({
"@io_bazel_rules_go//go/platform:android": [
"resizeevents.go",
],
"@io_bazel_rules_go//go/platform:darwin": [
"resizeevents.go",
],
"@io_bazel_rules_go//go/platform:dragonfly": [
"resizeevents.go",
],
"@io_bazel_rules_go//go/platform:freebsd": [
"resizeevents.go",
],
"@io_bazel_rules_go//go/platform:linux": [
"resizeevents.go",
],
"@io_bazel_rules_go//go/platform:nacl": [
"resizeevents.go",
],
"@io_bazel_rules_go//go/platform:netbsd": [
"resizeevents.go",
],
"@io_bazel_rules_go//go/platform:openbsd": [
"resizeevents.go",
],
"@io_bazel_rules_go//go/platform:plan9": [
"resizeevents.go",
],
"@io_bazel_rules_go//go/platform:solaris": [
"resizeevents.go",
],
"@io_bazel_rules_go//go/platform:windows": [
"resizeevents_windows.go",
],
"//conditions:default": [],
}),
],
importpath = "k8s.io/kubernetes/pkg/kubectl/util/term",
deps = [
"//pkg/util/interrupt:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//staging/src/k8s.io/client-go/tools/remotecommand:go_default_library",
"//vendor/github.com/docker/docker/pkg/term:go_default_library",
"//vendor/github.com/mitchellh/go-wordwrap:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//vendor/k8s.io/client-go/tools/remotecommand:go_default_library",
] + select({
"@io_bazel_rules_go//go/platform:android": [
"//vendor/golang.org/x/sys/unix:go_default_library",

View File

@@ -19,7 +19,7 @@ package util
import "testing"
func TestParseFileSource(t *testing.T) {
cases := []struct {
tests := []struct {
name string
input string
key string
@@ -88,35 +88,37 @@ func TestParseFileSource(t *testing.T) {
},
}
for _, tc := range cases {
key, filepath, err := ParseFileSource(tc.input)
if err != nil {
if tc.err {
continue
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
key, filepath, err := ParseFileSource(tt.input)
if err != nil {
if tt.err {
return
}
t.Errorf("%v: unexpected error: %v", tt.name, err)
return
}
t.Errorf("%v: unexpected error: %v", tc.name, err)
continue
}
if tt.err {
t.Errorf("%v: unexpected success", tt.name)
return
}
if tc.err {
t.Errorf("%v: unexpected success", tc.name)
continue
}
if e, a := tt.key, key; e != a {
t.Errorf("%v: expected key %v; got %v", tt.name, e, a)
return
}
if e, a := tc.key, key; e != a {
t.Errorf("%v: expected key %v; got %v", tc.name, e, a)
continue
}
if e, a := tc.filepath, filepath; e != a {
t.Errorf("%v: expected filepath %v; got %v", tc.name, e, a)
}
if e, a := tt.filepath, filepath; e != a {
t.Errorf("%v: expected filepath %v; got %v", tt.name, e, a)
}
})
}
}
func TestParseLiteralSource(t *testing.T) {
cases := []struct {
tests := []struct {
name string
input string
key string
@@ -170,29 +172,31 @@ func TestParseLiteralSource(t *testing.T) {
},
}
for _, tc := range cases {
key, value, err := ParseLiteralSource(tc.input)
if err != nil {
if tc.err {
continue
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
key, value, err := ParseLiteralSource(tt.input)
if err != nil {
if tt.err {
return
}
t.Errorf("%v: unexpected error: %v", tt.name, err)
return
}
t.Errorf("%v: unexpected error: %v", tc.name, err)
continue
}
if tt.err {
t.Errorf("%v: unexpected success", tt.name)
return
}
if tc.err {
t.Errorf("%v: unexpected success", tc.name)
continue
}
if e, a := tt.key, key; e != a {
t.Errorf("%v: expected key %v; got %v", tt.name, e, a)
return
}
if e, a := tc.key, key; e != a {
t.Errorf("%v: expected key %v; got %v", tc.name, e, a)
continue
}
if e, a := tc.value, value; e != a {
t.Errorf("%v: expected value %v; got %v", tc.name, e, a)
}
if e, a := tt.value, value; e != a {
t.Errorf("%v: expected value %v; got %v", tt.name, e, a)
}
})
}
}