mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Deep copy should always use existing functions that are not ignored
While testing this fix in OpenShift it was discovered that the PackageConstraint was overly aggressive - types that declare a public copy function should always return true. PackageConstraint is intended to limit packages where we might generate deep copy function, rather than to prevent external packages from being consumed.
This commit is contained in:
parent
903a2db90a
commit
534075f828
@ -118,10 +118,12 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
// avoid having to make a reflection call.
|
||||
canInlineTypeFn := func(c *generator.Context, t *types.Type) bool {
|
||||
// types must be public structs or have a custom DeepCopy_<method> already defined
|
||||
if !copyableWithinPackage(t, explicitInputs.Has(t.Name.Package)) && !publicCopyFunctionDefined(c, t) {
|
||||
if publicCopyFunctionDefined(c, t) {
|
||||
return true
|
||||
}
|
||||
if !copyableWithinPackage(t, explicitInputs.Has(t.Name.Package)) {
|
||||
return false
|
||||
}
|
||||
|
||||
// only packages within the restricted range can be inlined
|
||||
for _, s := range restrictRange {
|
||||
if strings.HasPrefix(t.Name.Package, s) {
|
||||
|
Loading…
Reference in New Issue
Block a user