Migrate everything to new deep-copy generator.

This commit is contained in:
Wojciech Tyczynski 2016-03-17 11:09:17 +01:00
parent b21da9ed92
commit 04eb0d40bb
3 changed files with 17 additions and 2 deletions

View File

@ -363,7 +363,9 @@ func (g *genDeepCopy) doStruct(t *types.Type, sw *generator.SnippetWriter) {
if m.Type.Kind == types.Alias && m.Type.Underlying.Kind == types.Builtin { if m.Type.Kind == types.Alias && m.Type.Underlying.Kind == types.Builtin {
sw.Do("out.$.name$ = in.$.name$\n", args) sw.Do("out.$.name$ = in.$.name$\n", args)
} else { } else {
sw.Do("if newVal, err := c.DeepCopy(in.$.name$); err != nil {\n", args) sw.Do("if in.$.name$ == nil {\n", args)
sw.Do("out.$.name$ = nil\n", args)
sw.Do("} else if newVal, err := c.DeepCopy(in.$.name$); err != nil {\n", args)
sw.Do("return err\n", nil) sw.Do("return err\n", nil)
sw.Do("} else {\n", nil) sw.Do("} else {\n", nil)
sw.Do("out.$.name$ = newVal.($.type|raw$)\n", args) sw.Do("out.$.name$ = newVal.($.type|raw$)\n", args)

View File

@ -34,6 +34,19 @@ func main() {
// 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",
"k8s.io/kubernetes/pkg/api/v1",
"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/componentconfig",
"k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1",
"k8s.io/kubernetes/pkg/apis/extensions",
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1",
"k8s.io/kubernetes/pkg/apis/metrics",
"k8s.io/kubernetes/pkg/apis/metrics/v1alpha1",
} }
if err := arguments.Execute( if err := arguments.Execute(

View File

@ -62,6 +62,6 @@ function generate_deep_copies() {
# Currently pkg/api/deep_copy_generated.go is generated by the new go2idl generator. # Currently pkg/api/deep_copy_generated.go is generated by the new go2idl generator.
# All others (mentioned above) are still generated by the old reflection-based generator. # All others (mentioned above) are still generated by the old reflection-based generator.
# TODO: Migrate these to the new generator. # TODO: Migrate these to the new generator.
DEFAULT_VERSIONS="v1 authorization/__internal authorization/v1beta1 autoscaling/__internal autoscaling/v1 batch/__internal batch/v1 extensions/__internal extensions/v1beta1 componentconfig/__internal componentconfig/v1alpha1 metrics/__internal metrics/v1alpha1" DEFAULT_VERSIONS=""
VERSIONS=${VERSIONS:-$DEFAULT_VERSIONS} VERSIONS=${VERSIONS:-$DEFAULT_VERSIONS}
generate_deep_copies "$VERSIONS" generate_deep_copies "$VERSIONS"