Merge pull request #26179 from smarterclayton/fix_deep_copy

Automatic merge from submit-queue

DeepCopy should generate types within k8s.io/kubernetes

Take an incremental step to control which types get DeepCopy generated.

Fixes #26036, #24667

@thockin @wojtek-t @lavalamp
This commit is contained in:
k8s-merge-robot 2016-06-08 08:06:13 -07:00
commit e7fa88f6bc
21 changed files with 146 additions and 671 deletions

View File

@ -97,6 +97,7 @@ func (g *GeneratorArgs) NewBuilder() (*parser.Builder, error) {
b.AddBuildTags("ignore_autogenerated") b.AddBuildTags("ignore_autogenerated")
for _, d := range g.InputDirs { for _, d := range g.InputDirs {
d = strings.TrimLeft(d, "+-*")
if g.Recursive { if g.Recursive {
if err := b.AddDirRecursive(d); err != nil { if err := b.AddDirRecursive(d); err != nil {
return nil, fmt.Errorf("unable to add directory %q: %v", d, err) return nil, fmt.Errorf("unable to add directory %q: %v", d, err)

View File

@ -19,6 +19,7 @@ package generators
import ( import (
"fmt" "fmt"
"io" "io"
"path"
"path/filepath" "path/filepath"
"strings" "strings"
@ -31,6 +32,15 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
) )
// Constraints is a set of optional limitations on what deep copy will generate.
type Constraints struct {
// PackageConstraints is an optional set of package prefixes that constrain which types
// will have inline deep copy methods generated for. Any type outside of these packages
// (if specified) will not have a function generated and will result in a call to the
// cloner.DeepCopy method.
PackageConstraints []string
}
// TODO: This is created only to reduce number of changes in a single PR. // TODO: This is created only to reduce number of changes in a single PR.
// Remove it and use PublicNamer instead. // Remove it and use PublicNamer instead.
func deepCopyNamer() *namer.NameStrategy { func deepCopyNamer() *namer.NameStrategy {
@ -62,7 +72,32 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
glog.Fatalf("Failed loading boilerplate: %v", err) glog.Fatalf("Failed loading boilerplate: %v", err)
} }
inputs := sets.NewString(arguments.InputDirs...) initInputs := sets.NewString()
explicitInputs := sets.NewString()
inputs := sets.NewString()
for _, s := range arguments.InputDirs {
switch {
case strings.HasPrefix(s, "+"):
// packages with '+' prefix get functions generated for everything except gencopy=false, but
// no init function
s = strings.TrimPrefix(s, "+")
inputs.Insert(s)
case strings.HasPrefix(s, "-"):
// packages with '-' prefix only get functions generated for those with gencopy=true
s = strings.TrimPrefix(s, "-")
inputs.Insert(s)
explicitInputs.Insert(s)
default:
inputs.Insert(s)
initInputs.Insert(s)
}
}
var restrictRange []string
if c, ok := arguments.CustomArgs.(Constraints); ok {
restrictRange = c.PackageConstraints
}
packages := generator.Packages{} packages := generator.Packages{}
header := append([]byte( header := append([]byte(
`// +build !ignore_autogenerated `// +build !ignore_autogenerated
@ -76,11 +111,29 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
for _, p := range context.Universe { for _, p := range context.Universe {
copyableType := false copyableType := false
for _, t := range p.Types { for _, t := range p.Types {
if copyableWithinPackage(t) && inputs.Has(t.Name.Package) { if copyableWithinPackage(t, explicitInputs.Has(t.Name.Package)) && inputs.Has(t.Name.Package) {
copyableType = true copyableType = true
} }
} }
if copyableType { if copyableType {
// TODO: replace this with a more sophisticated algorithm that generates private copy methods
// (like auto_DeepCopy_...) for any type that is outside of the PackageConstraints. That would
// 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) {
return false
}
// only packages within the restricted range can be inlined
for _, s := range restrictRange {
if strings.HasPrefix(t.Name.Package, s) {
return true
}
}
return false
}
path := p.Path path := p.Path
packages = append(packages, packages = append(packages,
&generator.DefaultPackage{ &generator.DefaultPackage{
@ -90,7 +143,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) { GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
generators = []generator.Generator{} generators = []generator.Generator{}
generators = append( generators = append(
generators, NewGenDeepCopy("deep_copy_generated", path, inputs.Has(path))) generators, NewGenDeepCopy("deep_copy_generated", path, initInputs.Has(path), explicitInputs.Has(path), canInlineTypeFn))
return generators return generators
}, },
FilterFunc: func(c *generator.Context, t *types.Type) bool { FilterFunc: func(c *generator.Context, t *types.Type) bool {
@ -102,6 +155,9 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
return packages return packages
} }
// CanInlineTypeFunc should return true if the provided type can be converted to a function call
type CanInlineTypeFunc func(*generator.Context, *types.Type) bool
const ( const (
apiPackagePath = "k8s.io/kubernetes/pkg/api" apiPackagePath = "k8s.io/kubernetes/pkg/api"
conversionPackagePath = "k8s.io/kubernetes/pkg/conversion" conversionPackagePath = "k8s.io/kubernetes/pkg/conversion"
@ -110,15 +166,20 @@ const (
// genDeepCopy produces a file with autogenerated deep-copy functions. // genDeepCopy produces a file with autogenerated deep-copy functions.
type genDeepCopy struct { type genDeepCopy struct {
generator.DefaultGen generator.DefaultGen
targetPackage string targetPackage string
imports namer.ImportTracker imports namer.ImportTracker
typesForInit []*types.Type typesForInit []*types.Type
generateInitFunc bool generateInitFunc bool
requireExplicitTag bool
canInlineTypeFn CanInlineTypeFunc
context *generator.Context
globalVariables map[string]interface{} globalVariables map[string]interface{}
} }
func NewGenDeepCopy(sanitizedName, targetPackage string, generateInitFunc bool) generator.Generator { func NewGenDeepCopy(sanitizedName, targetPackage string, generateInitFunc, requireExplicitTag bool, canInlineTypeFn CanInlineTypeFunc) generator.Generator {
return &genDeepCopy{ return &genDeepCopy{
DefaultGen: generator.DefaultGen{ DefaultGen: generator.DefaultGen{
OptionalName: sanitizedName, OptionalName: sanitizedName,
@ -127,6 +188,8 @@ func NewGenDeepCopy(sanitizedName, targetPackage string, generateInitFunc bool)
imports: generator.NewImportTracker(), imports: generator.NewImportTracker(),
typesForInit: make([]*types.Type, 0), typesForInit: make([]*types.Type, 0),
generateInitFunc: generateInitFunc, generateInitFunc: generateInitFunc,
requireExplicitTag: requireExplicitTag,
canInlineTypeFn: canInlineTypeFn,
} }
} }
@ -137,15 +200,29 @@ func (g *genDeepCopy) Namers(c *generator.Context) namer.NameSystems {
func (g *genDeepCopy) Filter(c *generator.Context, t *types.Type) bool { func (g *genDeepCopy) Filter(c *generator.Context, t *types.Type) bool {
// Filter out all types not copyable within the package. // Filter out all types not copyable within the package.
copyable := copyableWithinPackage(t) copyable := copyableWithinPackage(t, g.requireExplicitTag)
if copyable { if copyable {
g.typesForInit = append(g.typesForInit, t) g.typesForInit = append(g.typesForInit, t)
} }
return copyable return copyable
} }
func copyableWithinPackage(t *types.Type) bool { // publicCopyFunctionDefined returns true if a DeepCopy function has already been defined in a given
if types.ExtractCommentTags("+", t.CommentLines)["gencopy"] == "false" { // package, which allows more efficient deep copy implementations to be defined by the caller.
func publicCopyFunctionDefined(c *generator.Context, t *types.Type) bool {
p, ok := c.Universe[t.Name.Package]
if !ok {
return false
}
return p.Functions["DeepCopy_"+path.Base(t.Name.Package)+"_"+t.Name.Name] != nil
}
func copyableWithinPackage(t *types.Type, explicitCopyRequired bool) bool {
tag := types.ExtractCommentTags("+", t.CommentLines)["gencopy"]
if tag == "false" {
return false
}
if explicitCopyRequired && tag != "true" {
return false return false
} }
// TODO: Consider generating functions for other kinds too. // TODO: Consider generating functions for other kinds too.
@ -204,6 +281,7 @@ func (g *genDeepCopy) funcNameTmpl(t *types.Type) string {
} }
func (g *genDeepCopy) Init(c *generator.Context, w io.Writer) error { func (g *genDeepCopy) Init(c *generator.Context, w io.Writer) error {
g.context = c
cloner := c.Universe.Type(types.Name{Package: conversionPackagePath, Name: "Cloner"}) cloner := c.Universe.Type(types.Name{Package: conversionPackagePath, Name: "Cloner"})
g.imports.AddType(cloner) g.imports.AddType(cloner)
g.globalVariables = map[string]interface{}{ g.globalVariables = map[string]interface{}{
@ -282,7 +360,7 @@ func (g *genDeepCopy) doMap(t *types.Type, sw *generator.SnippetWriter) {
if t.Elem.IsAssignable() { if t.Elem.IsAssignable() {
sw.Do("(*out)[key] = val\n", nil) sw.Do("(*out)[key] = val\n", nil)
} else { } else {
if copyableWithinPackage(t.Elem) { if g.canInlineTypeFn(g.context, t.Elem) {
sw.Do("newVal := new($.|raw$)\n", t.Elem) sw.Do("newVal := new($.|raw$)\n", t.Elem)
funcName := g.funcNameTmpl(t.Elem) funcName := g.funcNameTmpl(t.Elem)
sw.Do(fmt.Sprintf("if err := %s(val, newVal, c); err != nil {\n", funcName), argsFromType(t.Elem)) sw.Do(fmt.Sprintf("if err := %s(val, newVal, c); err != nil {\n", funcName), argsFromType(t.Elem))
@ -313,7 +391,7 @@ func (g *genDeepCopy) doSlice(t *types.Type, sw *generator.SnippetWriter) {
sw.Do("for i := range in {\n", nil) sw.Do("for i := range in {\n", nil)
if t.Elem.IsAssignable() { if t.Elem.IsAssignable() {
sw.Do("(*out)[i] = in[i]\n", nil) sw.Do("(*out)[i] = in[i]\n", nil)
} else if copyableWithinPackage(t.Elem) { } else if g.canInlineTypeFn(g.context, t.Elem) {
funcName := g.funcNameTmpl(t.Elem) funcName := g.funcNameTmpl(t.Elem)
sw.Do(fmt.Sprintf("if err := %s(in[i], &(*out)[i], c); err != nil {\n", funcName), argsFromType(t.Elem)) sw.Do(fmt.Sprintf("if err := %s(in[i], &(*out)[i], c); err != nil {\n", funcName), argsFromType(t.Elem))
sw.Do("return err\n", nil) sw.Do("return err\n", nil)
@ -346,7 +424,7 @@ func (g *genDeepCopy) doStruct(t *types.Type, sw *generator.SnippetWriter) {
sw.Do("out.$.name$ = nil\n", args) sw.Do("out.$.name$ = nil\n", args)
sw.Do("}\n", nil) sw.Do("}\n", nil)
case types.Struct: case types.Struct:
if copyableWithinPackage(m.Type) { if g.canInlineTypeFn(g.context, m.Type) {
funcName := g.funcNameTmpl(m.Type) funcName := g.funcNameTmpl(m.Type)
sw.Do(fmt.Sprintf("if err := %s(in.$.name$, &out.$.name$, c); err != nil {\n", funcName), args) sw.Do(fmt.Sprintf("if err := %s(in.$.name$, &out.$.name$, c); err != nil {\n", funcName), args)
sw.Do("return err\n", nil) sw.Do("return err\n", nil)
@ -381,9 +459,9 @@ func (g *genDeepCopy) doInterface(t *types.Type, sw *generator.SnippetWriter) {
func (g *genDeepCopy) doPointer(t *types.Type, sw *generator.SnippetWriter) { func (g *genDeepCopy) doPointer(t *types.Type, sw *generator.SnippetWriter) {
sw.Do("*out = new($.Elem|raw$)\n", t) sw.Do("*out = new($.Elem|raw$)\n", t)
if t.Elem.Kind == types.Builtin { if t.Elem.IsAssignable() {
sw.Do("**out = *in", nil) sw.Do("**out = *in", nil)
} else if copyableWithinPackage(t.Elem) { } else if g.canInlineTypeFn(g.context, t.Elem) {
funcName := g.funcNameTmpl(t.Elem) funcName := g.funcNameTmpl(t.Elem)
sw.Do(fmt.Sprintf("if err := %s(*in, *out, c); err != nil {\n", funcName), argsFromType(t.Elem)) sw.Do(fmt.Sprintf("if err := %s(*in, *out, c); err != nil {\n", funcName), argsFromType(t.Elem))
sw.Do("return err\n", nil) sw.Do("return err\n", nil)

View File

@ -31,6 +31,11 @@ import (
func main() { func main() {
arguments := args.Default() arguments := args.Default()
arguments.CustomArgs = generators.Constraints{
// Types outside of this package will be inlined.
PackageConstraints: []string{"k8s.io/kubernetes/"},
}
// Override defaults. These are Kubernetes specific input locations. // Override defaults. These are Kubernetes specific input locations.
arguments.InputDirs = []string{ arguments.InputDirs = []string{
"k8s.io/kubernetes/pkg/api", "k8s.io/kubernetes/pkg/api",
@ -56,6 +61,19 @@ func main() {
"k8s.io/kubernetes/pkg/apis/rbac/v1alpha1", "k8s.io/kubernetes/pkg/apis/rbac/v1alpha1",
"k8s.io/kubernetes/federation/apis/federation", "k8s.io/kubernetes/federation/apis/federation",
"k8s.io/kubernetes/federation/apis/federation/v1alpha1", "k8s.io/kubernetes/federation/apis/federation/v1alpha1",
// generate all types, but do not register them
"+k8s.io/kubernetes/pkg/api/unversioned",
"-k8s.io/kubernetes/pkg/api/meta",
"-k8s.io/kubernetes/pkg/api/meta/metatypes",
"-k8s.io/kubernetes/pkg/api/resource",
"-k8s.io/kubernetes/pkg/conversion",
"-k8s.io/kubernetes/pkg/labels",
"-k8s.io/kubernetes/pkg/runtime",
"-k8s.io/kubernetes/pkg/runtime/serializer",
"-k8s.io/kubernetes/pkg/util/intstr",
"-k8s.io/kubernetes/pkg/util/sets",
} }
if err := arguments.Execute( if err := arguments.Execute(

View File

@ -2480,11 +2480,7 @@ func DeepCopy_api_Preconditions(in Preconditions, out *Preconditions, c *convers
if in.UID != nil { if in.UID != nil {
in, out := in.UID, &out.UID in, out := in.UID, &out.UID
*out = new(types.UID) *out = new(types.UID)
if newVal, err := c.DeepCopy(*in); err != nil { **out = *in
return err
} else {
**out = newVal.(types.UID)
}
} else { } else {
out.UID = nil out.UID = nil
} }

View File

@ -1,154 +0,0 @@
// +build !ignore_autogenerated
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package meta
import (
unversioned "k8s.io/kubernetes/pkg/api/unversioned"
conversion "k8s.io/kubernetes/pkg/conversion"
runtime "k8s.io/kubernetes/pkg/runtime"
)
func DeepCopy_meta_DefaultRESTMapper(in DefaultRESTMapper, out *DefaultRESTMapper, c *conversion.Cloner) error {
if in.defaultGroupVersions != nil {
in, out := in.defaultGroupVersions, &out.defaultGroupVersions
*out = make([]unversioned.GroupVersion, len(in))
for i := range in {
if err := unversioned.DeepCopy_unversioned_GroupVersion(in[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.defaultGroupVersions = nil
}
if in.resourceToKind != nil {
in, out := in.resourceToKind, &out.resourceToKind
*out = make(map[unversioned.GroupVersionResource]unversioned.GroupVersionKind)
for range in {
// FIXME: Copying unassignable keys unsupported unversioned.GroupVersionResource
}
} else {
out.resourceToKind = nil
}
if in.kindToPluralResource != nil {
in, out := in.kindToPluralResource, &out.kindToPluralResource
*out = make(map[unversioned.GroupVersionKind]unversioned.GroupVersionResource)
for range in {
// FIXME: Copying unassignable keys unsupported unversioned.GroupVersionKind
}
} else {
out.kindToPluralResource = nil
}
if in.kindToScope != nil {
in, out := in.kindToScope, &out.kindToScope
*out = make(map[unversioned.GroupVersionKind]RESTScope)
for range in {
// FIXME: Copying unassignable keys unsupported unversioned.GroupVersionKind
}
} else {
out.kindToScope = nil
}
if in.singularToPlural != nil {
in, out := in.singularToPlural, &out.singularToPlural
*out = make(map[unversioned.GroupVersionResource]unversioned.GroupVersionResource)
for range in {
// FIXME: Copying unassignable keys unsupported unversioned.GroupVersionResource
}
} else {
out.singularToPlural = nil
}
if in.pluralToSingular != nil {
in, out := in.pluralToSingular, &out.pluralToSingular
*out = make(map[unversioned.GroupVersionResource]unversioned.GroupVersionResource)
for range in {
// FIXME: Copying unassignable keys unsupported unversioned.GroupVersionResource
}
} else {
out.pluralToSingular = nil
}
if in.interfacesFunc == nil {
out.interfacesFunc = nil
} else if newVal, err := c.DeepCopy(in.interfacesFunc); err != nil {
return err
} else {
out.interfacesFunc = newVal.(VersionInterfacesFunc)
}
if in.aliasToResource != nil {
in, out := in.aliasToResource, &out.aliasToResource
*out = make(map[string][]string)
for key, val := range in {
if newVal, err := c.DeepCopy(val); err != nil {
return err
} else {
(*out)[key] = newVal.([]string)
}
}
} else {
out.aliasToResource = nil
}
return nil
}
func DeepCopy_meta_RESTMapping(in RESTMapping, out *RESTMapping, c *conversion.Cloner) error {
out.Resource = in.Resource
if err := unversioned.DeepCopy_unversioned_GroupVersionKind(in.GroupVersionKind, &out.GroupVersionKind, c); err != nil {
return err
}
if in.Scope == nil {
out.Scope = nil
} else if newVal, err := c.DeepCopy(in.Scope); err != nil {
return err
} else {
out.Scope = newVal.(RESTScope)
}
if in.ObjectConvertor == nil {
out.ObjectConvertor = nil
} else if newVal, err := c.DeepCopy(in.ObjectConvertor); err != nil {
return err
} else {
out.ObjectConvertor = newVal.(runtime.ObjectConvertor)
}
if in.MetadataAccessor == nil {
out.MetadataAccessor = nil
} else if newVal, err := c.DeepCopy(in.MetadataAccessor); err != nil {
return err
} else {
out.MetadataAccessor = newVal.(MetadataAccessor)
}
return nil
}
func DeepCopy_meta_VersionInterfaces(in VersionInterfaces, out *VersionInterfaces, c *conversion.Cloner) error {
if in.ObjectConvertor == nil {
out.ObjectConvertor = nil
} else if newVal, err := c.DeepCopy(in.ObjectConvertor); err != nil {
return err
} else {
out.ObjectConvertor = newVal.(runtime.ObjectConvertor)
}
if in.MetadataAccessor == nil {
out.MetadataAccessor = nil
} else if newVal, err := c.DeepCopy(in.MetadataAccessor); err != nil {
return err
} else {
out.MetadataAccessor = newVal.(MetadataAccessor)
}
return nil
}

View File

@ -1,37 +0,0 @@
// +build !ignore_autogenerated
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package metatypes
import (
conversion "k8s.io/kubernetes/pkg/conversion"
)
func DeepCopy_metatypes_OwnerReference(in OwnerReference, out *OwnerReference, c *conversion.Cloner) error {
out.APIVersion = in.APIVersion
out.Kind = in.Kind
out.UID = in.UID
out.Name = in.Name
if in.Controller != nil {
value := *in.Controller
out.Controller = &value
}
return nil
}

View File

@ -83,6 +83,7 @@ option go_package = "resource";
// writing some sort of special handling code in the hopes that that will // writing some sort of special handling code in the hopes that that will
// cause implementors to also use a fixed point implementation. // cause implementors to also use a fixed point implementation.
// //
// +gencopy=false
// +protobuf=true // +protobuf=true
// +protobuf.embed=string // +protobuf.embed=string
// +protobuf.options.marshal=false // +protobuf.options.marshal=false

View File

@ -87,6 +87,7 @@ import (
// writing some sort of special handling code in the hopes that that will // writing some sort of special handling code in the hopes that that will
// cause implementors to also use a fixed point implementation. // cause implementors to also use a fixed point implementation.
// //
// +gencopy=false
// +protobuf=true // +protobuf=true
// +protobuf.embed=string // +protobuf.embed=string
// +protobuf.options.marshal=false // +protobuf.options.marshal=false

View File

@ -21,9 +21,8 @@ limitations under the License.
package unversioned package unversioned
import ( import (
"time"
conversion "k8s.io/kubernetes/pkg/conversion" conversion "k8s.io/kubernetes/pkg/conversion"
time "time"
) )
func DeepCopy_unversioned_APIGroup(in APIGroup, out *APIGroup, c *conversion.Cloner) error { func DeepCopy_unversioned_APIGroup(in APIGroup, out *APIGroup, c *conversion.Cloner) error {

View File

@ -2428,11 +2428,7 @@ func DeepCopy_v1_Preconditions(in Preconditions, out *Preconditions, c *conversi
if in.UID != nil { if in.UID != nil {
in, out := in.UID, &out.UID in, out := in.UID, &out.UID
*out = new(types.UID) *out = new(types.UID)
if newVal, err := c.DeepCopy(*in); err != nil { **out = *in
return err
} else {
**out = newVal.(types.UID)
}
} else { } else {
out.UID = nil out.UID = nil
} }

View File

@ -576,11 +576,7 @@ func DeepCopy_extensions_NetworkPolicyPort(in NetworkPolicyPort, out *NetworkPol
if in.Protocol != nil { if in.Protocol != nil {
in, out := in.Protocol, &out.Protocol in, out := in.Protocol, &out.Protocol
*out = new(api.Protocol) *out = new(api.Protocol)
if newVal, err := c.DeepCopy(*in); err != nil { **out = *in
return err
} else {
**out = newVal.(api.Protocol)
}
} else { } else {
out.Protocol = nil out.Protocol = nil
} }

View File

@ -888,11 +888,7 @@ func DeepCopy_v1beta1_NetworkPolicyPort(in NetworkPolicyPort, out *NetworkPolicy
if in.Protocol != nil { if in.Protocol != nil {
in, out := in.Protocol, &out.Protocol in, out := in.Protocol, &out.Protocol
*out = new(v1.Protocol) *out = new(v1.Protocol)
if newVal, err := c.DeepCopy(*in); err != nil { **out = *in
return err
} else {
**out = newVal.(v1.Protocol)
}
} else { } else {
out.Protocol = nil out.Protocol = nil
} }

View File

@ -1,185 +0,0 @@
// +build !ignore_autogenerated
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package conversion
import (
forked_reflect "k8s.io/kubernetes/third_party/forked/reflect"
reflect "reflect"
)
func DeepCopy_conversion_Cloner(in Cloner, out *Cloner, c *Cloner) error {
if in.deepCopyFuncs != nil {
in, out := in.deepCopyFuncs, &out.deepCopyFuncs
*out = make(map[reflect.Type]reflect.Value)
for range in {
// FIXME: Copying unassignable keys unsupported reflect.Type
}
} else {
out.deepCopyFuncs = nil
}
if in.generatedDeepCopyFuncs != nil {
in, out := in.generatedDeepCopyFuncs, &out.generatedDeepCopyFuncs
*out = make(map[reflect.Type]reflect.Value)
for range in {
// FIXME: Copying unassignable keys unsupported reflect.Type
}
} else {
out.generatedDeepCopyFuncs = nil
}
return nil
}
func DeepCopy_conversion_ConversionFuncs(in ConversionFuncs, out *ConversionFuncs, c *Cloner) error {
if in.fns != nil {
in, out := in.fns, &out.fns
*out = make(map[typePair]reflect.Value)
for range in {
// FIXME: Copying unassignable keys unsupported typePair
}
} else {
out.fns = nil
}
return nil
}
func DeepCopy_conversion_Converter(in Converter, out *Converter, c *Cloner) error {
if err := DeepCopy_conversion_ConversionFuncs(in.conversionFuncs, &out.conversionFuncs, c); err != nil {
return err
}
if err := DeepCopy_conversion_ConversionFuncs(in.generatedConversionFuncs, &out.generatedConversionFuncs, c); err != nil {
return err
}
if in.genericConversions != nil {
in, out := in.genericConversions, &out.genericConversions
*out = make([]GenericConversionFunc, len(in))
for i := range in {
if newVal, err := c.DeepCopy(in[i]); err != nil {
return err
} else {
(*out)[i] = newVal.(GenericConversionFunc)
}
}
} else {
out.genericConversions = nil
}
if in.ignoredConversions != nil {
in, out := in.ignoredConversions, &out.ignoredConversions
*out = make(map[typePair]struct{})
for range in {
// FIXME: Copying unassignable keys unsupported typePair
}
} else {
out.ignoredConversions = nil
}
if in.structFieldDests != nil {
in, out := in.structFieldDests, &out.structFieldDests
*out = make(map[typeNamePair][]typeNamePair)
for range in {
// FIXME: Copying unassignable keys unsupported typeNamePair
}
} else {
out.structFieldDests = nil
}
if in.structFieldSources != nil {
in, out := in.structFieldSources, &out.structFieldSources
*out = make(map[typeNamePair][]typeNamePair)
for range in {
// FIXME: Copying unassignable keys unsupported typeNamePair
}
} else {
out.structFieldSources = nil
}
if in.defaultingFuncs != nil {
in, out := in.defaultingFuncs, &out.defaultingFuncs
*out = make(map[reflect.Type]reflect.Value)
for range in {
// FIXME: Copying unassignable keys unsupported reflect.Type
}
} else {
out.defaultingFuncs = nil
}
if in.defaultingInterfaces != nil {
in, out := in.defaultingInterfaces, &out.defaultingInterfaces
*out = make(map[reflect.Type]interface{})
for range in {
// FIXME: Copying unassignable keys unsupported reflect.Type
}
} else {
out.defaultingInterfaces = nil
}
if in.inputFieldMappingFuncs != nil {
in, out := in.inputFieldMappingFuncs, &out.inputFieldMappingFuncs
*out = make(map[reflect.Type]FieldMappingFunc)
for range in {
// FIXME: Copying unassignable keys unsupported reflect.Type
}
} else {
out.inputFieldMappingFuncs = nil
}
if in.inputDefaultFlags != nil {
in, out := in.inputDefaultFlags, &out.inputDefaultFlags
*out = make(map[reflect.Type]FieldMatchingFlags)
for range in {
// FIXME: Copying unassignable keys unsupported reflect.Type
}
} else {
out.inputDefaultFlags = nil
}
if in.Debug == nil {
out.Debug = nil
} else if newVal, err := c.DeepCopy(in.Debug); err != nil {
return err
} else {
out.Debug = newVal.(DebugLogger)
}
if in.nameFunc == nil {
out.nameFunc = nil
} else if newVal, err := c.DeepCopy(in.nameFunc); err != nil {
return err
} else {
out.nameFunc = newVal.(func(reflect.Type) string)
}
return nil
}
func DeepCopy_conversion_Equalities(in Equalities, out *Equalities, c *Cloner) error {
if in.Equalities != nil {
in, out := in.Equalities, &out.Equalities
*out = make(forked_reflect.Equalities)
for range in {
// FIXME: Copying unassignable keys unsupported reflect.Type
}
} else {
out.Equalities = nil
}
return nil
}
func DeepCopy_conversion_Meta(in Meta, out *Meta, c *Cloner) error {
if in.KeyNameMapping == nil {
out.KeyNameMapping = nil
} else if newVal, err := c.DeepCopy(in.KeyNameMapping); err != nil {
return err
} else {
out.KeyNameMapping = newVal.(FieldMappingFunc)
}
return nil
}

View File

@ -1,45 +0,0 @@
// +build !ignore_autogenerated
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package labels
import (
conversion "k8s.io/kubernetes/pkg/conversion"
sets "k8s.io/kubernetes/pkg/util/sets"
)
func DeepCopy_labels_Requirement(in Requirement, out *Requirement, c *conversion.Cloner) error {
out.key = in.key
out.operator = in.operator
if in.strValues != nil {
in, out := in.strValues, &out.strValues
*out = make(sets.String)
for key, val := range in {
newVal := new(sets.Empty)
if err := sets.DeepCopy_sets_Empty(val, newVal, c); err != nil {
return err
}
(*out)[key] = *newVal
}
} else {
out.strValues = nil
}
return nil
}

View File

@ -21,9 +21,7 @@ limitations under the License.
package runtime package runtime
import ( import (
unversioned "k8s.io/kubernetes/pkg/api/unversioned"
conversion "k8s.io/kubernetes/pkg/conversion" conversion "k8s.io/kubernetes/pkg/conversion"
reflect "reflect"
) )
func DeepCopy_runtime_RawExtension(in RawExtension, out *RawExtension, c *conversion.Cloner) error { func DeepCopy_runtime_RawExtension(in RawExtension, out *RawExtension, c *conversion.Cloner) error {
@ -44,107 +42,24 @@ func DeepCopy_runtime_RawExtension(in RawExtension, out *RawExtension, c *conver
return nil return nil
} }
func DeepCopy_runtime_Scheme(in Scheme, out *Scheme, c *conversion.Cloner) error { func DeepCopy_runtime_TypeMeta(in TypeMeta, out *TypeMeta, c *conversion.Cloner) error {
if in.gvkToType != nil { out.APIVersion = in.APIVersion
in, out := in.gvkToType, &out.gvkToType out.Kind = in.Kind
*out = make(map[unversioned.GroupVersionKind]reflect.Type)
for range in {
// FIXME: Copying unassignable keys unsupported unversioned.GroupVersionKind
}
} else {
out.gvkToType = nil
}
if in.typeToGVK != nil {
in, out := in.typeToGVK, &out.typeToGVK
*out = make(map[reflect.Type][]unversioned.GroupVersionKind)
for range in {
// FIXME: Copying unassignable keys unsupported reflect.Type
}
} else {
out.typeToGVK = nil
}
if in.unversionedTypes != nil {
in, out := in.unversionedTypes, &out.unversionedTypes
*out = make(map[reflect.Type]unversioned.GroupVersionKind)
for range in {
// FIXME: Copying unassignable keys unsupported reflect.Type
}
} else {
out.unversionedTypes = nil
}
if in.unversionedKinds != nil {
in, out := in.unversionedKinds, &out.unversionedKinds
*out = make(map[string]reflect.Type)
for key, val := range in {
if newVal, err := c.DeepCopy(val); err != nil {
return err
} else {
(*out)[key] = newVal.(reflect.Type)
}
}
} else {
out.unversionedKinds = nil
}
if in.fieldLabelConversionFuncs != nil {
in, out := in.fieldLabelConversionFuncs, &out.fieldLabelConversionFuncs
*out = make(map[string]map[string]FieldLabelConversionFunc)
for key, val := range in {
if newVal, err := c.DeepCopy(val); err != nil {
return err
} else {
(*out)[key] = newVal.(map[string]FieldLabelConversionFunc)
}
}
} else {
out.fieldLabelConversionFuncs = nil
}
if in.converter != nil {
in, out := in.converter, &out.converter
*out = new(conversion.Converter)
if err := conversion.DeepCopy_conversion_Converter(*in, *out, c); err != nil {
return err
}
} else {
out.converter = nil
}
if in.cloner != nil {
in, out := in.cloner, &out.cloner
*out = new(conversion.Cloner)
if err := conversion.DeepCopy_conversion_Cloner(*in, *out, c); err != nil {
return err
}
} else {
out.cloner = nil
}
return nil return nil
} }
func DeepCopy_runtime_SerializerInfo(in SerializerInfo, out *SerializerInfo, c *conversion.Cloner) error { func DeepCopy_runtime_Unknown(in Unknown, out *Unknown, c *conversion.Cloner) error {
if in.Serializer == nil { if err := DeepCopy_runtime_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
out.Serializer = nil
} else if newVal, err := c.DeepCopy(in.Serializer); err != nil {
return err
} else {
out.Serializer = newVal.(Serializer)
}
out.EncodesAsText = in.EncodesAsText
out.MediaType = in.MediaType
return nil
}
func DeepCopy_runtime_StreamSerializerInfo(in StreamSerializerInfo, out *StreamSerializerInfo, c *conversion.Cloner) error {
if err := DeepCopy_runtime_SerializerInfo(in.SerializerInfo, &out.SerializerInfo, c); err != nil {
return err
}
if in.Framer == nil {
out.Framer = nil
} else if newVal, err := c.DeepCopy(in.Framer); err != nil {
return err
} else {
out.Framer = newVal.(Framer)
}
if err := DeepCopy_runtime_SerializerInfo(in.Embedded, &out.Embedded, c); err != nil {
return err return err
} }
if in.Raw != nil {
in, out := in.Raw, &out.Raw
*out = make([]byte, len(in))
copy(*out, in)
} else {
out.Raw = nil
}
out.ContentEncoding = in.ContentEncoding
out.ContentType = in.ContentType
return nil return nil
} }

View File

@ -69,6 +69,7 @@ option go_package = "runtime";
// in the Object. (TODO: In the case where the object is of an unknown type, a // in the Object. (TODO: In the case where the object is of an unknown type, a
// runtime.Unknown object will be created and stored.) // runtime.Unknown object will be created and stored.)
// //
// +gencopy=true
// +protobuf=true // +protobuf=true
message RawExtension { message RawExtension {
// Raw is the underlying serialization of this object. // Raw is the underlying serialization of this object.
@ -88,6 +89,7 @@ message RawExtension {
// TypeMeta is provided here for convenience. You may use it directly from this package or define // TypeMeta is provided here for convenience. You may use it directly from this package or define
// your own with the same fields. // your own with the same fields.
// //
// +gencopy=true
// +protobuf=true // +protobuf=true
message TypeMeta { message TypeMeta {
optional string apiVersion = 1; optional string apiVersion = 1;
@ -101,6 +103,7 @@ message TypeMeta {
// TODO: Make this object have easy access to field based accessors and settors for // TODO: Make this object have easy access to field based accessors and settors for
// metadata and field mutatation. // metadata and field mutatation.
// //
// +gencopy=true
// +protobuf=true // +protobuf=true
message Unknown { message Unknown {
optional TypeMeta typeMeta = 1; optional TypeMeta typeMeta = 1;

View File

@ -1,80 +0,0 @@
// +build !ignore_autogenerated
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package serializer
import (
conversion "k8s.io/kubernetes/pkg/conversion"
runtime "k8s.io/kubernetes/pkg/runtime"
)
func DeepCopy_serializer_CodecFactory(in CodecFactory, out *CodecFactory, c *conversion.Cloner) error {
if in.scheme != nil {
in, out := in.scheme, &out.scheme
*out = new(runtime.Scheme)
if err := runtime.DeepCopy_runtime_Scheme(*in, *out, c); err != nil {
return err
}
} else {
out.scheme = nil
}
if in.serializers != nil {
in, out := in.serializers, &out.serializers
*out = make([]serializerType, len(in))
for i := range in {
if newVal, err := c.DeepCopy(in[i]); err != nil {
return err
} else {
(*out)[i] = newVal.(serializerType)
}
}
} else {
out.serializers = nil
}
if in.universal == nil {
out.universal = nil
} else if newVal, err := c.DeepCopy(in.universal); err != nil {
return err
} else {
out.universal = newVal.(runtime.Decoder)
}
if in.accepts != nil {
in, out := in.accepts, &out.accepts
*out = make([]string, len(in))
copy(*out, in)
} else {
out.accepts = nil
}
if in.streamingAccepts != nil {
in, out := in.streamingAccepts, &out.streamingAccepts
*out = make([]string, len(in))
copy(*out, in)
} else {
out.streamingAccepts = nil
}
if in.legacySerializer == nil {
out.legacySerializer = nil
} else if newVal, err := c.DeepCopy(in.legacySerializer); err != nil {
return err
} else {
out.legacySerializer = newVal.(runtime.Serializer)
}
return nil
}

View File

@ -40,6 +40,7 @@ import (
// TypeMeta is provided here for convenience. You may use it directly from this package or define // TypeMeta is provided here for convenience. You may use it directly from this package or define
// your own with the same fields. // your own with the same fields.
// //
// +gencopy=true
// +protobuf=true // +protobuf=true
type TypeMeta struct { type TypeMeta struct {
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty" protobuf:"bytes,1,opt,name=apiVersion"` APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty" protobuf:"bytes,1,opt,name=apiVersion"`
@ -92,6 +93,7 @@ const (
// in the Object. (TODO: In the case where the object is of an unknown type, a // in the Object. (TODO: In the case where the object is of an unknown type, a
// runtime.Unknown object will be created and stored.) // runtime.Unknown object will be created and stored.)
// //
// +gencopy=true
// +protobuf=true // +protobuf=true
type RawExtension struct { type RawExtension struct {
// Raw is the underlying serialization of this object. // Raw is the underlying serialization of this object.
@ -109,6 +111,7 @@ type RawExtension struct {
// TODO: Make this object have easy access to field based accessors and settors for // TODO: Make this object have easy access to field based accessors and settors for
// metadata and field mutatation. // metadata and field mutatation.
// //
// +gencopy=true
// +protobuf=true // +protobuf=true
type Unknown struct { type Unknown struct {
TypeMeta `json:",inline" protobuf:"bytes,1,opt,name=typeMeta"` TypeMeta `json:",inline" protobuf:"bytes,1,opt,name=typeMeta"`

View File

@ -30,6 +30,7 @@ option go_package = "intstr";
// accept a name or number. // accept a name or number.
// TODO: Rename to Int32OrString // TODO: Rename to Int32OrString
// //
// +gencopy=true
// +protobuf=true // +protobuf=true
// +protobuf.options.(gogoproto.goproto_stringer)=false // +protobuf.options.(gogoproto.goproto_stringer)=false
message IntOrString { message IntOrString {

View File

@ -32,6 +32,7 @@ import (
// accept a name or number. // accept a name or number.
// TODO: Rename to Int32OrString // TODO: Rename to Int32OrString
// //
// +gencopy=true
// +protobuf=true // +protobuf=true
// +protobuf.options.(gogoproto.goproto_stringer)=false // +protobuf.options.(gogoproto.goproto_stringer)=false
type IntOrString struct { type IntOrString struct {

View File

@ -1,29 +0,0 @@
// +build !ignore_autogenerated
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package sets
import (
conversion "k8s.io/kubernetes/pkg/conversion"
)
func DeepCopy_sets_Empty(in Empty, out *Empty, c *conversion.Cloner) error {
return nil
}