Skip to content

Commit

Permalink
Clarified syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
sttts committed May 1, 2019
1 parent 2840c9e commit 2e3f530
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions keps/sig-api-machinery/20190426-crd-defaulting.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,22 @@ We propose to

This means in detail for primitive types and no types (i.e. IntOrString or arbitrary JSON) in the structural schema:

* `if _, ok := obj[fld]; !ok` => default
* `if !nullable && v == nil` => default
* `if v, ok := obj[fld]; !ok` => default
* `else if !nullable && v == nil` => default

and for `array` type in the schema one of these:

* `if v, ok := obj[fld]; !ok` => default
* `if !nullable && v == nil` => default
* `if array, ok := v.([]interface{}); !ok` => return deserialization error
* `if len(array) == 0` => default
* `else if !nullable && v == nil` => default
* `else if array, ok := v.([]interface{}); !ok` => return deserialization error
* `else if len(array) == 0` => default

and for `object` type in the schema:

* `if v, ok := obj[fld]; !ok` => default
* `if !nullable && v == nil` => default
* `if object, ok := v.(map[string]interface{}); !ok` => return deserialization error
* `if len(object) == 0` => default.
* `else if !nullable && v == nil` => default
* `else if object, ok := v.(map[string]interface{}); !ok` => return deserialization error
* `else if len(object) == 0` => default.

Hence, we never default zero numbers, integers or empty string if they are specified explicitly in the input.

Expand Down

0 comments on commit 2e3f530

Please sign in to comment.