Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use default HTTP headers consistently [HEAD-936] #4915

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions cliv2/cmd/cliv2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,29 @@ const (
handleErrorUnhandled HandleError = iota
)

func getDebugLogger(config configuration.Configuration) *zerolog.Logger {
func getDebugLevel(config configuration.Configuration) zerolog.Level {
loglevel := zerolog.DebugLevel
if loglevelString := config.GetString("snyk_loglevel"); loglevelString != "" {
var err error
loglevel, err = zerolog.ParseLevel(loglevelString)
if err == nil {
debugLogger.Log().Msgf("Setting log level to %s", loglevelString)
} else {
debugLogger.Log().Msgf("%v", err)
loglevel = zerolog.DebugLevel
}
}
return loglevel
}

func initDebugLogger(config configuration.Configuration) *zerolog.Logger {
debug := config.GetBool(configuration.DEBUG)
if !debug {
debugLogger = debugLogger.Output(io.Discard)
} else {
loglevel := getDebugLevel(config)
debugLogger = debugLogger.Level(loglevel)
}

return &debugLogger
}

Expand Down Expand Up @@ -366,7 +383,7 @@ func MainWithErrorCode() int {
}

debugEnabled := globalConfiguration.GetBool(configuration.DEBUG)
debugLogger := getDebugLogger(globalConfiguration)
debugLogger := initDebugLogger(globalConfiguration)

initApplicationConfiguration(globalConfiguration)
engine = app.CreateAppEngineWithOptions(app.WithZeroLogger(debugLogger), app.WithConfiguration(globalConfiguration))
Expand Down
2 changes: 1 addition & 1 deletion cliv2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/snyk/cli-extension-iac-rules v0.0.0-20230601153200-c572cfce46ce
github.com/snyk/cli-extension-sbom v0.0.0-20230926124903-9705d7d47d8f
github.com/snyk/container-cli v0.0.0-20230920093251-fe865879a91f
github.com/snyk/go-application-framework v0.0.0-20231010111039-f5b82b5eeb81
github.com/snyk/go-application-framework v0.0.0-20231020152829-1d64d967af62
github.com/snyk/go-httpauth v0.0.0-20230925093100-dfb05155efc1
github.com/snyk/snyk-iac-capture v0.6.5
github.com/snyk/snyk-ls v0.0.0-20231018080541-3a486664f5ac
Expand Down
4 changes: 2 additions & 2 deletions cliv2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,8 @@ github.com/snyk/cli-extension-sbom v0.0.0-20230926124903-9705d7d47d8f h1:U3DQ9wn
github.com/snyk/cli-extension-sbom v0.0.0-20230926124903-9705d7d47d8f/go.mod h1:O/cjwCbKhJQWyXHPmNbZ7ToQKnhyw0VUp1Qhim3WEcw=
github.com/snyk/container-cli v0.0.0-20230920093251-fe865879a91f h1:ghajT5PEiLP8XNFIdc7Yn4Th74RH/9Q++dDOp6Cb9eo=
github.com/snyk/container-cli v0.0.0-20230920093251-fe865879a91f/go.mod h1:38w+dcAQp9eG3P5t2eNS9eG0reut10AeJjLv5lJ5lpM=
github.com/snyk/go-application-framework v0.0.0-20231010111039-f5b82b5eeb81 h1:a9P3ChzGgvmulkLsVORNEE9sBZVXapGzYxwxANG31oM=
github.com/snyk/go-application-framework v0.0.0-20231010111039-f5b82b5eeb81/go.mod h1:kuw/MMZ4rnQYMVGDTIkoJGyEEAl0DoHqEN6ZiYbNbSA=
github.com/snyk/go-application-framework v0.0.0-20231020152829-1d64d967af62 h1:uUVWh8+Zzc6RWBnShqIFvLgbYp5UCoaexrWwJjhh0bI=
github.com/snyk/go-application-framework v0.0.0-20231020152829-1d64d967af62/go.mod h1:kuw/MMZ4rnQYMVGDTIkoJGyEEAl0DoHqEN6ZiYbNbSA=
github.com/snyk/go-httpauth v0.0.0-20230925093100-dfb05155efc1 h1:2HfjHQxOjWyD5jKJQtiZV9mptamqikAvE/H4gilFk30=
github.com/snyk/go-httpauth v0.0.0-20230925093100-dfb05155efc1/go.mod h1:88KbbvGYlmLgee4OcQ19yr0bNpXpOr2kciOthaSzCAg=
github.com/snyk/policy-engine v0.22.0 h1:od9pduGrXyfWO791X+8M1qmnvWUxaIXh0gBzGKqeseA=
Expand Down