• Rostislav M. Georgiev's avatar
    kubeadm: Fix omitempty in v1beta2 · 81e3adc5
    Rostislav M. Georgiev authored
    There are a couple of problems with regards to the `omitempty` in v1beta1:
    
    - It is not applied to certain fields. This makes emitting YAML configuration
      files in v1beta1 config format verbose by both kubeadm and third party Go
      lang tools. Certain fields, that were never given an explicit value would
      show up in the marshalled YAML document. This can cause confusion and even
      misconfiguration.
    
    - It can be used in inappropriate places. In this case it's used for fields,
      that need to be always serialized. The only one such field at the moment is
      `NodeRegistrationOptions.Taints`. If the `Taints` field is nil, then it's
      defaulted to a slice containing a single control plane node taint. If it's
      an empty slice, no taints are applied, thus, the cluster behaves differently.
      With that in mind, a Go program, that uses v1beta1 with `omitempty` on the
      `Taints` field has no way to specify an explicit empty slice of taints, as
      this would get lost after marshalling to YAML.
    
    To fix these issues the following is done in this change:
    
    - A whole bunch of additional omitemptys are placed at many fields in v1beta2.
    - `omitempty` is removed from `NodeRegistrationOptions.Taints`
    - A test, that verifies the ability to specify empty slice value for `Taints`
      is included.
    Signed-off-by: 's avatarRostislav M. Georgiev <rostislavg@vmware.com>
    81e3adc5