Skip to content

Commit

Permalink
agent: Remove color support
Browse files Browse the repository at this point in the history
The value of this is minimal and it adds an external dependency

Signed-off-by: Thomas Graf <thomas@cilium.io>
  • Loading branch information
tgraf committed Mar 1, 2020
1 parent b758cee commit 39729f3
Show file tree
Hide file tree
Showing 32 changed files with 8 additions and 2,402 deletions.
7 changes: 2 additions & 5 deletions cilium/cmd/endpoint_labels.go
Expand Up @@ -19,7 +19,6 @@ import (
"os"
"text/tabwriter"

"github.com/cilium/cilium/pkg/color"
endpointid "github.com/cilium/cilium/pkg/endpoint/id"
"github.com/cilium/cilium/pkg/labels"
"github.com/cilium/cilium/pkg/labels/model"
Expand Down Expand Up @@ -74,13 +73,11 @@ func printEndpointLabels(lbls *labels.OpLabels) {
w := tabwriter.NewWriter(os.Stdout, 2, 0, 3, ' ', 0)

for _, v := range lbls.IdentityLabels() {
text := color.Green("Enabled")
fmt.Fprintf(w, "%s\t%s\n", v, text)
fmt.Fprintf(w, "%s\t%s\n", v, "Enabled")
}

for _, v := range lbls.Disabled {
text := color.Red("Disabled")
fmt.Fprintf(w, "%s\t%s\n", v, text)
fmt.Fprintf(w, "%s\t%s\n", v, "Disabled")
}
w.Flush()
}
7 changes: 3 additions & 4 deletions cilium/cmd/helpers.go
Expand Up @@ -26,7 +26,6 @@ import (
"text/tabwriter"

"github.com/cilium/cilium/pkg/bpf"
"github.com/cilium/cilium/pkg/color"
endpointid "github.com/cilium/cilium/pkg/endpoint/id"
"github.com/cilium/cilium/pkg/identity"
"github.com/cilium/cilium/pkg/maps/policymap"
Expand Down Expand Up @@ -358,11 +357,11 @@ func dumpConfig(Opts map[string]string) {
value = Opts[k]
if enabled, err := option.NormalizeBool(value); err != nil {
// If it cannot be parsed as a bool, just format the value.
fmt.Printf("%-24s %s\n", k, color.Green(value))
fmt.Printf("%-24s %s\n", k, value)
} else if enabled == option.OptionDisabled {
fmt.Printf("%-24s %s\n", k, color.Red("Disabled"))
fmt.Printf("%-24s %s\n", k, "Disabled")
} else {
fmt.Printf("%-24s %s\n", k, color.Green("Enabled"))
fmt.Printf("%-24s %s\n", k, "Enabled")
}
}
}
1 change: 0 additions & 1 deletion go.mod
Expand Up @@ -21,7 +21,6 @@ require (
github.com/docker/go-connections v0.3.0 // indirect
github.com/docker/libnetwork v0.0.0-20190128195551-d8d4c8cf03d7
github.com/envoyproxy/protoc-gen-validate v0.1.0 // indirect
github.com/fatih/color v1.7.0
github.com/go-openapi/errors v0.19.3
github.com/go-openapi/loads v0.19.5
github.com/go-openapi/runtime v0.19.4
Expand Down
25 changes: 0 additions & 25 deletions pkg/color/color.go

This file was deleted.

18 changes: 0 additions & 18 deletions pkg/endpoint/status.go
Expand Up @@ -20,7 +20,6 @@ import (
"time"

"github.com/cilium/cilium/api/v1/models"
"github.com/cilium/cilium/pkg/color"
"github.com/cilium/cilium/pkg/lock"
)

Expand Down Expand Up @@ -50,23 +49,6 @@ type Status struct {
State string `json:"state"`
}

func (sc StatusCode) ColorString() string {
var text string
switch sc {
case OK:
text = color.Green("OK")
case Warning:
text = color.Yellow("Warning")
case Failure:
text = color.Red("Failure")
case Disabled:
text = color.Yellow("Disabled")
default:
text = "Unknown code"
}
return fmt.Sprintf("%s", text)
}

func (sc StatusCode) String() string {
switch sc {
case OK:
Expand Down
8 changes: 3 additions & 5 deletions pkg/option/option.go
Expand Up @@ -20,7 +20,6 @@ import (
"strings"

"github.com/cilium/cilium/api/v1/models"
"github.com/cilium/cilium/pkg/color"
"github.com/cilium/cilium/pkg/lock"
)

Expand All @@ -32,8 +31,7 @@ type VerifyFunc func(key string, value string) error
// cannot be parsed or applied.
type ParseFunc func(value string) (OptionSetting, error)

// FormatFunc formats the specified value as a colored textual representation
// of the option.
// FormatFunc formats the specified value as textual representation option.
type FormatFunc func(value OptionSetting) string

// Option is the structure used to specify the semantics of a configurable
Expand Down Expand Up @@ -373,9 +371,9 @@ func (o *IntOptions) Dump() {
_, option := o.Library.Lookup(k)
if option == nil || option.Format == nil {
if o.Opts[k] == OptionDisabled {
text = color.Red("Disabled")
text = "Disabled"
} else {
text = color.Green("Enabled")
text = "Enabled"
}
} else {
text = option.Format(o.Opts[k])
Expand Down
5 changes: 0 additions & 5 deletions vendor/github.com/fatih/color/.travis.yml

This file was deleted.

27 changes: 0 additions & 27 deletions vendor/github.com/fatih/color/Gopkg.lock

This file was deleted.

30 changes: 0 additions & 30 deletions vendor/github.com/fatih/color/Gopkg.toml

This file was deleted.

20 changes: 0 additions & 20 deletions vendor/github.com/fatih/color/LICENSE.md

This file was deleted.

0 comments on commit 39729f3

Please sign in to comment.