Skip to content

Commit

Permalink
Add docs and use pre-defined colors everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
spkane committed Jul 11, 2022
1 parent 0ff729d commit 1800adb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ release-out
.certs
.tmp
*.tmp
.vscode
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![asciicinema example](https://asciinema.org/a/gPEIEo1NzmDTUu2bEPsUboqmU.png)](https://asciinema.org/a/gPEIEo1NzmDTUu2bEPsUboqmU)

# BuildKit
# BuildKit <!-- omit in toc -->

[![GoDoc](https://godoc.org/github.com/moby/buildkit?status.svg)](https://godoc.org/github.com/moby/buildkit/client/llb)
[![Build Status](https://github.com/moby/buildkit/workflows/build/badge.svg)](https://github.com/moby/buildkit/actions?query=workflow%3Abuild)
Expand Down Expand Up @@ -213,6 +213,12 @@ See [`frontend/dockerfile/docs/experimental.md`](frontend/dockerfile/docs/experi

By default, the build result and intermediate cache will only remain internally in BuildKit. An output needs to be specified to retrieve the result.

> Color Output Controls
>
> `buildctl` has support for modifying the colors that are used to output information to the terminal. You can set the environment varliable `BUILDKIT_COLORS` to something like `run=blue;cancel=yellow;warn=orange;error=red` to set the colors that you would like to use. You can also set `NO_COLOR` to disable colorized output.
>
> - [A list of the supported colors](https://github.com/moby/buildkit/blob/master/util/progress/progressui/colors.go).
#### Image/Registry

```bash
Expand Down
3 changes: 1 addition & 2 deletions util/progress/progressui/colors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/morikuni/aec"
)

var rex = regexp.MustCompile("(\\w+)=(\\w+)")
var rex = regexp.MustCompile(`(\w+)=(\w+)`)

var termColorMap = map[string]aec.ANSI{
"default": aec.DefaultF,
Expand All @@ -35,7 +35,6 @@ var termColorMap = map[string]aec.ANSI{
}

func setUserDefinedTermColors(colorsEnv string) {

data := rex.FindAllStringSubmatch(colorsEnv, -1)
for _, kv := range data {
k := kv[1]
Expand Down
27 changes: 14 additions & 13 deletions util/progress/progressui/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,31 @@ var colorError aec.ANSI
var envColorString string

func init() {
// As recommended on https://no-color.org/
_, noColorIsSet = os.LookupEnv("NO_COLOR")
// Loosely based on the standard set by Linux LS_COLORS.
_, buildkitColorIsSet = os.LookupEnv("BUILDKIT_COLORS")

if noColorIsSet {
colorRun = aec.DefaultF
colorCancel = aec.DefaultF
colorWarning = aec.DefaultF
colorError = aec.DefaultF
colorRun = termColorMap["default"]
colorCancel = termColorMap["default"]
colorWarning = termColorMap["default"]
colorError = termColorMap["default"]
return
} else if runtime.GOOS == "windows" {
colorRun = aec.CyanF
colorCancel = aec.YellowF
colorWarning = aec.Color8BitF(aec.NewRGB8Bit(255, 140, 0))
colorError = aec.RedF
colorRun = termColorMap["cyan"]
colorCancel = termColorMap["yellow"]
colorWarning = termColorMap["orange"]
colorError = termColorMap["red"]
} else {
colorRun = aec.BlueF
colorCancel = aec.YellowF
colorWarning = aec.Color8BitF(aec.NewRGB8Bit(255, 140, 0))
colorError = aec.RedF
colorRun = termColorMap["blue"]
colorCancel = termColorMap["yellow"]
colorWarning = termColorMap["orange"]
colorError = termColorMap["red"]
}

if buildkitColorIsSet {
envColorString = os.Getenv("BUILDKIT_COLORS")
setUserDefinedTermColors(envColorString)
}

}

0 comments on commit 1800adb

Please sign in to comment.