func (chk *WalkCompare) Compare(ctx context.Context, path string, data []byte, reportOut io.Writer, opts map[string]string) error {
	beforeWalk := &fspb.Walk{}

	err := proto.Unmarshal(data, beforeWalk)
	if err != nil {
		return errors.Wrap(err, "walk data unmarshal error")
	}

	clearHostname(beforeWalk)

	afterWalk, err := performWalk(ctx, path)
	if err != nil {
		return errors.Wrap(err, "walk with hashing error during compare phase")
	}

	report, err := reporter.Report(ctx, &fspb.ReportConfig{}, beforeWalk, afterWalk)
	if err != nil {
		return errors.Wrap(err, "report error")
	}

	chk.filterReportDiffs(report)

	err = validateReport(report)
	if err != nil && reportOut != nil {
		printReportSummary(report, reportOut)

		// Don't spew these fields. They can be enormous and
		// are probably redundant
		report.WalkBefore = nil
		report.WalkAfter = nil

		b, marshalErr := json.MarshalIndent(report, "", "   ")
		if marshalErr != nil {
			_, reportErr := reportOut.Write([]byte(marshalErr.Error()))
			if reportErr != nil {
				return errors.Wrapf(reportErr, "error while writing out marshal error (%v)", marshalErr.Error())
			}

			return errors.Wrap(marshalErr, "error JSON marshaling report")
		}

		if _, wrErr := reportOut.Write(b); wrErr != nil {
			return errors.Wrap(err, "error writing report to output")
		}

		return errors.Wrap(err, "validation error")
	}

	return err
}
// Compare meets the checker.Comparer interface. It performs a fswalker Walk
// on the provided file path, unmarshals the comparison data as a fswalker Walk,
// and generates a fswalker report comparing the two Walks. If there are any differences
// an error is returned, and the full report will be written to the provided writer
// as JSON.
Compare meets the checker.Comparer interface. It performs a fswalker Walk
on the provided file path, unmarshals the comparison data as a fswalker Walk,
and generates a fswalker report comparing the two Walks. If there are any differences
an error is returned, and the full report will be written to the provided writer
as JSON.
// Compare meets the checker . Comparer interface . It performs a fswalker Walk // on the provided file path unmarshals the comparison data as a fswalker Walk // and generates a fswalker report comparing the two Walks . If there are any differences // an error is returned and the full report will be written to the provided writer // as JSON .
func (chk *WalkCompare) Compare(ctx context.Context, path string, data []byte, reportOut io.Writer, opts map[string]string) error {
	beforeWalk := &fspb.Walk{}
	err := proto.Unmarshal(data, beforeWalk)
	if err != nil {
		return errors.Wrap(err, "walk data unmarshal error")
	}
	clearHostname(beforeWalk)
	afterWalk, err := performWalk(ctx, path)
	if err != nil {
		return errors.Wrap(err, "walk with hashing error during compare phase")
	}
	report, err := reporter.Report(ctx, &fspb.ReportConfig{}, beforeWalk, afterWalk)
	if err != nil {
		return errors.Wrap(err, "report error")
	}
	chk.filterReportDiffs(report)
	err = validateReport(report)
	if err != nil && reportOut != nil {
		printReportSummary(report, reportOut)
		report.WalkBefore = nil
		report.WalkAfter = nil
		b, marshalErr := json.MarshalIndent(report, "", "   ")
		if marshalErr != nil {
			_, reportErr := reportOut.Write([]byte(marshalErr.Error()))
			if reportErr != nil {
				return errors.Wrapf(reportErr, "error while writing out marshal error (%v)", marshalErr.Error())
			}
			return errors.Wrap(marshalErr, "error JSON marshaling report")
		}
		if _, wrErr := reportOut.Write(b); wrErr != nil {
			return errors.Wrap(err, "error writing report to output")
		}
		return errors.Wrap(err, "validation error")
	}
	return err
}
func ( chk * WalkCompare ) Compare ( ctx context . Context , path string , data [ ] byte , reportOut io . Writer , opts map [ string ] string ) error { beforeWalk := & fspb . Walk { } err := proto . Unmarshal ( data , beforeWalk ) if err != nil { return errors . Wrap ( err , " " ) } clearHostname ( beforeWalk ) afterWalk , err := performWalk ( ctx , path ) if err != nil { return errors . Wrap ( err , " " ) } report , err := reporter . Report ( ctx , & fspb . ReportConfig { } , beforeWalk , afterWalk ) if err != nil { return errors . Wrap ( err , " " ) } chk . filterReportDiffs ( report ) err = validateReport ( report ) if err != nil && reportOut != nil { printReportSummary ( report , reportOut ) report . WalkBefore = nil report . WalkAfter = nil b , marshalErr := json . MarshalIndent ( report , " " , " " ) if marshalErr != nil { _ , reportErr := reportOut . Write ( [ ] byte ( marshalErr . Error ( ) ) ) if reportErr != nil { return errors . Wrapf ( reportErr , " " , marshalErr . Error ( ) ) } return errors . Wrap ( marshalErr , " " ) } if _ , wrErr := reportOut . Write ( b ) ; wrErr != nil { return errors . Wrap ( err , " " ) } return errors . Wrap ( err , " " ) } return err }
Compare meets the checker.Comparer interface.
Compare meets the checker . Comparer interface .
// Don't spew these fields. They can be enormous and // are probably redundant