progress: move from an internal package to external

This commit makes the previously internal `progress` package an
external API. The is the result of the discussion in images
PR#1150 where we decided that the progress module is not a great
fit for the "images" library.

We want to share this code between bootc-image-builder and
image-builder-cli now. In the future we will also want to
use it in the `worker-executor` in `osbuild-composer` to
parse the stream data from `osbuild`.

We plan to merge bootc-image-builder and image-builder-cli
medium term so importing code from bootc-image-buider in
image-builder cli is not that stange.

When we (longer-term) use this code the `worker-executor`
we will need to think about this again and maybe put it
back into images. However this commit unblocks us without
making anything worse.
This commit is contained in:
Michael Vogt 2025-01-21 10:10:29 +01:00 committed by Simon de Vlieger
parent 6d0927c2f9
commit 9ac654a7b1
3 changed files with 563 additions and 0 deletions

View file

@ -0,0 +1,27 @@
package progress
import (
"io"
)
type (
TerminalProgressBar = terminalProgressBar
DebugProgressBar = debugProgressBar
VerboseProgressBar = verboseProgressBar
)
func MockOsStderr(w io.Writer) (restore func()) {
saved := osStderr
osStderr = w
return func() {
osStderr = saved
}
}
func MockIsattyIsTerminal(fn func(uintptr) bool) (restore func()) {
saved := isattyIsTerminal
isattyIsTerminal = fn
return func() {
isattyIsTerminal = saved
}
}