diff --git a/cliv2/internal/cliv2/cliv2.go b/cliv2/internal/cliv2/cliv2.go index 321f4d7f77..2ab8d77b81 100644 --- a/cliv2/internal/cliv2/cliv2.go +++ b/cliv2/internal/cliv2/cliv2.go @@ -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" @@ -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 { @@ -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,