diff --git a/.gitignore b/.gitignore index 1c5bb8c1544f1..c067221885374 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ release-out .certs .tmp *.tmp +.vscode diff --git a/README.md b/README.md index 29c15dc3d8775..655c79b0cd165 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![asciicinema example](https://asciinema.org/a/gPEIEo1NzmDTUu2bEPsUboqmU.png)](https://asciinema.org/a/gPEIEo1NzmDTUu2bEPsUboqmU) -# BuildKit +# BuildKit [![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) @@ -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 diff --git a/util/progress/progressui/colors.go b/util/progress/progressui/colors.go index ec93dd77a4f71..c750223bd6b09 100644 --- a/util/progress/progressui/colors.go +++ b/util/progress/progressui/colors.go @@ -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, @@ -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] diff --git a/util/progress/progressui/init.go b/util/progress/progressui/init.go index d6af215391545..e40d3d847403d 100644 --- a/util/progress/progressui/init.go +++ b/util/progress/progressui/init.go @@ -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) } - }