kubernetes-sigs / cli-utils

This repo contains binaries that built from libraries in cli-runtime.
Apache License 2.0
154 stars 77 forks source link

[WIP] Separate out collection of stats from the printer #503

Closed mortent closed 2 years ago

mortent commented 2 years ago

This is a POC for how we can separate collection of stats from an apply/destroy operation from the printers. It splits out the code used for this within the BaseListPrinter and make the Stats type available for other use-cases. It makes it available in the stats.Collector, which can be used as in this example:

eventChannel := a.Run(ctx, inv, objs, apply.Options{})

statsCollector := stats.NewCollector()
printer := printers.GetPrinter(r.output, r.ioStreams)
if err := printer.Print(statsCollector.Run(eventChannel), common.DryRunNone, r.printStatusEvents); err != nil {
  // handle err
}

s := statsCollector.Stats
k8s-ci-robot commented 2 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mortent

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-sigs/cli-utils/blob/master/OWNERS)~~ [mortent] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment