Use file tags to generate deep-copies

This drives most of the logic of deep-copy generation from tags like:
  // +deepcopy-gen=package
..rather than hardcoded lists of packages.  This will make it possible to
subsequently generate code ONLY for packages that need it *right now*, rather
than all of them always.

Also remove pkgs that really do not need deep-copies (no symbols used
anywhere).
This commit is contained in:
Tim Hockin 2016-06-06 22:46:24 -07:00
parent 4c4c6fc40e
commit 28af54138d
41 changed files with 723 additions and 203 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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{

View File

@ -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/`<group>`/`<version>` 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/`<group>`/`<version>` 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:

View File

@ -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/<version>/deep_copy_generated.go` containing auto-generated copy functions
- `pkg/apis/extensions/<version>/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:
- `<path_to_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

View File

@ -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)
}
}

View File

@ -73,7 +73,6 @@ func AddToScheme(scheme *runtime.Scheme) {
&unversioned.APIResourceList{},
)
addDeepCopyFuncs(scheme)
addDefaultingFuncs(scheme)
addConversionFuncs(scheme)
}

View File

@ -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)
}
}

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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}

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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

19
pkg/apis/apps/doc.go Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

19
pkg/apis/batch/doc.go Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

19
pkg/apis/policy/doc.go Normal file
View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -15,5 +15,7 @@ limitations under the License.
*/
// +groupName=rbac.authorization.k8s.io
// +k8s:deepcopy-gen=register
// +genconversion=true
package v1alpha1

View File

@ -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
}

View File

@ -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

View File

@ -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
}

View File

@ -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