From d28d9ff58de4a12f89d33b97f2a453895e60b05f Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 8 Aug 2024 09:35:08 +0200 Subject: [PATCH] Use `printers.DyffPrinter` to format the output. Also updates the list of options passed to `dyff.CompareInputFiles` to be the same as in the internal `build` package. Signed-off-by: Florian Forster --- cmd/flux/diff_artifact.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cmd/flux/diff_artifact.go b/cmd/flux/diff_artifact.go index 88116be7..1aebd3de 100644 --- a/cmd/flux/diff_artifact.go +++ b/cmd/flux/diff_artifact.go @@ -31,6 +31,7 @@ import ( "github.com/spf13/cobra" "github.com/fluxcd/flux2/v2/internal/flags" + "github.com/fluxcd/flux2/v2/pkg/printers" ) var ErrDiffArtifactChanged = errors.New("the remote and local artifact contents differ") @@ -142,6 +143,7 @@ func diffArtifact(ctx context.Context, client *oci.Client, remoteURL, localPath defer cleanup() report, err := dyff.CompareInputFiles(remoteFile, localFile, + dyff.IgnoreOrderChanges(false), dyff.KubernetesEntityDetection(true), ) if err != nil { @@ -154,13 +156,8 @@ func diffArtifact(ctx context.Context, client *oci.Client, remoteURL, localPath var buf bytes.Buffer - hr := &dyff.HumanReport{ - Report: report, - OmitHeader: true, - MultilineContextLines: 3, - } - if err := hr.WriteReport(&buf); err != nil { - return "", fmt.Errorf("WriteReport(): %w", err) + if err := printers.NewDyffPrinter().Print(&buf, report); err != nil { + return "", fmt.Errorf("formatting dyff report: %w", err) } return buf.String(), nil