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 <fforster@gitlab.com>
This commit is contained in:
@@ -31,6 +31,7 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/fluxcd/flux2/v2/internal/flags"
|
"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")
|
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()
|
defer cleanup()
|
||||||
|
|
||||||
report, err := dyff.CompareInputFiles(remoteFile, localFile,
|
report, err := dyff.CompareInputFiles(remoteFile, localFile,
|
||||||
|
dyff.IgnoreOrderChanges(false),
|
||||||
dyff.KubernetesEntityDetection(true),
|
dyff.KubernetesEntityDetection(true),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -154,13 +156,8 @@ func diffArtifact(ctx context.Context, client *oci.Client, remoteURL, localPath
|
|||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
||||||
hr := &dyff.HumanReport{
|
if err := printers.NewDyffPrinter().Print(&buf, report); err != nil {
|
||||||
Report: report,
|
return "", fmt.Errorf("formatting dyff report: %w", err)
|
||||||
OmitHeader: true,
|
|
||||||
MultilineContextLines: 3,
|
|
||||||
}
|
|
||||||
if err := hr.WriteReport(&buf); err != nil {
|
|
||||||
return "", fmt.Errorf("WriteReport(): %w", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf.String(), nil
|
return buf.String(), nil
|
||||||
|
|||||||
Reference in New Issue
Block a user