Skip to content

Commit

Permalink
use a more obvious way of telling verbose level on conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
stevefan1999-personal committed Jul 15, 2020
1 parent 16a15c1 commit c1a9519
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/lib/pq v1.3.0
github.com/mattn/go-sqlite3 v1.14.0
github.com/pkg/errors v0.8.1
github.com/pkg/math v0.0.0-20141027224758-f2ed9e40e245
github.com/rancher/wrangler v0.4.0
github.com/satori/go.uuid v1.2.0
github.com/sirupsen/logrus v1.4.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/math v0.0.0-20141027224758-f2ed9e40e245 h1:gk/AF9SGRj+RafNCoDcS3RRscb8S4BVbvqODOgWA7/8=
github.com/pkg/math v0.0.0-20141027224758-f2ed9e40e245/go.mod h1:2dhPPj2Li3DXrSY2U2ADdZy2B7sjQsT57lqENx1+FSE=
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
11 changes: 6 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"os"

"github.com/pkg/math"
"github.com/rancher/wrangler/pkg/signals"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
Expand Down Expand Up @@ -77,14 +78,14 @@ func main() {
}

func run(c *cli.Context) error {
if c.Bool("debug") && config.Features.VerboseLevel < int(logrus.DebugLevel) {
if config.Features.VerboseLevel >= 0 {
logrus.Warn("you've set verbose level yourself, but you also specified you want debug mode, superseding")
if c.Bool("debug") {
if config.IsValidVerboseLevel() {
logrus.Warn("you've requested verbose level and debug mode together yourself, whoever is more verbose will be superseding")
}
config.Features.VerboseLevel = int(logrus.DebugLevel)
config.Features.VerboseLevel = math.Max(config.Features.VerboseLevel, int(logrus.DebugLevel))
}

if config.Features.VerboseLevel >= 0 {
if config.IsValidVerboseLevel() {
logrus.SetLevel(logrus.Level(config.Features.VerboseLevel))
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/endpoint/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ type Config struct {
tls.Config
}

func (c *Config) IsValidVerboseLevel() bool {
return c.Features.VerboseLevel >= 0
}

type ETCDConfig struct {
Endpoints []string
TLSConfig tls.Config
Expand Down

0 comments on commit c1a9519

Please sign in to comment.