Skip to content

Commit

Permalink
Make output window configurable: BUILDKIT_TTY_LOG_LINES
Browse files Browse the repository at this point in the history
The output window was previously hard-coded to a height of 6;
this patch makes it configurable at run-time by setting the
BUILDKIT_TTY_LOG_LINES environment variable.

Signed-off-by: Burt Holzman <[email protected]>
  • Loading branch information
holzman committed Sep 28, 2023
1 parent 4c89091 commit 2677a22
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Join `#buildkit` channel on [Docker Community Slack](https://dockr.ly/comm-slack
- [Building multi-platform images](#building-multi-platform-images)
- [Configuring `buildctl`](#configuring-buildctl)
- [Color Output Controls](#color-output-controls)
- [Number of log lines (for active steps in tty mode)](#number-of-log-lines-for-active-steps-in-tty-mode)
- [Contributing](#contributing)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Expand Down Expand Up @@ -791,6 +792,9 @@ Parsing errors will be reported but ignored. This will result in default color v

- [The list of pre-defined colors](https://github.com/moby/buildkit/blob/master/util/progress/progressui/colors.go).

#### Number of log lines (for active steps in tty mode)
You can change how many log lines are visible for active steps in tty mode by setting `BUILDKIT_TTY_LOG_LINES` to a number (default: 6).

## Contributing

Want to contribute to BuildKit? Awesome! You can find information about contributing to this project in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
1 change: 0 additions & 1 deletion util/progress/progressui/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ func (d *rawJSONDisplay) done() {
// No actions needed.
}

const termHeight = 6
const termPad = 10

type displayInfo struct {
Expand Down
12 changes: 12 additions & 0 deletions util/progress/progressui/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package progressui
import (
"os"
"runtime"
"strconv"

"github.com/morikuni/aec"
)
Expand All @@ -12,6 +13,8 @@ var colorCancel aec.ANSI
var colorWarning aec.ANSI
var colorError aec.ANSI

var termHeight = 6

func init() {
// As recommended on https://no-color.org/
if v := os.Getenv("NO_COLOR"); v != "" {
Expand All @@ -34,4 +37,13 @@ func init() {
envColorString := os.Getenv("BUILDKIT_COLORS")
setUserDefinedTermColors(envColorString)
}

// Make the terminal height configurable at runtime.
termHeightStr := os.Getenv("BUILDKIT_TTY_LOG_LINES")
if termHeightStr != "" {
termHeightVal, err := strconv.Atoi(termHeightStr)
if err == nil && termHeightVal > 0 {
termHeight = termHeightVal
}
}
}

0 comments on commit 2677a22

Please sign in to comment.