Replace godep with dep
This commit is contained in:
parent
1e7489927c
commit
bf5616c65b
14883 changed files with 3937406 additions and 361781 deletions
56
vendor/k8s.io/kubernetes/pkg/api/testing/BUILD
generated
vendored
Normal file
56
vendor/k8s.io/kubernetes/pkg/api/testing/BUILD
generated
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"conversion.go",
|
||||
"fuzzer.go",
|
||||
"pod_specs.go",
|
||||
],
|
||||
deps = [
|
||||
"//cmd/kubeadm/app/apis/kubeadm/fuzzer:go_default_library",
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/api/fuzzer:go_default_library",
|
||||
"//pkg/apis/admissionregistration/fuzzer:go_default_library",
|
||||
"//pkg/apis/apps/fuzzer:go_default_library",
|
||||
"//pkg/apis/autoscaling/fuzzer:go_default_library",
|
||||
"//pkg/apis/batch/fuzzer:go_default_library",
|
||||
"//pkg/apis/certificates/fuzzer:go_default_library",
|
||||
"//pkg/apis/extensions:go_default_library",
|
||||
"//pkg/apis/extensions/fuzzer:go_default_library",
|
||||
"//pkg/apis/extensions/v1beta1:go_default_library",
|
||||
"//pkg/apis/networking/fuzzer:go_default_library",
|
||||
"//pkg/apis/policy/fuzzer:go_default_library",
|
||||
"//pkg/apis/rbac/fuzzer:go_default_library",
|
||||
"//pkg/apis/storage/fuzzer:go_default_library",
|
||||
"//vendor/github.com/google/gofuzz:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/testing:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/testing/fuzzer:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/fuzzer:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//pkg/api/testing/compat:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
39
vendor/k8s.io/kubernetes/pkg/api/testing/OWNERS
generated
vendored
Executable file
39
vendor/k8s.io/kubernetes/pkg/api/testing/OWNERS
generated
vendored
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
reviewers:
|
||||
- thockin
|
||||
- lavalamp
|
||||
- smarterclayton
|
||||
- wojtek-t
|
||||
- deads2k
|
||||
- yujuhong
|
||||
- brendandburns
|
||||
- derekwaynecarr
|
||||
- caesarxuchao
|
||||
- vishh
|
||||
- mikedanese
|
||||
- nikhiljindal
|
||||
- erictune
|
||||
- pmorie
|
||||
- dchen1107
|
||||
- saad-ali
|
||||
- zmerlynn
|
||||
- justinsb
|
||||
- pwittrock
|
||||
- roberthbailey
|
||||
- tallclair
|
||||
- yifan-gu
|
||||
- eparis
|
||||
- soltysh
|
||||
- jsafrane
|
||||
- madhusudancs
|
||||
- hongchaodeng
|
||||
- rootfs
|
||||
- jszczepkowski
|
||||
- markturansky
|
||||
- fgrzadkowski
|
||||
- aveshagarwal
|
||||
- david-mcmahon
|
||||
- pweil-
|
||||
- rata
|
||||
- feihujiang
|
||||
- sdminonne
|
||||
- ghodss
|
||||
31
vendor/k8s.io/kubernetes/pkg/api/testing/compat/BUILD
generated
vendored
Normal file
31
vendor/k8s.io/kubernetes/pkg/api/testing/compat/BUILD
generated
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["compatibility_tester.go"],
|
||||
deps = [
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/printers:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
||||
144
vendor/k8s.io/kubernetes/pkg/api/testing/compat/compatibility_tester.go
generated
vendored
Normal file
144
vendor/k8s.io/kubernetes/pkg/api/testing/compat/compatibility_tester.go
generated
vendored
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
Copyright 2015 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 compat
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
)
|
||||
|
||||
// Based on: https://github.com/openshift/origin/blob/master/pkg/api/compatibility_test.go
|
||||
//
|
||||
// TestCompatibility reencodes the input using the codec for the given
|
||||
// version and checks for the presence of the expected keys and absent
|
||||
// keys in the resulting JSON.
|
||||
func TestCompatibility(
|
||||
t *testing.T,
|
||||
version schema.GroupVersion,
|
||||
input []byte,
|
||||
validator func(obj runtime.Object) field.ErrorList,
|
||||
expectedKeys map[string]string,
|
||||
absentKeys []string,
|
||||
) {
|
||||
|
||||
// Decode
|
||||
codec := api.Codecs.LegacyCodec(version)
|
||||
obj, err := runtime.Decode(codec, input)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
// Validate
|
||||
errs := validator(obj)
|
||||
if len(errs) != 0 {
|
||||
t.Fatalf("Unexpected validation errors: %v", errs)
|
||||
}
|
||||
|
||||
// Encode
|
||||
output, err := runtime.Encode(codec, obj)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
// Validate old and new fields are encoded
|
||||
generic := map[string]interface{}{}
|
||||
if err := json.Unmarshal(output, &generic); err != nil {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
|
||||
hasError := false
|
||||
for k, expectedValue := range expectedKeys {
|
||||
keys := strings.Split(k, ".")
|
||||
if actualValue, ok, err := getJSONValue(generic, keys...); err != nil || !ok {
|
||||
t.Errorf("Unexpected error for %s: %v", k, err)
|
||||
hasError = true
|
||||
} else if !reflect.DeepEqual(expectedValue, fmt.Sprintf("%v", actualValue)) {
|
||||
hasError = true
|
||||
t.Errorf("Unexpected value for %v: expected %v, got %v", k, expectedValue, actualValue)
|
||||
}
|
||||
}
|
||||
|
||||
for _, absentKey := range absentKeys {
|
||||
keys := strings.Split(absentKey, ".")
|
||||
actualValue, ok, err := getJSONValue(generic, keys...)
|
||||
if err == nil || ok {
|
||||
t.Errorf("Unexpected value found for key %s: %v", absentKey, actualValue)
|
||||
hasError = true
|
||||
}
|
||||
}
|
||||
|
||||
if hasError {
|
||||
printer := &printers.JSONPrinter{}
|
||||
printer.PrintObj(obj, os.Stdout)
|
||||
t.Logf("2: Encoded value: %#v", string(output))
|
||||
}
|
||||
}
|
||||
|
||||
func getJSONValue(data map[string]interface{}, keys ...string) (interface{}, bool, error) {
|
||||
// No keys, current value is it
|
||||
if len(keys) == 0 {
|
||||
return data, true, nil
|
||||
}
|
||||
|
||||
// Get the key (and optional index)
|
||||
key := keys[0]
|
||||
index := -1
|
||||
if matches := regexp.MustCompile(`^(.*)\[(\d+)\]$`).FindStringSubmatch(key); len(matches) > 0 {
|
||||
key = matches[1]
|
||||
index, _ = strconv.Atoi(matches[2])
|
||||
}
|
||||
|
||||
// Look up the value
|
||||
value, ok := data[key]
|
||||
if !ok {
|
||||
return nil, false, fmt.Errorf("No key %s found", key)
|
||||
}
|
||||
|
||||
// Get the indexed value if an index is specified
|
||||
if index >= 0 {
|
||||
valueSlice, ok := value.([]interface{})
|
||||
if !ok {
|
||||
return nil, false, fmt.Errorf("Key %s did not hold a slice", key)
|
||||
}
|
||||
if index >= len(valueSlice) {
|
||||
return nil, false, fmt.Errorf("Index %d out of bounds for slice at key: %v", index, key)
|
||||
}
|
||||
value = valueSlice[index]
|
||||
}
|
||||
|
||||
if len(keys) == 1 {
|
||||
return value, true, nil
|
||||
}
|
||||
|
||||
childData, ok := value.(map[string]interface{})
|
||||
if !ok {
|
||||
return nil, false, fmt.Errorf("Key %s did not hold a map", keys[0])
|
||||
}
|
||||
return getJSONValue(childData, keys[1:]...)
|
||||
}
|
||||
72
vendor/k8s.io/kubernetes/pkg/api/testing/conversion.go
generated
vendored
Normal file
72
vendor/k8s.io/kubernetes/pkg/api/testing/conversion.go
generated
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
Copyright 2015 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 testing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
)
|
||||
|
||||
// TestSelectableFieldLabelConversions verifies that given resource have field
|
||||
// label conversion defined for each its selectable field.
|
||||
// fields contains selectable fields of the resource.
|
||||
// labelMap maps deprecated labels to their canonical names.
|
||||
func TestSelectableFieldLabelConversionsOfKind(t *testing.T, apiVersion string, kind string, fields fields.Set, labelMap map[string]string) {
|
||||
badFieldLabels := []string{
|
||||
"name",
|
||||
".name",
|
||||
"bad",
|
||||
"metadata",
|
||||
"foo.bar",
|
||||
}
|
||||
|
||||
value := "value"
|
||||
|
||||
if len(fields) == 0 {
|
||||
t.Logf("no selectable fields for kind %q, skipping", kind)
|
||||
}
|
||||
for label := range fields {
|
||||
if label == "name" {
|
||||
t.Logf("FIXME: \"name\" is deprecated by \"metadata.name\", it should be removed from selectable fields of kind=%s", kind)
|
||||
continue
|
||||
}
|
||||
newLabel, newValue, err := api.Scheme.ConvertFieldLabel(apiVersion, kind, label, value)
|
||||
if err != nil {
|
||||
t.Errorf("kind=%s label=%s: got unexpected error: %v", kind, label, err)
|
||||
} else {
|
||||
expectedLabel := label
|
||||
if l, exists := labelMap[label]; exists {
|
||||
expectedLabel = l
|
||||
}
|
||||
if newLabel != expectedLabel {
|
||||
t.Errorf("kind=%s label=%s: got unexpected label name (%q != %q)", kind, label, newLabel, expectedLabel)
|
||||
}
|
||||
if newValue != value {
|
||||
t.Errorf("kind=%s label=%s: got unexpected new value (%q != %q)", kind, label, newValue, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, label := range badFieldLabels {
|
||||
_, _, err := api.Scheme.ConvertFieldLabel(apiVersion, kind, label, "value")
|
||||
if err == nil {
|
||||
t.Errorf("kind=%s label=%s: got unexpected non-error", kind, label)
|
||||
}
|
||||
}
|
||||
}
|
||||
107
vendor/k8s.io/kubernetes/pkg/api/testing/fuzzer.go
generated
vendored
Normal file
107
vendor/k8s.io/kubernetes/pkg/api/testing/fuzzer.go
generated
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
Copyright 2015 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 testing
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
fuzz "github.com/google/gofuzz"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
apitesting "k8s.io/apimachinery/pkg/api/testing"
|
||||
"k8s.io/apimachinery/pkg/api/testing/fuzzer"
|
||||
genericfuzzer "k8s.io/apimachinery/pkg/apis/meta/fuzzer"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
kubeadmfuzzer "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/fuzzer"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
corefuzzer "k8s.io/kubernetes/pkg/api/fuzzer"
|
||||
admissionregistrationfuzzer "k8s.io/kubernetes/pkg/apis/admissionregistration/fuzzer"
|
||||
appsfuzzer "k8s.io/kubernetes/pkg/apis/apps/fuzzer"
|
||||
autoscalingfuzzer "k8s.io/kubernetes/pkg/apis/autoscaling/fuzzer"
|
||||
batchfuzzer "k8s.io/kubernetes/pkg/apis/batch/fuzzer"
|
||||
certificatesfuzzer "k8s.io/kubernetes/pkg/apis/certificates/fuzzer"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
extensionsfuzzer "k8s.io/kubernetes/pkg/apis/extensions/fuzzer"
|
||||
extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
|
||||
networkingfuzzer "k8s.io/kubernetes/pkg/apis/networking/fuzzer"
|
||||
policyfuzzer "k8s.io/kubernetes/pkg/apis/policy/fuzzer"
|
||||
rbacfuzzer "k8s.io/kubernetes/pkg/apis/rbac/fuzzer"
|
||||
storagefuzzer "k8s.io/kubernetes/pkg/apis/storage/fuzzer"
|
||||
)
|
||||
|
||||
// overrideGenericFuncs override some generic fuzzer funcs from k8s.io/apiserver in order to have more realistic
|
||||
// values in a Kubernetes context.
|
||||
func overrideGenericFuncs(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||
return []interface{}{
|
||||
func(j *runtime.Object, c fuzz.Continue) {
|
||||
// TODO: uncomment when round trip starts from a versioned object
|
||||
if true { //c.RandBool() {
|
||||
*j = &runtime.Unknown{
|
||||
// We do not set TypeMeta here because it is not carried through a round trip
|
||||
Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`),
|
||||
ContentType: runtime.ContentTypeJSON,
|
||||
}
|
||||
} else {
|
||||
types := []runtime.Object{&api.Pod{}, &api.ReplicationController{}}
|
||||
t := types[c.Rand.Intn(len(types))]
|
||||
c.Fuzz(t)
|
||||
*j = t
|
||||
}
|
||||
},
|
||||
func(r *runtime.RawExtension, c fuzz.Continue) {
|
||||
// Pick an arbitrary type and fuzz it
|
||||
types := []runtime.Object{&api.Pod{}, &extensions.Deployment{}, &api.Service{}}
|
||||
obj := types[c.Rand.Intn(len(types))]
|
||||
c.Fuzz(obj)
|
||||
|
||||
var codec runtime.Codec
|
||||
switch obj.(type) {
|
||||
case *extensions.Deployment:
|
||||
codec = apitesting.TestCodec(codecs, extensionsv1beta1.SchemeGroupVersion)
|
||||
default:
|
||||
codec = apitesting.TestCodec(codecs, v1.SchemeGroupVersion)
|
||||
}
|
||||
|
||||
// Convert the object to raw bytes
|
||||
bytes, err := runtime.Encode(codec, obj)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("Failed to encode object: %v", err))
|
||||
}
|
||||
|
||||
// Set the bytes field on the RawExtension
|
||||
r.Raw = bytes
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
var FuzzerFuncs = fuzzer.MergeFuzzerFuncs(
|
||||
genericfuzzer.Funcs,
|
||||
overrideGenericFuncs,
|
||||
corefuzzer.Funcs,
|
||||
extensionsfuzzer.Funcs,
|
||||
appsfuzzer.Funcs,
|
||||
batchfuzzer.Funcs,
|
||||
autoscalingfuzzer.Funcs,
|
||||
rbacfuzzer.Funcs,
|
||||
kubeadmfuzzer.Funcs,
|
||||
policyfuzzer.Funcs,
|
||||
certificatesfuzzer.Funcs,
|
||||
admissionregistrationfuzzer.Funcs,
|
||||
storagefuzzer.Funcs,
|
||||
networkingfuzzer.Funcs,
|
||||
)
|
||||
45
vendor/k8s.io/kubernetes/pkg/api/testing/pod_specs.go
generated
vendored
Normal file
45
vendor/k8s.io/kubernetes/pkg/api/testing/pod_specs.go
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
Copyright 2015 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 testing
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
)
|
||||
|
||||
// DeepEqualSafePodSpec returns a PodSpec which is ready to be used with apiequality.Semantic.DeepEqual
|
||||
func DeepEqualSafePodSpec() api.PodSpec {
|
||||
grace := int64(30)
|
||||
return api.PodSpec{
|
||||
RestartPolicy: api.RestartPolicyAlways,
|
||||
DNSPolicy: api.DNSClusterFirst,
|
||||
TerminationGracePeriodSeconds: &grace,
|
||||
SecurityContext: &api.PodSecurityContext{},
|
||||
SchedulerName: api.DefaultSchedulerName,
|
||||
}
|
||||
}
|
||||
|
||||
// V1DeepEqualSafePodSpec returns a PodSpec which is ready to be used with apiequality.Semantic.DeepEqual
|
||||
func V1DeepEqualSafePodSpec() v1.PodSpec {
|
||||
grace := int64(30)
|
||||
return v1.PodSpec{
|
||||
RestartPolicy: v1.RestartPolicyAlways,
|
||||
DNSPolicy: v1.DNSClusterFirst,
|
||||
TerminationGracePeriodSeconds: &grace,
|
||||
SecurityContext: &v1.PodSecurityContext{},
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue