Skip to content

Commit

Permalink
Revert "chore: set DEBUG env var based on log level"
Browse files Browse the repository at this point in the history
This reverts commit a5a3b85.
  • Loading branch information
PeterSchafer committed Aug 1, 2024
1 parent 725d22a commit e8279d9
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions cliv2/internal/cliv2/cliv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"time"

"github.com/gofrs/flock"
"github.com/rs/zerolog"
"github.com/snyk/go-application-framework/pkg/configuration"
"github.com/snyk/go-application-framework/pkg/instrumentation"
"github.com/snyk/go-application-framework/pkg/utils"
Expand Down Expand Up @@ -392,8 +391,22 @@ func PrepareV1EnvironmentVariables(
inputAsMap[constants.SNYK_HTTPS_PROXY_ENV] = proxyAddress
inputAsMap[constants.SNYK_HTTP_PROXY_ENV] = proxyAddress
inputAsMap[constants.SNYK_CA_CERTIFICATE_LOCATION_ENV] = caCertificateLocation
inputAsMap[constants.SNYK_INTERNAL_ORGID_ENV] = config.GetString(configuration.ORGANIZATION)

fillEnvironmentFromConfig(inputAsMap, config, args)
if config.GetBool(configuration.PREVIEW_FEATURES_ENABLED) {
inputAsMap[constants.SNYK_INTERNAL_PREVIEW_FEATURES_ENABLED] = "1"
}

if config.IsSet(configuration.API_URL) {
inputAsMap[constants.SNYK_ENDPOINT_ENV] = config.GetString(configuration.API_URL)
}

_, orgEnVarExists := inputAsMap[constants.SNYK_ORG_ENV]
if !utils.ContainsPrefix(args, "--org=") &&
!orgEnVarExists &&
config.IsSet(configuration.ORGANIZATION) {
inputAsMap[constants.SNYK_ORG_ENV] = config.GetString(configuration.ORGANIZATION)
}

// merge user defined (external) and internal no_proxy configuration
if len(inputAsMap[constants.SNYK_HTTP_NO_PROXY_ENV_SYSTEM]) > 0 {
Expand All @@ -411,30 +424,6 @@ func PrepareV1EnvironmentVariables(
return result, err
}

// Fill environment variables for the legacy CLI from the given configuration.
func fillEnvironmentFromConfig(inputAsMap map[string]string, config configuration.Configuration, args []string) {
inputAsMap[constants.SNYK_INTERNAL_ORGID_ENV] = config.GetString(configuration.ORGANIZATION)

if config.GetBool(configuration.PREVIEW_FEATURES_ENABLED) {
inputAsMap[constants.SNYK_INTERNAL_PREVIEW_FEATURES_ENABLED] = "1"
}

if config.IsSet(configuration.API_URL) {
inputAsMap[constants.SNYK_ENDPOINT_ENV] = config.GetString(configuration.API_URL)
}

if local_utils.GetDebugLevel(config) == zerolog.TraceLevel {
inputAsMap["DEBUG"] = "*"
}

_, orgEnVarExists := inputAsMap[constants.SNYK_ORG_ENV]
if !utils.ContainsPrefix(args, "--org=") &&
!orgEnVarExists &&
config.IsSet(configuration.ORGANIZATION) {
inputAsMap[constants.SNYK_ORG_ENV] = config.GetString(configuration.ORGANIZATION)
}
}

func (c *CLI) PrepareV1Command(
ctx context.Context,
cmd string,
Expand Down

0 comments on commit e8279d9

Please sign in to comment.