kubernetes-sigs / kubebuilder-declarative-pattern

A toolkit for building declarative operators with kubebuilder
Apache License 2.0
251 stars 84 forks source link

Validator inserts extra newlines between Objects #360

Closed annasong20 closed 7 months ago

annasong20 commented 7 months ago

What happened:

Validator expects empty lines before and after each document separator --- in the expected output manifests that I specify in "*.out.yaml".

#example.out.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: x

---

apiVersion: v1
kind: Namespace
metadata:
  name: y

What you expected to happen:

I expected that I should be able to specify consecutive objects in my "*.out.yaml" file without the extra newlines.

#example.out.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: x
---
apiVersion: v1
kind: Namespace
metadata:
  name: y

How to reproduce it (as minimally and precisely as possible):

You can see that the existing guestbook test with validator

expects newlines before and after each document separator https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern/blob/f6a5c89244f2221088444042166f89743d409515/examples/guestbook-operator/controllers/tests/patches-stable.out.yaml#L32

Anything else we need to know?:

This line

that adds additional newlines, even though yamilzer.Encode already adds a newline after the object, is likely the culprit.