Skip to content

Commit

Permalink
Clarify that we aim at a real defaulter
Browse files Browse the repository at this point in the history
  • Loading branch information
sttts committed Apr 27, 2019
1 parent 7d90984 commit 7b72256
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions keps/sig-api-machinery/20190426-crd-defaulting.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ This KEP proposes to apply these default values during deserialization, in the s

### Non-Goals

* allow non-constant defaults. Native Golang code can of course set defaults which depends on other fields of a JSON object. This is out of scope here and would need some kind of defaulting webhook.
* allow non-constant defaults: native Golang code can of course set defaults which depends on other fields of a JSON object. This is out of scope here and would need some kind of defaulting webhook.
* native-type declarative defaulting: this KEP is about CRDs. Though it might be desireable to support the same `// +default=<some-json-value>` tag and a mechanism in `k8s.io/apiserver` to evaluate defaults in native, generic registries, this is out-of-scope of the KEP though.

## Proposal

Expand All @@ -90,7 +91,7 @@ We propose to
* undefined (`_, ok := obj[field]; !ok`)
* `nil` if the field not nullable.

We do this in the serializer just after the binary payload has been unmarshalled into an `map[string]interface{}`, pruning of [KEP: Pruning for CustomResources](https://github.com/kubernetes/enhancements/pull/709) was done, compare the yellow boxes in the following figure:
We do this in the serializer by passing a real defaulter to [`versioningserializer.NewCodec`](https://github.com/kubernetes/apimachinery/blob/master/pkg/runtime/serializer/versioning/versioning.go#L49) such that defaulting is done natively just after the binary payload has been unmarshalled into an `map[string]interface{}` and pruning of [KEP: Pruning for CustomResources](https://github.com/kubernetes/enhancements/pull/709) was done, compare the yellow boxes in the following figure:

![Decoding steps which must apply defaults](20190426-crd-defaulting-pipeline.png)

Expand Down

0 comments on commit 7b72256

Please sign in to comment.