diff --git a/pkg/api/deep_copy_generated.go b/pkg/api/deep_copy_generated.go index e35bd074d02..d79771c730a 100644 --- a/pkg/api/deep_copy_generated.go +++ b/pkg/api/deep_copy_generated.go @@ -2268,8 +2268,6 @@ func deepCopy_resource_Quantity(in resource.Quantity, out *resource.Quantity, c if in.Amount != nil { if newVal, err := c.DeepCopy(in.Amount); err != nil { return err - } else if newVal == nil { - out.Amount = nil } else { out.Amount = newVal.(*inf.Dec) } diff --git a/pkg/api/v1/deep_copy_generated.go b/pkg/api/v1/deep_copy_generated.go index 357bbefd307..248b7fbc424 100644 --- a/pkg/api/v1/deep_copy_generated.go +++ b/pkg/api/v1/deep_copy_generated.go @@ -34,8 +34,6 @@ func deepCopy_resource_Quantity(in resource.Quantity, out *resource.Quantity, c if in.Amount != nil { if newVal, err := c.DeepCopy(in.Amount); err != nil { return err - } else if newVal == nil { - out.Amount = nil } else { out.Amount = newVal.(*inf.Dec) } diff --git a/pkg/apis/extensions/deep_copy_generated.go b/pkg/apis/extensions/deep_copy_generated.go index 1716049c2b7..fa2985aa7e4 100644 --- a/pkg/apis/extensions/deep_copy_generated.go +++ b/pkg/apis/extensions/deep_copy_generated.go @@ -810,8 +810,6 @@ func deepCopy_resource_Quantity(in resource.Quantity, out *resource.Quantity, c if in.Amount != nil { if newVal, err := c.DeepCopy(in.Amount); err != nil { return err - } else if newVal == nil { - out.Amount = nil } else { out.Amount = newVal.(*inf.Dec) } diff --git a/pkg/apis/extensions/v1beta1/deep_copy_generated.go b/pkg/apis/extensions/v1beta1/deep_copy_generated.go index 51f28684578..9deb6b33925 100644 --- a/pkg/apis/extensions/v1beta1/deep_copy_generated.go +++ b/pkg/apis/extensions/v1beta1/deep_copy_generated.go @@ -34,8 +34,6 @@ func deepCopy_resource_Quantity(in resource.Quantity, out *resource.Quantity, c if in.Amount != nil { if newVal, err := c.DeepCopy(in.Amount); err != nil { return err - } else if newVal == nil { - out.Amount = nil } else { out.Amount = newVal.(*inf.Dec) } diff --git a/pkg/runtime/deep_copy_generator.go b/pkg/runtime/deep_copy_generator.go index 5dee4e263ab..38fb54f5c47 100644 --- a/pkg/runtime/deep_copy_generator.go +++ b/pkg/runtime/deep_copy_generator.go @@ -403,7 +403,8 @@ func (g *deepCopyGenerator) writeDeepCopyForPtr(b *buffer, inField reflect.Struc ifStmt := fmt.Sprintf(ifFormat, inField.Name) b.addLine(ifStmt, indent) - switch inField.Type.Elem().Kind() { + kind := inField.Type.Elem().Kind() + switch kind { case reflect.Map, reflect.Ptr, reflect.Slice, reflect.Interface, reflect.Struct: if _, found := g.copyables[inField.Type.Elem()]; found { newFormat := "out.%s = new(%s)\n" @@ -420,8 +421,10 @@ func (g *deepCopyGenerator) writeDeepCopyForPtr(b *buffer, inField reflect.Struc ifStmt := fmt.Sprintf(ifFormat, inField.Name) b.addLine(ifStmt, indent+1) b.addLine("return err\n", indent+2) - b.addLine("} else if newVal == nil {\n", indent+1) - b.addLine(fmt.Sprintf("out.%s = nil\n", inField.Name), indent+2) + if kind != reflect.Struct { + b.addLine("} else if newVal == nil {\n", indent+1) + b.addLine(fmt.Sprintf("out.%s = nil\n", inField.Name), indent+2) + } b.addLine("} else {\n", indent+1) assignFormat := "out.%s = newVal.(%s)\n" assignStmt := fmt.Sprintf(assignFormat, inField.Name, g.typeName(inField.Type)) @@ -455,7 +458,8 @@ func (g *deepCopyGenerator) writeDeepCopyForSlice(b *buffer, inField reflect.Str forStmt := fmt.Sprintf(forFormat, inField.Name) b.addLine(forStmt, indent+1) - switch inField.Type.Elem().Kind() { + kind := inField.Type.Elem().Kind() + switch kind { case reflect.Map, reflect.Ptr, reflect.Slice, reflect.Interface, reflect.Struct: if _, found := g.copyables[inField.Type.Elem()]; found { assignFormat := "if err := %s(in.%s[i], &out.%s[i], c); err != nil {\n" @@ -469,8 +473,10 @@ func (g *deepCopyGenerator) writeDeepCopyForSlice(b *buffer, inField reflect.Str ifStmt := fmt.Sprintf(ifFormat, inField.Name) b.addLine(ifStmt, indent+2) b.addLine("return err\n", indent+3) - b.addLine("} else if newVal == nil {\n", indent+2) - b.addLine(fmt.Sprintf("out.%s[i] = nil\n", inField.Name), indent+3) + if kind != reflect.Struct { + b.addLine("} else if newVal == nil {\n", indent+2) + b.addLine(fmt.Sprintf("out.%s[i] = nil\n", inField.Name), indent+3) + } b.addLine("} else {\n", indent+2) assignFormat := "out.%s[i] = newVal.(%s)\n" assignStmt := fmt.Sprintf(assignFormat, inField.Name, g.typeName(inField.Type.Elem()))