mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
remove API dependency on printers
This commit is contained in:
parent
080739a12a
commit
3693ed095f
@ -11,7 +11,6 @@ go_library(
|
|||||||
importpath = "k8s.io/kubernetes/pkg/api/testing/compat",
|
importpath = "k8s.io/kubernetes/pkg/api/testing/compat",
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/api/legacyscheme:go_default_library",
|
"//pkg/api/legacyscheme:go_default_library",
|
||||||
"//pkg/printers:go_default_library",
|
|
||||||
"//vendor/k8s.io/apimachinery/pkg/runtime: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/runtime/schema:go_default_library",
|
||||||
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
|
||||||
|
@ -19,7 +19,6 @@ package compat
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -30,7 +29,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/printers"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Based on: https://github.com/openshift/origin/blob/master/pkg/api/compatibility_test.go
|
// Based on: https://github.com/openshift/origin/blob/master/pkg/api/compatibility_test.go
|
||||||
@ -72,14 +70,11 @@ func TestCompatibility(
|
|||||||
t.Fatalf("Unexpected error: %v", err)
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasError := false
|
|
||||||
for k, expectedValue := range expectedKeys {
|
for k, expectedValue := range expectedKeys {
|
||||||
keys := strings.Split(k, ".")
|
keys := strings.Split(k, ".")
|
||||||
if actualValue, ok, err := getJSONValue(generic, keys...); err != nil || !ok {
|
if actualValue, ok, err := getJSONValue(generic, keys...); err != nil || !ok {
|
||||||
t.Errorf("Unexpected error for %s: %v", k, err)
|
t.Errorf("Unexpected error for %s: %v", k, err)
|
||||||
hasError = true
|
|
||||||
} else if !reflect.DeepEqual(expectedValue, fmt.Sprintf("%v", actualValue)) {
|
} else if !reflect.DeepEqual(expectedValue, fmt.Sprintf("%v", actualValue)) {
|
||||||
hasError = true
|
|
||||||
t.Errorf("Unexpected value for %v: expected %v, got %v", k, expectedValue, actualValue)
|
t.Errorf("Unexpected value for %v: expected %v, got %v", k, expectedValue, actualValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,14 +84,17 @@ func TestCompatibility(
|
|||||||
actualValue, ok, err := getJSONValue(generic, keys...)
|
actualValue, ok, err := getJSONValue(generic, keys...)
|
||||||
if err == nil || ok {
|
if err == nil || ok {
|
||||||
t.Errorf("Unexpected value found for key %s: %v", absentKey, actualValue)
|
t.Errorf("Unexpected value found for key %s: %v", absentKey, actualValue)
|
||||||
hasError = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if hasError {
|
if t.Failed() {
|
||||||
printer := &printers.JSONPrinter{}
|
data, err := json.MarshalIndent(obj, "", " ")
|
||||||
printer.PrintObj(obj, os.Stdout)
|
if err != nil {
|
||||||
t.Logf("2: Encoded value: %#v", string(output))
|
t.Log(err)
|
||||||
|
} else {
|
||||||
|
t.Log(string(data))
|
||||||
|
}
|
||||||
|
t.Logf("2: Encoded value: %v", string(output))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user