kubernetes/pkg/api
Kubernetes Submit Queue 2ea4e1f066 Merge pull request #33352 from smarterclayton/unified_defaulters
Automatic merge from submit-queue

Split conversion and defaulting

Separate conversion and defaulting.   Defaulting occurs mixed with conversion today - change the server so that the `VersioningCodec` performs defaulting on the external type during decoding.  

* Add a new method to `Scheme` - `func (*runtime.Scheme) Default(runtime.Object)` - that takes an object and performs defaulting.  
* Call `Default` during decoding and at static initialization time
* Use the new `defaulter-gen` to generate top level object defaulters (`v1.Pod`) at build time for any type that needs to perform defaulting.  
* Add tests and alter the existing code to adapt as necessary
* Fix a few bugs in conversions that depended on defaulting behavior

---

Step 1 of decoupling conversion and defaulting. The generator will assist in creating top level defaulters that in a single method invoke all nested defaulters, preventing the need to recurse via reflection or conversion. These top level defaulters will be registered in the scheme and invoked instead of the nested recursion path. This will set the stage for a future generator, capable of creating defaulters from embedded struct tags on external types. However, we must gradually switch these over.

The immediate goal here is to split defaulting and conversion so that the unsafe convertor can be used to maximum potential (we would be able to use direct memory conversion for any identical nested struct, even those that must be defaulted).

The generator uses `k8s:defaulter-gen=TypeMeta` on most public packages to flag any top level type that has defaulters to get a `SetObjectDefaults_NAME` function created (types that don't have defaulters won't have functions).  This also creates a `RegisterDefaults` method that applies a default to an interface{} and returns true if the object was handled.  Existing defaults are left as is.

Add a test to verify old and new path generate the same outcomes.  Defaulter will move to gengo before this is merged, and subsequent PRs will remove defaulting during conversion and have the VersioningCodec apply defaults.
2016-10-18 20:34:13 -07:00
..
annotations Use Go canonical import paths 2016-07-16 13:48:21 -04:00
endpoints Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
errors Change minion to node 2016-09-28 10:53:30 -07:00
events kubectl: move events sorting interface to the api for general use 2016-09-18 19:25:42 +02:00
install remove dead mapper 2016-09-19 09:57:19 -04:00
meta Allow garbage collection to work against different API prefixes 2016-09-22 15:00:58 -04:00
pod Fix various typos in pkg/api 2016-08-29 11:31:16 +02:00
resource update generated protobuf 2016-10-13 21:22:59 -07:00
rest Revert "Work around the etcd watch issue" 2016-09-26 23:54:10 -07:00
service GCE Cloud provider changes for ESIPP 2016-08-23 16:16:39 -07:00
testapi kubeadm: fix conversion macros and add kubeadm to round trip testing 2016-10-12 13:26:23 -07:00
testing change rbac roleref type 2016-09-09 09:55:51 -04:00
unversioned Flag all packages as needing defaulters 2016-10-18 21:07:33 -04:00
util Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
v1 Invoke init container defaulting in conversion 2016-10-18 21:07:35 -04:00
validation support seccomp in psp 2016-10-17 14:49:02 -04:00
context_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
context.go print instruction in case of failed kubectl 1.3 rolling-update against 1.4 cluster 2016-09-15 17:20:39 -07:00
conversion_test.go remove testapi.Default.GroupVersion 2016-10-07 10:10:54 -04:00
conversion.go fix register.go files up + add test import 2016-08-11 17:06:54 -07:00
copy_test.go remove testapi.Default.GroupVersion 2016-10-07 10:10:54 -04:00
deep_copy_test.go Update etcd default ports for v3, and validate tests 2016-08-17 07:49:19 -05:00
defaulting_test.go Make defaulting part of versioning codec 2016-10-18 21:07:35 -04:00
defaults.go fix register.go files up + add test import 2016-08-11 17:06:54 -07:00
doc.go Use Go canonical import paths 2016-07-16 13:48:21 -04:00
field_constants.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
generate_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
generate.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
helpers_test.go Return error for empty sysctl names 2016-09-30 17:56:37 +02:00
helpers.go Removed empty line. 2016-10-18 17:14:05 +08:00
mapper.go remove dead mapper 2016-09-19 09:57:19 -04:00
meta_test.go remove testapi.Default.GroupVersion 2016-10-07 10:10:54 -04:00
meta.go add ClusterName field to ObjectMeta 2016-08-22 21:09:57 -07:00
node_example.json Change minion to node 2016-09-28 10:53:30 -07:00
OWNERS Move blunderbuss assignees into tree 2016-03-02 20:46:32 -05:00
ref_test.go Use make as the main build tool 2016-07-12 21:52:00 -07:00
ref.go move api.OjbectReference.ObjectKind() to ref.go 2016-07-14 23:02:05 -07:00
register.go Fix various typos in pkg/api 2016-08-29 11:31:16 +02:00
replication_controller_example.json Initial Quobyte support 2016-08-18 17:13:50 +02:00
requestcontext.go Cleanup handler chain 2016-09-23 12:03:58 +02:00
resource_helpers_test.go extensions: add minReadySeconds/availableReplicas to replica sets 2016-09-28 11:06:40 +02:00
resource_helpers.go extensions: add minReadySeconds/availableReplicas to replica sets 2016-09-28 11:06:40 +02:00
serialization_proto_test.go kubeadm: fix conversion macros and add kubeadm to round trip testing 2016-10-12 13:26:23 -07:00
serialization_test.go allow apigroups to opt out of proto round trip testing 2016-10-12 10:01:38 -07:00
types.generated.go Generated code for RS/RC conditions 2016-10-10 18:34:01 +02:00
types.go Add +optional tag to all fields with omitempty json tag 2016-10-17 08:52:13 -07:00
zz_generated.deepcopy.go Generated code for RS/RC conditions 2016-10-10 18:34:01 +02:00