mirror of https://github.com/kubernetes/kops.git
Don't output empty sections in the manifests
In our kube-dns manifest for 1.6 we often had an empty section, normalization converted this to `{}` which causes `kubectl apply` to fail. We can simply skip empty objects when outputing.
This commit is contained in:
parent
adc4083caa
commit
f348b47332
|
@ -111,6 +111,11 @@ func (a *AssetBuilder) RemapManifest(data []byte) ([]byte, error) {
|
|||
return nil, fmt.Errorf("error remapping images: %v", err)
|
||||
}
|
||||
|
||||
// Don't serialize empty objects - they confuse yaml parsers
|
||||
if manifest.IsEmptyObject() {
|
||||
continue
|
||||
}
|
||||
|
||||
y, err := manifest.ToYAML()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error re-marshaling manifest: %v", err)
|
||||
|
|
|
@ -65,3 +65,8 @@ func (m *Manifest) accept(visitor Visitor) error {
|
|||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// IsEmptyObject checks if the object has no keys set (i.e. `== {}`)
|
||||
func (m *Manifest) IsEmptyObject() bool {
|
||||
return len(m.data) == 0
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue