From 9997683ba20495ea508c7b9a3b09ec94429b88df Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Tue, 21 Feb 2023 13:06:38 -0500 Subject: [PATCH] Use custom-defined type generators for slice elements in compatibility objects --- .../apimachinery/pkg/api/apitesting/roundtrip/construct.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/construct.go b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/construct.go index 705839f54d3..4ca7f6c5a0b 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/construct.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/apitesting/roundtrip/construct.go @@ -110,7 +110,11 @@ func fill(dataString string, dataInt int, t reflect.Type, v reflect.Value, fillF // populate with a single-item slice v.Set(reflect.MakeSlice(t, 1, 1)) // recurse to populate the item, preserving the data context - fill(dataString, dataInt, t.Elem(), v.Index(0), fillFuncs, filledTypes) + if t.Elem().Kind() == reflect.Pointer { + fill(dataString, dataInt, t.Elem(), v.Index(0), fillFuncs, filledTypes) + } else { + fill(dataString, dataInt, reflect.PointerTo(t.Elem()), v.Index(0).Addr(), fillFuncs, filledTypes) + } case reflect.Map: // construct the key, which must be a string type, possibly converted to a type alias of string