mirror of https://github.com/k3s-io/k3s
Add a Log method on Scheme for better debugging
parent
f9e5477e2b
commit
305db35422
|
@ -146,6 +146,20 @@ func runTest(t *testing.T, codec runtime.Codec, source runtime.Object) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For debugging problems
|
||||||
|
func TestSpecificKind(t *testing.T) {
|
||||||
|
api.Scheme.Log(t)
|
||||||
|
kind := "PodList"
|
||||||
|
item, err := api.Scheme.New("", kind)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Couldn't make a %v? %v", kind, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
runTest(t, v1beta1.Codec, item)
|
||||||
|
runTest(t, v1beta2.Codec, item)
|
||||||
|
api.Scheme.Log(nil)
|
||||||
|
}
|
||||||
|
|
||||||
func TestTypes(t *testing.T) {
|
func TestTypes(t *testing.T) {
|
||||||
for kind := range api.Scheme.KnownTypes("") {
|
for kind := range api.Scheme.KnownTypes("") {
|
||||||
// Try a few times, since runTest uses random values.
|
// Try a few times, since runTest uses random values.
|
||||||
|
|
|
@ -86,6 +86,11 @@ func NewScheme() *Scheme {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log sets a logger on the scheme. For test purposes only
|
||||||
|
func (s *Scheme) Log(l DebugLogger) {
|
||||||
|
s.converter.Debug = l
|
||||||
|
}
|
||||||
|
|
||||||
// nameFunc returns the name of the type that we wish to use for encoding. Defaults to
|
// nameFunc returns the name of the type that we wish to use for encoding. Defaults to
|
||||||
// the go name of the type if the type is not registered.
|
// the go name of the type if the type is not registered.
|
||||||
func (s *Scheme) nameFunc(t reflect.Type) string {
|
func (s *Scheme) nameFunc(t reflect.Type) string {
|
||||||
|
|
|
@ -219,6 +219,11 @@ func (s *Scheme) New(versionName, typeName string) (Object, error) {
|
||||||
return obj.(Object), nil
|
return obj.(Object), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log sets a logger on the scheme. For test purposes only
|
||||||
|
func (s *Scheme) Log(l conversion.DebugLogger) {
|
||||||
|
s.raw.Log(l)
|
||||||
|
}
|
||||||
|
|
||||||
// AddConversionFuncs adds a function to the list of conversion functions. The given
|
// AddConversionFuncs adds a function to the list of conversion functions. The given
|
||||||
// function should know how to convert between two API objects. We deduce how to call
|
// function should know how to convert between two API objects. We deduce how to call
|
||||||
// it from the types of its two parameters; see the comment for Converter.Register.
|
// it from the types of its two parameters; see the comment for Converter.Register.
|
||||||
|
|
Loading…
Reference in New Issue