From a5f386023795da4352feaa1e0ab2dab03372d12b Mon Sep 17 00:00:00 2001 From: Rob Scott Date: Wed, 29 Sep 2021 08:44:05 -0700 Subject: [PATCH] Updating WriteYAML to not add delimiter to start files --- pkg/crd/testdata/gen/bar.example.com_foos.v1beta1.yaml | 1 - pkg/crd/testdata/gen/bar.example.com_foos.yaml | 1 - pkg/genall/genall.go | 2 +- pkg/webhook/parser_integration_test.go | 2 +- .../invalid-admissionReviewVersionsRequired/manifests.yaml | 2 -- pkg/webhook/testdata/invalid-sideEffects/manifests.yaml | 2 -- pkg/webhook/testdata/invalid-v1beta1NotSupported/manifests.yaml | 2 -- pkg/webhook/testdata/manifests.yaml | 2 -- pkg/webhook/testdata/valid/manifests.yaml | 2 -- 9 files changed, 2 insertions(+), 14 deletions(-) diff --git a/pkg/crd/testdata/gen/bar.example.com_foos.v1beta1.yaml b/pkg/crd/testdata/gen/bar.example.com_foos.v1beta1.yaml index 11b2c7c2d..3236c35c7 100644 --- a/pkg/crd/testdata/gen/bar.example.com_foos.v1beta1.yaml +++ b/pkg/crd/testdata/gen/bar.example.com_foos.v1beta1.yaml @@ -1,4 +1,3 @@ - --- apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition diff --git a/pkg/crd/testdata/gen/bar.example.com_foos.yaml b/pkg/crd/testdata/gen/bar.example.com_foos.yaml index 7fe830f29..961c48e15 100644 --- a/pkg/crd/testdata/gen/bar.example.com_foos.yaml +++ b/pkg/crd/testdata/gen/bar.example.com_foos.yaml @@ -1,4 +1,3 @@ - --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition diff --git a/pkg/genall/genall.go b/pkg/genall/genall.go index 2cf4ec7e7..e03888d4e 100644 --- a/pkg/genall/genall.go +++ b/pkg/genall/genall.go @@ -135,7 +135,7 @@ func (g GenerationContext) WriteYAML(itemPath string, objs ...interface{}) error if err != nil { return err } - n, err := out.Write(append([]byte("\n---\n"), yamlContent...)) + n, err := out.Write(append([]byte("---\n"), yamlContent...)) if err != nil { return err } diff --git a/pkg/webhook/parser_integration_test.go b/pkg/webhook/parser_integration_test.go index e91302707..f2f6c438c 100644 --- a/pkg/webhook/parser_integration_test.go +++ b/pkg/webhook/parser_integration_test.go @@ -178,7 +178,7 @@ var _ = Describe("Webhook Generation From Parsing to CustomResourceDefinition", }) func unmarshalBothV1(in []byte) (mutating admissionregv1.MutatingWebhookConfiguration, validating admissionregv1.ValidatingWebhookConfiguration) { - documents := bytes.Split(in, []byte("\n---\n"))[1:] + documents := bytes.Split(in, []byte("\n---\n")) ExpectWithOffset(1, documents).To(HaveLen(2), "expected two documents in file, found %d", len(documents)) ExpectWithOffset(1, yaml.UnmarshalStrict(documents[0], &mutating)).To(Succeed(), "expected the first document in the file to be a mutating webhook configuration") diff --git a/pkg/webhook/testdata/invalid-admissionReviewVersionsRequired/manifests.yaml b/pkg/webhook/testdata/invalid-admissionReviewVersionsRequired/manifests.yaml index 8a579ae92..059794d6d 100644 --- a/pkg/webhook/testdata/invalid-admissionReviewVersionsRequired/manifests.yaml +++ b/pkg/webhook/testdata/invalid-admissionReviewVersionsRequired/manifests.yaml @@ -1,4 +1,3 @@ - --- apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration @@ -28,7 +27,6 @@ webhooks: resources: - cronjobs sideEffects: None - --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration diff --git a/pkg/webhook/testdata/invalid-sideEffects/manifests.yaml b/pkg/webhook/testdata/invalid-sideEffects/manifests.yaml index 8a579ae92..059794d6d 100644 --- a/pkg/webhook/testdata/invalid-sideEffects/manifests.yaml +++ b/pkg/webhook/testdata/invalid-sideEffects/manifests.yaml @@ -1,4 +1,3 @@ - --- apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration @@ -28,7 +27,6 @@ webhooks: resources: - cronjobs sideEffects: None - --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration diff --git a/pkg/webhook/testdata/invalid-v1beta1NotSupported/manifests.yaml b/pkg/webhook/testdata/invalid-v1beta1NotSupported/manifests.yaml index 8a579ae92..059794d6d 100644 --- a/pkg/webhook/testdata/invalid-v1beta1NotSupported/manifests.yaml +++ b/pkg/webhook/testdata/invalid-v1beta1NotSupported/manifests.yaml @@ -1,4 +1,3 @@ - --- apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration @@ -28,7 +27,6 @@ webhooks: resources: - cronjobs sideEffects: None - --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration diff --git a/pkg/webhook/testdata/manifests.yaml b/pkg/webhook/testdata/manifests.yaml index 8a579ae92..059794d6d 100644 --- a/pkg/webhook/testdata/manifests.yaml +++ b/pkg/webhook/testdata/manifests.yaml @@ -1,4 +1,3 @@ - --- apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration @@ -28,7 +27,6 @@ webhooks: resources: - cronjobs sideEffects: None - --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration diff --git a/pkg/webhook/testdata/valid/manifests.yaml b/pkg/webhook/testdata/valid/manifests.yaml index 8a579ae92..059794d6d 100644 --- a/pkg/webhook/testdata/valid/manifests.yaml +++ b/pkg/webhook/testdata/valid/manifests.yaml @@ -1,4 +1,3 @@ - --- apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration @@ -28,7 +27,6 @@ webhooks: resources: - cronjobs sideEffects: None - --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration