mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Fix bug in ignoring untypes conversions
This commit is contained in:
parent
7ab3e436f7
commit
bcaab8c1a2
@ -55,6 +55,7 @@ type Converter struct {
|
|||||||
|
|
||||||
// Set of conversions that should be treated as a no-op
|
// Set of conversions that should be treated as a no-op
|
||||||
ignoredConversions map[typePair]struct{}
|
ignoredConversions map[typePair]struct{}
|
||||||
|
ignoredUntypedConversions map[typePair]struct{}
|
||||||
|
|
||||||
// This is a map from a source field type and name, to a list of destination
|
// This is a map from a source field type and name, to a list of destination
|
||||||
// field type and name.
|
// field type and name.
|
||||||
@ -86,6 +87,7 @@ func NewConverter(nameFn NameFunc) *Converter {
|
|||||||
conversionFuncs: NewConversionFuncs(),
|
conversionFuncs: NewConversionFuncs(),
|
||||||
generatedConversionFuncs: NewConversionFuncs(),
|
generatedConversionFuncs: NewConversionFuncs(),
|
||||||
ignoredConversions: make(map[typePair]struct{}),
|
ignoredConversions: make(map[typePair]struct{}),
|
||||||
|
ignoredUntypedConversions: make(map[typePair]struct{}),
|
||||||
nameFunc: nameFn,
|
nameFunc: nameFn,
|
||||||
structFieldDests: make(map[typeNamePair][]typeNamePair),
|
structFieldDests: make(map[typeNamePair][]typeNamePair),
|
||||||
structFieldSources: make(map[typeNamePair][]typeNamePair),
|
structFieldSources: make(map[typeNamePair][]typeNamePair),
|
||||||
@ -377,6 +379,7 @@ func (c *Converter) RegisterIgnoredConversion(from, to interface{}) error {
|
|||||||
return fmt.Errorf("expected pointer arg for 'to' param 1, got: %v", typeTo)
|
return fmt.Errorf("expected pointer arg for 'to' param 1, got: %v", typeTo)
|
||||||
}
|
}
|
||||||
c.ignoredConversions[typePair{typeFrom.Elem(), typeTo.Elem()}] = struct{}{}
|
c.ignoredConversions[typePair{typeFrom.Elem(), typeTo.Elem()}] = struct{}{}
|
||||||
|
c.ignoredUntypedConversions[typePair{typeFrom, typeTo}] = struct{}{}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,6 +462,11 @@ func (c *Converter) doConversion(src, dest interface{}, flags FieldMatchingFlags
|
|||||||
flags: flags,
|
flags: flags,
|
||||||
meta: meta,
|
meta: meta,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore conversions of this type
|
||||||
|
if _, ok := c.ignoredUntypedConversions[pair]; ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if fn, ok := c.conversionFuncs.untyped[pair]; ok {
|
if fn, ok := c.conversionFuncs.untyped[pair]; ok {
|
||||||
return fn(src, dest, scope)
|
return fn(src, dest, scope)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user