mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-21 23:21:48 +00:00
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:
parent
2c4194e0a5
commit
d28d9ff58d
1 changed files with 4 additions and 7 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue