diff --git a/cmd/libs/go2idl/deepcopy-gen/generators/deepcopy.go b/cmd/libs/go2idl/deepcopy-gen/generators/deepcopy.go index 83e16c43ec3..d28396c0c35 100644 --- a/cmd/libs/go2idl/deepcopy-gen/generators/deepcopy.go +++ b/cmd/libs/go2idl/deepcopy-gen/generators/deepcopy.go @@ -87,13 +87,23 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat } for _, p := range context.Universe { - copyableType := false + // Short-circuit if this package has not opted in. + if tagvals := types.ExtractCommentTags("+", p.Comments)["k8s:deepcopy-gen"]; tagvals == nil { + // No tag for this package. + continue + } else if tagvals[0] != "generate" && tagvals[0] != "register" { + // Unknown tag. + glog.Errorf("Uknown tag value '+k8s:deepcopy-gen=%s'", tagvals[0]) + continue + } + needsGeneration := false for _, t := range p.Types { if copyableWithinPackage(t, boundingDirs) && inputs.Has(t.Name.Package) { - copyableType = true + needsGeneration = true + break } } - if copyableType { + if needsGeneration { path := p.Path packages = append(packages, &generator.DefaultPackage{ @@ -103,7 +113,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) { generators = []generator.Generator{} generators = append( - generators, NewGenDeepCopy("deep_copy_generated", path, boundingDirs, inputs.Has(path))) + generators, NewGenDeepCopy(arguments.OutputFileBaseName, path, boundingDirs)) return generators }, FilterFunc: func(c *generator.Context, t *types.Type) bool { @@ -123,25 +133,23 @@ const ( // genDeepCopy produces a file with autogenerated deep-copy functions. type genDeepCopy struct { generator.DefaultGen - targetPackage string - boundingDirs []string - imports namer.ImportTracker - typesForInit []*types.Type - generateInitFunc bool + targetPackage string + boundingDirs []string + imports namer.ImportTracker + typesForInit []*types.Type globalVariables map[string]interface{} } -func NewGenDeepCopy(sanitizedName, targetPackage string, boundingDirs []string, generateInitFunc bool) generator.Generator { +func NewGenDeepCopy(sanitizedName, targetPackage string, boundingDirs []string) generator.Generator { return &genDeepCopy{ DefaultGen: generator.DefaultGen{ OptionalName: sanitizedName, }, - targetPackage: targetPackage, - boundingDirs: boundingDirs, - imports: generator.NewImportTracker(), - typesForInit: make([]*types.Type, 0), - generateInitFunc: generateInitFunc, + targetPackage: targetPackage, + boundingDirs: boundingDirs, + imports: generator.NewImportTracker(), + typesForInit: make([]*types.Type, 0), } } @@ -200,7 +208,7 @@ func isRootedUnder(pkg string, roots []string) bool { func copyableWithinPackage(t *types.Type, boundingDirs []string) bool { // If the type opts out of copy-generation, stop. - if extractBoolTagOrDie("gencopy", true, t.CommentLines) == false { + if extractBoolTagOrDie("k8s:deepcopy-gen", true, t.CommentLines) == false { return false } // Only packages within the restricted range can be processed. @@ -268,7 +276,7 @@ func (g *genDeepCopy) Init(c *generator.Context, w io.Writer) error { g.globalVariables = map[string]interface{}{ "Cloner": cloner, } - if !g.generateInitFunc { + if tagvals := types.ExtractCommentTags("+", c.Universe[g.targetPackage].Comments)["k8s:deepcopy-gen"]; tagvals != nil && tagvals[0] != "register" { // TODO: We should come up with a solution to register all generated // deep-copy functions. However, for now, to avoid import cycles // we register only those explicitly requested. diff --git a/cmd/libs/go2idl/deepcopy-gen/generators/deepcopy_test.go b/cmd/libs/go2idl/deepcopy-gen/generators/deepcopy_test.go index c9cf55354d8..f6d33837e1b 100644 --- a/cmd/libs/go2idl/deepcopy-gen/generators/deepcopy_test.go +++ b/cmd/libs/go2idl/deepcopy-gen/generators/deepcopy_test.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Kubernetes Authors All rights reserved. +Copyright 2016 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/cmd/libs/go2idl/deepcopy-gen/main.go b/cmd/libs/go2idl/deepcopy-gen/main.go index ae4b1d901f6..dd584ce811b 100644 --- a/cmd/libs/go2idl/deepcopy-gen/main.go +++ b/cmd/libs/go2idl/deepcopy-gen/main.go @@ -16,9 +16,30 @@ limitations under the License. // deepcopy-gen is a tool for auto-generating DeepCopy functions. // -// Structs in the input directories with the below line in their comments -// will be ignored during generation. -// // +gencopy=false +// Given a list of input directories, it will generate functions that +// efficiently perform a full deep-copy of each type. For any type that +// offers a `.DeepCopy()` method, it will simply call that. Otherwise it will +// use standard value assignment whenever possible. If that is not possible it +// will try to call its own generated copy function for the type, if the type is +// within the allowed root packages. Failing that, it will fall back on +// `conversion.Cloner.DeepCopy(val)` to make the copy. The resulting file will +// be stored in the same directory as the processed source package. +// +// Generation is governed by comment tags in the source. Any package may +// request DeepCopy generation by including a comment in the file-comments of +// one file, of the form: +// // +k8s:deepcopy-gen=generate +// or: +// // +k8s:deepcopy-gen=register +// +// Packages which specify `=generate` will have DeepCopy functions generated +// into them. Packages which specify `=register` will have DeepCopy functions +// generated and registered with in `init()` function call to +// `Scheme.AddGeneratedDeepCopyFuncs()`. +// +// Individual types may opt out of DeepCopy generation by specifying a comment +// of the form: +// // +k8s:deepcopy-gen=false package main import ( @@ -32,34 +53,8 @@ import ( func main() { arguments := args.Default() - // Override defaults. These are Kubernetes specific input locations. - arguments.InputDirs = []string{ - "k8s.io/kubernetes/pkg/api", - "k8s.io/kubernetes/pkg/api/v1", - "k8s.io/kubernetes/pkg/apis/authentication.k8s.io", - "k8s.io/kubernetes/pkg/apis/authentication.k8s.io/v1beta1", - "k8s.io/kubernetes/pkg/apis/authorization", - "k8s.io/kubernetes/pkg/apis/authorization/v1beta1", - "k8s.io/kubernetes/pkg/apis/autoscaling", - "k8s.io/kubernetes/pkg/apis/autoscaling/v1", - "k8s.io/kubernetes/pkg/apis/batch", - "k8s.io/kubernetes/pkg/apis/batch/v1", - "k8s.io/kubernetes/pkg/apis/batch/v2alpha1", - "k8s.io/kubernetes/pkg/apis/apps", - "k8s.io/kubernetes/pkg/apis/apps/v1alpha1", - "k8s.io/kubernetes/pkg/apis/certificates", - "k8s.io/kubernetes/pkg/apis/certificates/v1alpha1", - "k8s.io/kubernetes/pkg/apis/componentconfig", - "k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1", - "k8s.io/kubernetes/pkg/apis/policy", - "k8s.io/kubernetes/pkg/apis/policy/v1alpha1", - "k8s.io/kubernetes/pkg/apis/extensions", - "k8s.io/kubernetes/pkg/apis/extensions/v1beta1", - "k8s.io/kubernetes/pkg/apis/rbac", - "k8s.io/kubernetes/pkg/apis/rbac/v1alpha1", - "k8s.io/kubernetes/federation/apis/federation", - "k8s.io/kubernetes/federation/apis/federation/v1beta1", - } + // Override defaults. + arguments.OutputFileBaseName = "deep_copy_generated" // Custom args. customArgs := &generators.CustomArgs{ diff --git a/docs/devel/adding-an-APIGroup.md b/docs/devel/adding-an-APIGroup.md index c219776167a..6026cc2e45d 100644 --- a/docs/devel/adding-an-APIGroup.md +++ b/docs/devel/adding-an-APIGroup.md @@ -75,12 +75,14 @@ cmd/libs/go2idl/ tool. 1. Generate conversions and deep-copies: 1. Add your "group/" or "group/version" into - cmd/libs/go2idl/{conversion-gen, deep-copy-gen}/main.go; + cmd/libs/go2idl/conversion-gen/main.go; 2. Make sure your pkg/apis/``/`` directory has a doc.go file + with the comment `// +k8s:deepcopy-gen=register`, to catch the attention + of our generation tools. + 3. Make sure your pkg/apis/``/`` directory has a doc.go file with the comment `// +genconversion=true`, to catch the attention of our gen-conversion script. - 3. Run hack/update-all.sh. - + 4. Run hack/update-all.sh. 2. Generate files for Ugorji codec: diff --git a/docs/devel/api_changes.md b/docs/devel/api_changes.md index 4af0bd7c374..99aba0d77d9 100644 --- a/docs/devel/api_changes.md +++ b/docs/devel/api_changes.md @@ -468,12 +468,11 @@ regenerate auto-generated ones. To regenerate them run: hack/update-codegen.sh ``` -update-codegen will also generate code to handle deep copy of your versioned -api objects. The deep copy code resides with each versioned API: - - `pkg/api//deep_copy_generated.go` containing auto-generated copy functions - - `pkg/apis/extensions//deep_copy_generated.go` containing auto-generated copy functions +As part of the build, kubernetes will also generate code to handle deep copy of +your versioned api objects. The deep copy code resides with each versioned API: + - `/zz_generated.deep_copy.go` containing auto-generated copy functions -If running the above script is impossible due to compile errors, the easiest +If regeneration is somehow not possible due to compile errors, the easiest workaround is to comment out the code causing errors and let the script to regenerate it. If the auto-generated conversion methods are not used by the manually-written ones, it's fine to just remove the whole file and let the diff --git a/federation/apis/core/deep_copy.go b/federation/apis/core/deep_copy.go deleted file mode 100644 index d83bffc81d8..00000000000 --- a/federation/apis/core/deep_copy.go +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -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. -*/ - -package core - -import ( - "k8s.io/kubernetes/pkg/api" - "k8s.io/kubernetes/pkg/runtime" -) - -func addDeepCopyFuncs(scheme *runtime.Scheme) { - if err := scheme.AddGeneratedDeepCopyFuncs( - api.DeepCopy_api_DeleteOptions, - api.DeepCopy_api_ExportOptions, - api.DeepCopy_api_List, - api.DeepCopy_api_ListOptions, - api.DeepCopy_api_ObjectMeta, - api.DeepCopy_api_ObjectReference, - api.DeepCopy_api_OwnerReference, - api.DeepCopy_api_Service, - api.DeepCopy_api_ServiceList, - api.DeepCopy_api_ServicePort, - api.DeepCopy_api_ServiceSpec, - api.DeepCopy_api_ServiceStatus, - ); err != nil { - // if one of the deep copy functions is malformed, detect it immediately. - panic(err) - } -} diff --git a/federation/apis/core/register.go b/federation/apis/core/register.go index c045520af88..c4d1c289e08 100644 --- a/federation/apis/core/register.go +++ b/federation/apis/core/register.go @@ -73,7 +73,6 @@ func AddToScheme(scheme *runtime.Scheme) { &unversioned.APIResourceList{}, ) - addDeepCopyFuncs(scheme) addDefaultingFuncs(scheme) addConversionFuncs(scheme) } diff --git a/federation/apis/core/v1/deep_copy.go b/federation/apis/core/v1/deep_copy.go deleted file mode 100644 index 23f8592c866..00000000000 --- a/federation/apis/core/v1/deep_copy.go +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -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. -*/ - -package v1 - -import ( - "k8s.io/kubernetes/pkg/api/v1" - "k8s.io/kubernetes/pkg/runtime" -) - -func addDeepCopyFuncs(scheme *runtime.Scheme) { - if err := scheme.AddGeneratedDeepCopyFuncs( - v1.DeepCopy_v1_DeleteOptions, - v1.DeepCopy_v1_ExportOptions, - v1.DeepCopy_v1_List, - v1.DeepCopy_v1_ListOptions, - v1.DeepCopy_v1_ObjectMeta, - v1.DeepCopy_v1_ObjectReference, - v1.DeepCopy_v1_OwnerReference, - v1.DeepCopy_v1_Service, - v1.DeepCopy_v1_ServiceList, - v1.DeepCopy_v1_ServicePort, - v1.DeepCopy_v1_ServiceSpec, - v1.DeepCopy_v1_ServiceStatus, - ); err != nil { - // if one of the deep copy functions is malformed, detect it immediately. - panic(err) - } -} diff --git a/federation/apis/core/v1/register.go b/federation/apis/core/v1/register.go index 0a3d87bb9a0..30054870f24 100644 --- a/federation/apis/core/v1/register.go +++ b/federation/apis/core/v1/register.go @@ -34,7 +34,6 @@ func AddToScheme(scheme *runtime.Scheme) { addKnownTypes(scheme) addConversionFuncs(scheme) addDefaultingFuncs(scheme) - addDeepCopyFuncs(scheme) } // Adds the list of known types to api.Scheme. diff --git a/pkg/util/intstr/deep_copy_generated.go b/federation/apis/federation/doc.go similarity index 61% rename from pkg/util/intstr/deep_copy_generated.go rename to federation/apis/federation/doc.go index 793b1ebd184..d3eb70de2df 100644 --- a/pkg/util/intstr/deep_copy_generated.go +++ b/federation/apis/federation/doc.go @@ -1,5 +1,3 @@ -// +build !ignore_autogenerated - /* Copyright 2016 The Kubernetes Authors. @@ -16,17 +14,6 @@ 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! +// +k8s:deepcopy-gen=register -package intstr - -import ( - conversion "k8s.io/kubernetes/pkg/conversion" -) - -func DeepCopy_intstr_IntOrString(in IntOrString, out *IntOrString, c *conversion.Cloner) error { - out.Type = in.Type - out.IntVal = in.IntVal - out.StrVal = in.StrVal - return nil -} +package federation diff --git a/federation/apis/federation/v1beta1/doc.go b/federation/apis/federation/v1beta1/doc.go index ac2fd00ba91..0dc068a3494 100644 --- a/federation/apis/federation/v1beta1/doc.go +++ b/federation/apis/federation/v1beta1/doc.go @@ -14,5 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // +genconversion=true package v1beta1 diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 979422d36bf..9d5df48b903 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -48,7 +48,34 @@ ${clientgen} --clientset-name="release_1_4" --input="api/v1,extensions/v1beta1,a ${clientgen} --clientset-name=federation_internalclientset --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input="../../federation/apis/federation/","api/" --included-types-overrides="api/Service" "$@" ${clientgen} --clientset-name=federation_release_1_4 --clientset-path=k8s.io/kubernetes/federation/client/clientset_generated --input="../../federation/apis/federation/v1beta1","api/v1" --included-types-overrides="api/v1/Service" "$@" ${conversiongen} "$@" -${deepcopygen} "$@" ${setgen} "$@" # You may add additional calls of code generators like set-gen above. + +# Generate a list of all files that have a `+k8s:` comment-tag. This will be +# used to derive lists of files/dirs for generation tools. +ALL_K8S_TAG_FILES=$( + grep -l '^// \?+k8s:' $( + find . \ + -not \( \ + \( \ + -path ./vendor -o \ + -path ./_output -o \ + -path ./.git \ + \) -prune \ + \) \ + -type f -name \*.go \ + | sed 's|^./||' + ) + ) +DEEP_COPY_DIRS=$( + grep -l '+k8s:deepcopy-gen=' ${ALL_K8S_TAG_FILES} \ + | xargs dirname \ + | sort -u + ) +INPUTS=$( + for d in ${DEEP_COPY_DIRS}; do + echo k8s.io/kubernetes/$d + done | paste -sd, + ) +${deepcopygen} -i ${INPUTS} diff --git a/pkg/api/doc.go b/pkg/api/doc.go index a4262ab3613..23fea0579da 100644 --- a/pkg/api/doc.go +++ b/pkg/api/doc.go @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // Package api contains the latest (or "internal") version of the // Kubernetes API objects. This is the API objects as represented in memory. // The contract presented to clients is located in the versioned packages, diff --git a/pkg/api/unversioned/deep_copy_generated.go b/pkg/api/unversioned/deep_copy_generated.go index b26c6579fe4..77f5b66d882 100644 --- a/pkg/api/unversioned/deep_copy_generated.go +++ b/pkg/api/unversioned/deep_copy_generated.go @@ -21,37 +21,28 @@ limitations under the License. package unversioned import ( - time "time" - conversion "k8s.io/kubernetes/pkg/conversion" + time "time" ) func DeepCopy_unversioned_APIGroup(in APIGroup, out *APIGroup, c *conversion.Cloner) error { - if err := DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { - return err - } + out.TypeMeta = in.TypeMeta out.Name = in.Name if in.Versions != nil { in, out := in.Versions, &out.Versions *out = make([]GroupVersionForDiscovery, len(in)) for i := range in { - if err := DeepCopy_unversioned_GroupVersionForDiscovery(in[i], &(*out)[i], c); err != nil { - return err - } + (*out)[i] = in[i] } } else { out.Versions = nil } - if err := DeepCopy_unversioned_GroupVersionForDiscovery(in.PreferredVersion, &out.PreferredVersion, c); err != nil { - return err - } + out.PreferredVersion = in.PreferredVersion if in.ServerAddressByClientCIDRs != nil { in, out := in.ServerAddressByClientCIDRs, &out.ServerAddressByClientCIDRs *out = make([]ServerAddressByClientCIDR, len(in)) for i := range in { - if err := DeepCopy_unversioned_ServerAddressByClientCIDR(in[i], &(*out)[i], c); err != nil { - return err - } + (*out)[i] = in[i] } } else { out.ServerAddressByClientCIDRs = nil @@ -60,9 +51,7 @@ func DeepCopy_unversioned_APIGroup(in APIGroup, out *APIGroup, c *conversion.Clo } func DeepCopy_unversioned_APIGroupList(in APIGroupList, out *APIGroupList, c *conversion.Cloner) error { - if err := DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { - return err - } + out.TypeMeta = in.TypeMeta if in.Groups != nil { in, out := in.Groups, &out.Groups *out = make([]APIGroup, len(in)) @@ -85,17 +74,13 @@ func DeepCopy_unversioned_APIResource(in APIResource, out *APIResource, c *conve } func DeepCopy_unversioned_APIResourceList(in APIResourceList, out *APIResourceList, c *conversion.Cloner) error { - if err := DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { - return err - } + out.TypeMeta = in.TypeMeta out.GroupVersion = in.GroupVersion if in.APIResources != nil { in, out := in.APIResources, &out.APIResources *out = make([]APIResource, len(in)) for i := range in { - if err := DeepCopy_unversioned_APIResource(in[i], &(*out)[i], c); err != nil { - return err - } + (*out)[i] = in[i] } } else { out.APIResources = nil @@ -104,9 +89,7 @@ func DeepCopy_unversioned_APIResourceList(in APIResourceList, out *APIResourceLi } func DeepCopy_unversioned_APIVersions(in APIVersions, out *APIVersions, c *conversion.Cloner) error { - if err := DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { - return err - } + out.TypeMeta = in.TypeMeta if in.Versions != nil { in, out := in.Versions, &out.Versions *out = make([]string, len(in)) @@ -118,9 +101,7 @@ func DeepCopy_unversioned_APIVersions(in APIVersions, out *APIVersions, c *conve in, out := in.ServerAddressByClientCIDRs, &out.ServerAddressByClientCIDRs *out = make([]ServerAddressByClientCIDR, len(in)) for i := range in { - if err := DeepCopy_unversioned_ServerAddressByClientCIDR(in[i], &(*out)[i], c); err != nil { - return err - } + (*out)[i] = in[i] } } else { out.ServerAddressByClientCIDRs = nil @@ -134,9 +115,7 @@ func DeepCopy_unversioned_Duration(in Duration, out *Duration, c *conversion.Clo } func DeepCopy_unversioned_ExportOptions(in ExportOptions, out *ExportOptions, c *conversion.Cloner) error { - if err := DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { - return err - } + out.TypeMeta = in.TypeMeta out.Export = in.Export out.Exact = in.Exact return nil @@ -245,12 +224,8 @@ func DeepCopy_unversioned_ServerAddressByClientCIDR(in ServerAddressByClientCIDR } func DeepCopy_unversioned_Status(in Status, out *Status, c *conversion.Cloner) error { - if err := DeepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { - return err - } - if err := DeepCopy_unversioned_ListMeta(in.ListMeta, &out.ListMeta, c); err != nil { - return err - } + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta out.Status = in.Status out.Message = in.Message out.Reason = in.Reason @@ -282,9 +257,7 @@ func DeepCopy_unversioned_StatusDetails(in StatusDetails, out *StatusDetails, c in, out := in.Causes, &out.Causes *out = make([]StatusCause, len(in)) for i := range in { - if err := DeepCopy_unversioned_StatusCause(in[i], &(*out)[i], c); err != nil { - return err - } + (*out)[i] = in[i] } } else { out.Causes = nil diff --git a/pkg/api/unversioned/doc.go b/pkg/api/unversioned/doc.go new file mode 100644 index 00000000000..e18a6675fd2 --- /dev/null +++ b/pkg/api/unversioned/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes Authors. + +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. +*/ + +// +k8s:deepcopy-gen=generate + +package unversioned diff --git a/pkg/api/v1/doc.go b/pkg/api/v1/doc.go index 6f00ffc857c..b9c15641bce 100644 --- a/pkg/api/v1/doc.go +++ b/pkg/api/v1/doc.go @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // Package v1 is the v1 version of the API. // +genconversion=true package v1 diff --git a/pkg/apis/apps/doc.go b/pkg/apis/apps/doc.go new file mode 100644 index 00000000000..9943700e451 --- /dev/null +++ b/pkg/apis/apps/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes Authors. + +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. +*/ + +// +k8s:deepcopy-gen=register + +package apps diff --git a/pkg/apis/apps/v1alpha1/doc.go b/pkg/apis/apps/v1alpha1/doc.go index 935d55b7423..06dafc4f96b 100644 --- a/pkg/apis/apps/v1alpha1/doc.go +++ b/pkg/apis/apps/v1alpha1/doc.go @@ -14,5 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // +genconversion=true package v1alpha1 diff --git a/pkg/apis/authentication.k8s.io/doc.go b/pkg/apis/authentication.k8s.io/doc.go new file mode 100644 index 00000000000..084447ac6fe --- /dev/null +++ b/pkg/apis/authentication.k8s.io/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes Authors. + +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. +*/ + +// +k8s:deepcopy-gen=register + +package authentication diff --git a/pkg/apis/authentication.k8s.io/v1beta1/doc.go b/pkg/apis/authentication.k8s.io/v1beta1/doc.go index ac2fd00ba91..0dc068a3494 100644 --- a/pkg/apis/authentication.k8s.io/v1beta1/doc.go +++ b/pkg/apis/authentication.k8s.io/v1beta1/doc.go @@ -14,5 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // +genconversion=true package v1beta1 diff --git a/pkg/apis/authorization/doc.go b/pkg/apis/authorization/doc.go new file mode 100644 index 00000000000..47877fadc02 --- /dev/null +++ b/pkg/apis/authorization/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes Authors. + +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. +*/ + +// +k8s:deepcopy-gen=register + +package authorization diff --git a/pkg/apis/authorization/v1beta1/doc.go b/pkg/apis/authorization/v1beta1/doc.go index ac2fd00ba91..0dc068a3494 100644 --- a/pkg/apis/authorization/v1beta1/doc.go +++ b/pkg/apis/authorization/v1beta1/doc.go @@ -14,5 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // +genconversion=true package v1beta1 diff --git a/pkg/apis/autoscaling/doc.go b/pkg/apis/autoscaling/doc.go new file mode 100644 index 00000000000..601be4361c9 --- /dev/null +++ b/pkg/apis/autoscaling/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes Authors. + +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. +*/ + +// +k8s:deepcopy-gen=register + +package autoscaling diff --git a/pkg/apis/autoscaling/v1/doc.go b/pkg/apis/autoscaling/v1/doc.go index 30030131794..d41a7fb76f7 100644 --- a/pkg/apis/autoscaling/v1/doc.go +++ b/pkg/apis/autoscaling/v1/doc.go @@ -14,5 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // +genconversion=true package v1 diff --git a/pkg/apis/batch/doc.go b/pkg/apis/batch/doc.go new file mode 100644 index 00000000000..bac88a93b16 --- /dev/null +++ b/pkg/apis/batch/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes Authors. + +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. +*/ + +// +k8s:deepcopy-gen=register + +package batch diff --git a/pkg/apis/batch/v1/doc.go b/pkg/apis/batch/v1/doc.go index 30030131794..d41a7fb76f7 100644 --- a/pkg/apis/batch/v1/doc.go +++ b/pkg/apis/batch/v1/doc.go @@ -14,5 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // +genconversion=true package v1 diff --git a/pkg/apis/batch/v2alpha1/doc.go b/pkg/apis/batch/v2alpha1/doc.go index d320bc733c0..7a5c3bce461 100644 --- a/pkg/apis/batch/v2alpha1/doc.go +++ b/pkg/apis/batch/v2alpha1/doc.go @@ -14,5 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // +genconversion=true package v2alpha1 diff --git a/pkg/apis/certificates/doc.go b/pkg/apis/certificates/doc.go new file mode 100644 index 00000000000..f045cee7da8 --- /dev/null +++ b/pkg/apis/certificates/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes Authors. + +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. +*/ + +// +k8s:deepcopy-gen=register + +package certificates diff --git a/pkg/apis/certificates/v1alpha1/doc.go b/pkg/apis/certificates/v1alpha1/doc.go index 935d55b7423..06dafc4f96b 100644 --- a/pkg/apis/certificates/v1alpha1/doc.go +++ b/pkg/apis/certificates/v1alpha1/doc.go @@ -14,5 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // +genconversion=true package v1alpha1 diff --git a/pkg/apis/componentconfig/doc.go b/pkg/apis/componentconfig/doc.go new file mode 100644 index 00000000000..bdbbbbd5ddf --- /dev/null +++ b/pkg/apis/componentconfig/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes Authors. + +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. +*/ + +// +k8s:deepcopy-gen=register + +package componentconfig diff --git a/pkg/apis/componentconfig/v1alpha1/doc.go b/pkg/apis/componentconfig/v1alpha1/doc.go index 935d55b7423..06dafc4f96b 100644 --- a/pkg/apis/componentconfig/v1alpha1/doc.go +++ b/pkg/apis/componentconfig/v1alpha1/doc.go @@ -14,5 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // +genconversion=true package v1alpha1 diff --git a/pkg/apis/extensions/doc.go b/pkg/apis/extensions/doc.go new file mode 100644 index 00000000000..e2d73e9daf9 --- /dev/null +++ b/pkg/apis/extensions/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes Authors. + +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. +*/ + +// +k8s:deepcopy-gen=register + +package extensions diff --git a/pkg/apis/extensions/v1beta1/doc.go b/pkg/apis/extensions/v1beta1/doc.go index ac2fd00ba91..0dc068a3494 100644 --- a/pkg/apis/extensions/v1beta1/doc.go +++ b/pkg/apis/extensions/v1beta1/doc.go @@ -14,5 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // +genconversion=true package v1beta1 diff --git a/pkg/apis/policy/doc.go b/pkg/apis/policy/doc.go new file mode 100644 index 00000000000..e7584c0fc2a --- /dev/null +++ b/pkg/apis/policy/doc.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 The Kubernetes Authors. + +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. +*/ + +// +k8s:deepcopy-gen=register + +package policy diff --git a/pkg/apis/policy/v1alpha1/doc.go b/pkg/apis/policy/v1alpha1/doc.go index 67857651c4f..f4ed6878b30 100644 --- a/pkg/apis/policy/v1alpha1/doc.go +++ b/pkg/apis/policy/v1alpha1/doc.go @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // Package policy is for any kind of policy object. Suitable examples, even if // they aren't all here, are PodDisruptionBudget, PodSecurityPolicy, // NetworkPolicy, etc. diff --git a/pkg/apis/rbac/doc.go b/pkg/apis/rbac/doc.go index c5f057484c4..6836fde7b1b 100644 --- a/pkg/apis/rbac/doc.go +++ b/pkg/apis/rbac/doc.go @@ -14,5 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=register + // +groupName=rbac.authorization.k8s.io package rbac diff --git a/pkg/apis/rbac/v1alpha1/doc.go b/pkg/apis/rbac/v1alpha1/doc.go index 84205537df6..9446f85afe2 100644 --- a/pkg/apis/rbac/v1alpha1/doc.go +++ b/pkg/apis/rbac/v1alpha1/doc.go @@ -15,5 +15,7 @@ limitations under the License. */ // +groupName=rbac.authorization.k8s.io +// +k8s:deepcopy-gen=register + // +genconversion=true package v1alpha1 diff --git a/pkg/conversion/deep_copy_generated.go b/pkg/conversion/deep_copy_generated.go new file mode 100644 index 00000000000..e8d736f9168 --- /dev/null +++ b/pkg/conversion/deep_copy_generated.go @@ -0,0 +1,185 @@ +// +build !ignore_autogenerated + +/* +Copyright 2016 The Kubernetes Authors. + +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 +} diff --git a/pkg/conversion/doc.go b/pkg/conversion/doc.go index 0c46ef2d169..c3866ff46a2 100644 --- a/pkg/conversion/doc.go +++ b/pkg/conversion/doc.go @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ +// +k8s:deepcopy-gen=generate + // Package conversion provides go object versioning. // // Specifically, conversion provides a way for you to define multiple versions diff --git a/pkg/runtime/deep_copy_generated.go b/pkg/runtime/deep_copy_generated.go index 3456eabeb32..46f08062f45 100644 --- a/pkg/runtime/deep_copy_generated.go +++ b/pkg/runtime/deep_copy_generated.go @@ -21,9 +21,39 @@ limitations under the License. package runtime import ( + unversioned "k8s.io/kubernetes/pkg/api/unversioned" conversion "k8s.io/kubernetes/pkg/conversion" + reflect "reflect" ) +func DeepCopy_runtime_NoopDecoder(in NoopDecoder, out *NoopDecoder, c *conversion.Cloner) error { + if in.Encoder == nil { + out.Encoder = nil + } else if newVal, err := c.DeepCopy(in.Encoder); err != nil { + return err + } else { + out.Encoder = newVal.(Encoder) + } + return nil +} + +func DeepCopy_runtime_NoopEncoder(in NoopEncoder, out *NoopEncoder, c *conversion.Cloner) error { + if in.Decoder == nil { + out.Decoder = nil + } else if newVal, err := c.DeepCopy(in.Decoder); err != nil { + return err + } else { + out.Decoder = newVal.(Decoder) + } + return nil +} + +func DeepCopy_runtime_Pair(in Pair, out *Pair, c *conversion.Cloner) error { + out.Name = in.Name + out.Doc = in.Doc + return nil +} + func DeepCopy_runtime_RawExtension(in RawExtension, out *RawExtension, c *conversion.Cloner) error { if in.Raw != nil { in, out := in.Raw, &out.Raw @@ -42,6 +72,115 @@ func DeepCopy_runtime_RawExtension(in RawExtension, out *RawExtension, c *conver return nil } +func DeepCopy_runtime_Scheme(in Scheme, out *Scheme, c *conversion.Cloner) error { + if in.gvkToType != nil { + in, out := in.gvkToType, &out.gvkToType + *out = make(map[unversioned.GroupVersionKind]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.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 +} + +func DeepCopy_runtime_SerializerInfo(in SerializerInfo, out *SerializerInfo, c *conversion.Cloner) error { + if in.Serializer == 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 nil +} + func DeepCopy_runtime_TypeMeta(in TypeMeta, out *TypeMeta, c *conversion.Cloner) error { out.APIVersion = in.APIVersion out.Kind = in.Kind @@ -49,9 +188,7 @@ func DeepCopy_runtime_TypeMeta(in TypeMeta, out *TypeMeta, c *conversion.Cloner) } func DeepCopy_runtime_Unknown(in Unknown, out *Unknown, c *conversion.Cloner) error { - if err := DeepCopy_runtime_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil { - return err - } + out.TypeMeta = in.TypeMeta if in.Raw != nil { in, out := in.Raw, &out.Raw *out = make([]byte, len(in)) @@ -63,3 +200,71 @@ func DeepCopy_runtime_Unknown(in Unknown, out *Unknown, c *conversion.Cloner) er out.ContentType = in.ContentType return nil } + +func DeepCopy_runtime_Unstructured(in Unstructured, out *Unstructured, c *conversion.Cloner) error { + if in.Object != nil { + in, out := in.Object, &out.Object + *out = make(map[string]interface{}) + for key, val := range in { + if newVal, err := c.DeepCopy(val); err != nil { + return err + } else { + (*out)[key] = newVal.(interface{}) + } + } + } else { + out.Object = nil + } + return nil +} + +func DeepCopy_runtime_UnstructuredList(in UnstructuredList, out *UnstructuredList, c *conversion.Cloner) error { + if in.Object != nil { + in, out := in.Object, &out.Object + *out = make(map[string]interface{}) + for key, val := range in { + if newVal, err := c.DeepCopy(val); err != nil { + return err + } else { + (*out)[key] = newVal.(interface{}) + } + } + } else { + out.Object = nil + } + if in.Items != nil { + in, out := in.Items, &out.Items + *out = make([]*Unstructured, len(in)) + for i := range in { + if newVal, err := c.DeepCopy(in[i]); err != nil { + return err + } else { + (*out)[i] = newVal.(*Unstructured) + } + } + } else { + out.Items = nil + } + return nil +} + +func DeepCopy_runtime_UnstructuredObjectConverter(in UnstructuredObjectConverter, out *UnstructuredObjectConverter, c *conversion.Cloner) error { + return nil +} + +func DeepCopy_runtime_VersionedObjects(in VersionedObjects, out *VersionedObjects, c *conversion.Cloner) error { + if in.Objects != nil { + in, out := in.Objects, &out.Objects + *out = make([]Object, len(in)) + for i := range in { + if newVal, err := c.DeepCopy(in[i]); err != nil { + return err + } else { + (*out)[i] = newVal.(Object) + } + } + } else { + out.Objects = nil + } + return nil +} diff --git a/pkg/runtime/doc.go b/pkg/runtime/doc.go index 7bdc70a2f77..120cd6d90db 100644 --- a/pkg/runtime/doc.go +++ b/pkg/runtime/doc.go @@ -41,4 +41,7 @@ limitations under the License. // // As a bonus, a few common types useful from all api objects and versions // are provided in types.go. + +// +k8s:deepcopy-gen=generate + package runtime