From b55f49b4fe39c841060ca2a8a0b14680f40431be Mon Sep 17 00:00:00 2001 From: Yiannis Date: Thu, 23 Mar 2023 19:44:01 +0000 Subject: [PATCH] fix: Remove any leading and trailing whitespace from resource before exporting Signed-off-by: Yiannis --- cmd/flux/export.go | 1 + cmd/flux/testdata/create_source_git/export.golden | 1 - cmd/flux/testdata/create_source_helm/https.golden | 1 - cmd/flux/testdata/create_source_helm/oci-with-secret.golden | 1 - cmd/flux/testdata/create_source_helm/oci.golden | 1 - cmd/flux/testdata/export/alert.yaml | 1 - cmd/flux/testdata/export/bucket.yaml | 1 - cmd/flux/testdata/export/git-repo.yaml | 1 - cmd/flux/testdata/export/helm-release.yaml | 1 - cmd/flux/testdata/export/helm-repo.yaml | 1 - cmd/flux/testdata/export/image-policy.yaml | 1 - cmd/flux/testdata/export/image-repo.yaml | 1 - cmd/flux/testdata/export/image-update.yaml | 1 - cmd/flux/testdata/export/ks.yaml | 1 - cmd/flux/testdata/export/provider.yaml | 1 - cmd/flux/testdata/export/receiver.yaml | 1 - cmd/flux/testdata/oci/export.golden | 1 - cmd/flux/testdata/oci/export_with_secret.golden | 1 - 18 files changed, 1 insertion(+), 17 deletions(-) diff --git a/cmd/flux/export.go b/cmd/flux/export.go index 4291ee5f..bfb2b60b 100644 --- a/cmd/flux/export.go +++ b/cmd/flux/export.go @@ -122,5 +122,6 @@ func printExport(export interface{}) error { func resourceToString(data []byte) string { data = bytes.Replace(data, []byte(" creationTimestamp: null\n"), []byte(""), 1) data = bytes.Replace(data, []byte("status: {}\n"), []byte(""), 1) + data = bytes.TrimSpace(data) return string(data) } diff --git a/cmd/flux/testdata/create_source_git/export.golden b/cmd/flux/testdata/create_source_git/export.golden index 2b0193df..c909bd25 100644 --- a/cmd/flux/testdata/create_source_git/export.golden +++ b/cmd/flux/testdata/create_source_git/export.golden @@ -12,4 +12,3 @@ spec: ref: branch: master url: https://github.com/stefanprodan/podinfo - diff --git a/cmd/flux/testdata/create_source_helm/https.golden b/cmd/flux/testdata/create_source_helm/https.golden index a0aad146..87235245 100644 --- a/cmd/flux/testdata/create_source_helm/https.golden +++ b/cmd/flux/testdata/create_source_helm/https.golden @@ -7,4 +7,3 @@ metadata: spec: interval: 5m0s url: https://stefanprodan.github.io/charts/podinfo - diff --git a/cmd/flux/testdata/create_source_helm/oci-with-secret.golden b/cmd/flux/testdata/create_source_helm/oci-with-secret.golden index 0c182048..760a265c 100644 --- a/cmd/flux/testdata/create_source_helm/oci-with-secret.golden +++ b/cmd/flux/testdata/create_source_helm/oci-with-secret.golden @@ -10,4 +10,3 @@ spec: name: creds type: oci url: oci://ghcr.io/stefanprodan/charts/podinfo - diff --git a/cmd/flux/testdata/create_source_helm/oci.golden b/cmd/flux/testdata/create_source_helm/oci.golden index af361810..f6049e99 100644 --- a/cmd/flux/testdata/create_source_helm/oci.golden +++ b/cmd/flux/testdata/create_source_helm/oci.golden @@ -8,4 +8,3 @@ spec: interval: 5m0s type: oci url: oci://ghcr.io/stefanprodan/charts/podinfo - diff --git a/cmd/flux/testdata/export/alert.yaml b/cmd/flux/testdata/export/alert.yaml index 930a2853..4619affb 100644 --- a/cmd/flux/testdata/export/alert.yaml +++ b/cmd/flux/testdata/export/alert.yaml @@ -14,4 +14,3 @@ spec: providerRef: name: slack summary: Slacktest Notification - diff --git a/cmd/flux/testdata/export/bucket.yaml b/cmd/flux/testdata/export/bucket.yaml index 2e94a38e..5547ee94 100644 --- a/cmd/flux/testdata/export/bucket.yaml +++ b/cmd/flux/testdata/export/bucket.yaml @@ -11,4 +11,3 @@ spec: provider: aws region: us-east-1 timeout: 30s - diff --git a/cmd/flux/testdata/export/git-repo.yaml b/cmd/flux/testdata/export/git-repo.yaml index ee74c4b0..e3a12bcd 100644 --- a/cmd/flux/testdata/export/git-repo.yaml +++ b/cmd/flux/testdata/export/git-repo.yaml @@ -13,4 +13,3 @@ spec: name: flux-system timeout: 1m0s url: ssh://git@github.com/example/repo - diff --git a/cmd/flux/testdata/export/helm-release.yaml b/cmd/flux/testdata/export/helm-release.yaml index 8f861110..b6c3b126 100644 --- a/cmd/flux/testdata/export/helm-release.yaml +++ b/cmd/flux/testdata/export/helm-release.yaml @@ -15,4 +15,3 @@ spec: namespace: {{ .fluxns }} version: '*' interval: 5m0s - diff --git a/cmd/flux/testdata/export/helm-repo.yaml b/cmd/flux/testdata/export/helm-repo.yaml index eb3d5634..c5366e0b 100644 --- a/cmd/flux/testdata/export/helm-repo.yaml +++ b/cmd/flux/testdata/export/helm-repo.yaml @@ -9,4 +9,3 @@ spec: provider: generic timeout: 1m0s url: https://stefanprodan.github.io/podinfo - diff --git a/cmd/flux/testdata/export/image-policy.yaml b/cmd/flux/testdata/export/image-policy.yaml index d61b535e..8feff350 100644 --- a/cmd/flux/testdata/export/image-policy.yaml +++ b/cmd/flux/testdata/export/image-policy.yaml @@ -10,4 +10,3 @@ spec: policy: semver: range: 5.0.x - diff --git a/cmd/flux/testdata/export/image-repo.yaml b/cmd/flux/testdata/export/image-repo.yaml index ca472928..5263245c 100644 --- a/cmd/flux/testdata/export/image-repo.yaml +++ b/cmd/flux/testdata/export/image-repo.yaml @@ -10,4 +10,3 @@ spec: image: ghcr.io/test/podinfo interval: 1m0s provider: generic - diff --git a/cmd/flux/testdata/export/image-update.yaml b/cmd/flux/testdata/export/image-update.yaml index 35566278..e2fcb3c1 100644 --- a/cmd/flux/testdata/export/image-update.yaml +++ b/cmd/flux/testdata/export/image-update.yaml @@ -17,4 +17,3 @@ spec: update: path: ./clusters/my-cluster strategy: Setters - diff --git a/cmd/flux/testdata/export/ks.yaml b/cmd/flux/testdata/export/ks.yaml index cd6085d2..891f76b5 100644 --- a/cmd/flux/testdata/export/ks.yaml +++ b/cmd/flux/testdata/export/ks.yaml @@ -11,4 +11,3 @@ spec: sourceRef: kind: GitRepository name: flux-system - diff --git a/cmd/flux/testdata/export/provider.yaml b/cmd/flux/testdata/export/provider.yaml index 5656415c..67104453 100644 --- a/cmd/flux/testdata/export/provider.yaml +++ b/cmd/flux/testdata/export/provider.yaml @@ -8,4 +8,3 @@ spec: address: https://hooks.slack.com/services/mock channel: A channel with spacess type: slack - diff --git a/cmd/flux/testdata/export/receiver.yaml b/cmd/flux/testdata/export/receiver.yaml index 0561d3db..e47add3d 100644 --- a/cmd/flux/testdata/export/receiver.yaml +++ b/cmd/flux/testdata/export/receiver.yaml @@ -15,4 +15,3 @@ spec: secretRef: name: webhook-token type: github - diff --git a/cmd/flux/testdata/oci/export.golden b/cmd/flux/testdata/oci/export.golden index 0f898188..7a043b64 100644 --- a/cmd/flux/testdata/oci/export.golden +++ b/cmd/flux/testdata/oci/export.golden @@ -9,4 +9,3 @@ spec: ref: tag: 6.3.5 url: oci://ghcr.io/stefanprodan/manifests/podinfo - diff --git a/cmd/flux/testdata/oci/export_with_secret.golden b/cmd/flux/testdata/oci/export_with_secret.golden index 436d6310..0b41116f 100644 --- a/cmd/flux/testdata/oci/export_with_secret.golden +++ b/cmd/flux/testdata/oci/export_with_secret.golden @@ -11,4 +11,3 @@ spec: secretRef: name: creds url: oci://ghcr.io/stefanprodan/manifests/podinfo -