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:
parent
0bc86fd69b
commit
4a69f7cd28
|
|
@ -75,12 +75,14 @@ cmd/libs/go2idl/ tool.
|
||||||
1. Generate conversions and deep-copies:
|
1. Generate conversions and deep-copies:
|
||||||
|
|
||||||
1. Add your "group/" or "group/version" into
|
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
|
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
|
with the comment `// +genconversion=true`, to catch the attention of our
|
||||||
gen-conversion script.
|
gen-conversion script.
|
||||||
3. Run hack/update-all.sh.
|
4. Run hack/update-all.sh.
|
||||||
|
|
||||||
|
|
||||||
2. Generate files for Ugorji codec:
|
2. Generate files for Ugorji codec:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -468,12 +468,11 @@ regenerate auto-generated ones. To regenerate them run:
|
||||||
hack/update-codegen.sh
|
hack/update-codegen.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
update-codegen will also generate code to handle deep copy of your versioned
|
As part of the build, kubernetes will also generate code to handle deep copy of
|
||||||
api objects. The deep copy code resides with each versioned API:
|
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
|
- `<path_to_versioned_api>/zz_generated.deep_copy.go` containing auto-generated copy functions
|
||||||
- `pkg/apis/extensions/<version>/deep_copy_generated.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
|
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
|
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
|
manually-written ones, it's fine to just remove the whole file and let the
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue