Skip to content

Commit 6989429

Browse files
committed
fix: add option to disable colors for users with conflicting background colors.
Fixes #2651 Fixes ENG-1494 Signed-off-by: Russell Centanni <[email protected]>
1 parent f9af41a commit 6989429

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

cmd/flags/flags.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
type GlobalFlags struct {
1010
Silent bool
1111
NoWarn bool
12+
NoColors bool
1213
Debug bool
1314
DisableProfileActivation bool
1415
SwitchContext bool
@@ -45,6 +46,7 @@ func SetGlobalFlags(flags *flag.FlagSet) *GlobalFlags {
4546

4647
flags.StringVar(&globalFlags.OverrideName, "override-name", "", "If specified will override the devspace.yaml name")
4748
flags.BoolVar(&globalFlags.NoWarn, "no-warn", false, "If true does not show any warning when deploying into a different namespace or kube-context than before")
49+
flags.BoolVar(&globalFlags.NoColors, "no-colors", false, "Do not show color highlighting in log output. This avoids invisible output with different terminal background colors")
4850
flags.BoolVar(&globalFlags.Debug, "debug", false, "Prints the stack trace if an error occurs")
4951
flags.BoolVar(&globalFlags.Silent, "silent", false, "Run in silent mode and prevents any devspace log output except panics & fatals")
5052

cmd/root.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import (
44
"context"
55
"flag"
66
"fmt"
7-
"github.com/loft-sh/devspace/pkg/devspace/kill"
87
"io"
98
"os"
109
"strings"
1110
"sync"
1211
"time"
1312

13+
"github.com/loft-sh/devspace/pkg/devspace/kill"
14+
"github.com/mgutz/ansi"
15+
1416
"github.com/loft-sh/devspace/pkg/devspace/config/loader"
1517
"github.com/loft-sh/devspace/pkg/devspace/config/loader/variable/expression"
1618
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
@@ -65,6 +67,8 @@ func NewRootCmd(f factory.Factory) *cobra.Command {
6567
log.SetLevel(logrus.DebugLevel)
6668
}
6769

70+
ansi.DisableColors(globalFlags.NoColors)
71+
6872
if globalFlags.KubeConfig != "" {
6973
err := os.Setenv("KUBECONFIG", globalFlags.KubeConfig)
7074
if err != nil {

pkg/devspace/services/proxycommands/rewrite.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ func (t Transformer) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err
7171
nSrc += n
7272
nDst += n
7373
if err != nil {
74-
return
74+
return nSrc, nDst, err
7575
}
7676
// copy the new value
7777
n, err = fullcopy(dst[nDst:], t.new)
7878
if err != nil {
79-
return
79+
return nSrc, nDst, err
8080
}
8181
nDst += n
8282
nSrc += t.oldlen
@@ -86,7 +86,7 @@ func (t Transformer) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err
8686
n, err = fullcopy(dst[nDst:], src[nSrc:])
8787
nDst += n
8888
nSrc += n
89-
return
89+
return nSrc, nDst, err
9090
}
9191
// skip everything except the trailing len(r.old) - 1
9292
// we do this because there could be a match straddling
@@ -96,7 +96,7 @@ func (t Transformer) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err
9696
nSrc += n
9797
nDst += n
9898
if err != nil {
99-
return
99+
return nSrc, nDst, err
100100
}
101101
}
102102
err = transform.ErrShortSrc

0 commit comments

Comments
 (0)