diff --git a/commands/previewPush.go b/commands/previewPush.go index ebeff28cd..594383224 100644 --- a/commands/previewPush.go +++ b/commands/previewPush.go @@ -77,6 +77,15 @@ func (args *PreviewArgs) flags() []cli.Flag { Destination: &args.Full, Usage: `Add headings, providers names, notifications of no changes, etc`, }) + flags = append(flags, &cli.IntFlag{ + Name: "reportmax", + Hidden: true, + Usage: `Limit the IGNORE/NO_PURGE report to this many lines (Expermental. Will change in the future.)`, + Action: func(ctx *cli.Context, max int) error { + printer.MaxReport = max + return nil + }, + }) flags = append(flags, &cli.Int64Flag{ Name: "bindserial", Destination: &bindserial.ForcedValue, diff --git a/pkg/diff2/handsoff.go b/pkg/diff2/handsoff.go index 917c33af7..7e2b4f649 100644 --- a/pkg/diff2/handsoff.go +++ b/pkg/diff2/handsoff.go @@ -98,8 +98,6 @@ The actual implementation combines this all into one loop: Append "foreign list" to "desired". */ -const maxReport = 5 - // handsoff processes the IGNORE*()//NO_PURGE/ENSURE_ABSENT features. func handsoff( domain string, @@ -116,14 +114,19 @@ func handsoff( return nil, nil, err } + var punct = ":" + if printer.MaxReport == 0 { + punct = "." + } + // Process IGNORE*() and NO_PURGE features: ignorable, foreign := processIgnoreAndNoPurge(domain, existing, desired, absences, unmanagedConfigs, noPurge) if len(foreign) != 0 { - msgs = append(msgs, fmt.Sprintf("%d records not being deleted because of NO_PURGE:", len(foreign))) + msgs = append(msgs, fmt.Sprintf("%d records not being deleted because of NO_PURGE%s", len(foreign), punct)) msgs = append(msgs, reportSkips(foreign, !printer.SkinnyReport)...) } if len(ignorable) != 0 { - msgs = append(msgs, fmt.Sprintf("%d records not being deleted because of IGNORE*():", len(ignorable))) + msgs = append(msgs, fmt.Sprintf("%d records not being deleted because of IGNORE*()%s", len(ignorable), punct)) msgs = append(msgs, reportSkips(ignorable, !printer.SkinnyReport)...) } @@ -146,21 +149,23 @@ func handsoff( return desired, msgs, nil } -// reportSkips reports records being skipped, if !full only the first maxReport are output. +// reportSkips reports records being skipped, if !full only the first +// printer.MaxReport are output. func reportSkips(recs models.Records, full bool) []string { var msgs []string - shorten := (!full) && (len(recs) > maxReport) + shorten := (!full) && (len(recs) > printer.MaxReport) + last := len(recs) if shorten { - last = maxReport + last = printer.MaxReport } for _, r := range recs[:last] { msgs = append(msgs, fmt.Sprintf(" %s. %s %s", r.GetLabelFQDN(), r.Type, r.GetTargetCombined())) } - if shorten { - msgs = append(msgs, fmt.Sprintf(" ...and %d more... (use --full to show all)", len(recs)-maxReport)) + if shorten && printer.MaxReport != 0 { + msgs = append(msgs, fmt.Sprintf(" ...and %d more... (use --full to show all)", len(recs)-printer.MaxReport)) } return msgs diff --git a/pkg/printer/printer.go b/pkg/printer/printer.go index da839ab66..ec8b2a8de 100644 --- a/pkg/printer/printer.go +++ b/pkg/printer/printer.go @@ -72,6 +72,9 @@ var ( // variable name is easy to grep for when we make the conversion. var SkinnyReport = true +// MaxReport represents how many records to show if SkinnyReport == true +var MaxReport = 5 + // ConsolePrinter is a handle for the console printer. type ConsolePrinter struct { Reader *bufio.Reader