From 358e46e62844640b3228ce984c3d717edb30676a Mon Sep 17 00:00:00 2001 From: Bryan Leong Date: Tue, 16 Dec 2025 19:18:14 +0800 Subject: [PATCH] Style: clean up dry-run (#7007) - Remove trailing whitespace on dryrun outputs - Fixed the relevant plugin-test outputs - Refactor to avoid partial lines that codecov flags out Signed-off-by: Bryan Leong --- e2e/application/application_auto_update_test.go | 6 +++--- e2e/plugin/plugin_test.go | 6 +++--- pkg/appfile/dryrun/dryrun.go | 10 ++++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/e2e/application/application_auto_update_test.go b/e2e/application/application_auto_update_test.go index 2e9ce048d..c47c8c0b5 100644 --- a/e2e/application/application_auto_update_test.go +++ b/e2e/application/application_auto_update_test.go @@ -161,7 +161,7 @@ var _ = Describe("Application Auto update", Ordered, func() { Eventually(func() error { appRev := &v1beta1.ApplicationRevision{} return k8sClient.Get(ctx, client.ObjectKey{Name: "app-with-auto-update-v2", Namespace: namespace}, appRev) - }, 60*time.Second, 2*time.Second).Should(BeNil()) + }, 90*time.Second, 2*time.Second).Should(BeNil()) By("Execute a live-diff command for previous two application versions") output, err := e2e.Exec(fmt.Sprintf("%s live-diff --revision app-with-auto-update-v2,app-with-auto-update-v1", velaCommandPrefix)) @@ -203,7 +203,7 @@ func randomNamespaceName(basic string) string { } var dryRunResult1 = `--- -# Application(app-with-auto-update) -- Component(test) +# Application(app-with-auto-update) -- Component(test) --- apiVersion: v1 @@ -226,7 +226,7 @@ metadata: ---` var dryRunResult2 = `--- -# Application(app-with-auto-update) -- Component(test) +# Application(app-with-auto-update) -- Component(test) --- apiVersion: v1 diff --git a/e2e/plugin/plugin_test.go b/e2e/plugin/plugin_test.go index 06c033c36..9d6dec8c5 100644 --- a/e2e/plugin/plugin_test.go +++ b/e2e/plugin/plugin_test.go @@ -566,7 +566,7 @@ spec: ` var dryRunResult = `--- -# Application(test-vela-app) -- Component(express-server) +# Application(test-vela-app) -- Component(express-server) --- apiVersion: apps/v1 @@ -598,7 +598,7 @@ spec: - containerPort: 80 --- -## From the trait test-ingress +## From the trait test-ingress apiVersion: v1 kind: Service metadata: @@ -621,7 +621,7 @@ spec: app.oam.dev/component: express-server --- -## From the trait test-ingress +## From the trait test-ingress apiVersion: networking.k8s.io/v1 kind: Ingress metadata: diff --git a/pkg/appfile/dryrun/dryrun.go b/pkg/appfile/dryrun/dryrun.go index 0f3bf174d..194f84609 100644 --- a/pkg/appfile/dryrun/dryrun.go +++ b/pkg/appfile/dryrun/dryrun.go @@ -178,7 +178,8 @@ func (d *Option) PrintDryRun(buff *bytes.Buffer, appName string, comps []*types. components[comp.Name] = comp.ComponentOutput } for _, c := range comps { - if _, err := fmt.Fprintf(buff, "---\n# Application(%s) -- Component(%s) \n---\n\n", appName, c.Name); err != nil { + _, err := fmt.Fprintf(buff, "---\n# Application(%s) -- Component(%s)\n---\n\n", appName, c.Name) + if err != nil { return errors.Wrap(err, "fail to write buff") } result, err := yaml.Marshal(components[c.Name]) @@ -191,9 +192,9 @@ func (d *Option) PrintDryRun(buff *bytes.Buffer, appName string, comps []*types. traitType := t.GetLabels()[oam.TraitTypeLabel] switch { case traitType == definition.AuxiliaryWorkload: - buff.WriteString("## From the auxiliary workload \n") + buff.WriteString("## From the auxiliary workload\n") case traitType != "": - fmt.Fprintf(buff, "## From the trait %s \n", traitType) + fmt.Fprintf(buff, "## From the trait %s\n", traitType) } result, err := yaml.Marshal(t) if err != nil { @@ -205,7 +206,8 @@ func (d *Option) PrintDryRun(buff *bytes.Buffer, appName string, comps []*types. buff.WriteString("\n") } for _, plc := range policies { - if _, err := fmt.Fprintf(buff, "---\n# Application(%s) -- Policy(%s) \n---\n\n", appName, plc.GetName()); err != nil { + _, err := fmt.Fprintf(buff, "---\n# Application(%s) -- Policy(%s)\n---\n\n", appName, plc.GetName()) + if err != nil { return errors.Wrap(err, "fail to write buff") } result, err := yaml.Marshal(plc)