-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: set endpoint configuration for legacy CLI (#4931)
- Loading branch information
1 parent
088a3a8
commit 4eb072f
Showing
6 changed files
with
161 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,7 +264,8 @@ func PrepareV1EnvironmentVariables( | |
integrationVersion string, | ||
proxyAddress string, | ||
caCertificateLocation string, | ||
orgid string, | ||
config configuration.Configuration, | ||
args []string, | ||
) (result []string, err error) { | ||
|
||
inputAsMap := utils.ToKeyValueMap(input, "=") | ||
|
@@ -309,7 +310,18 @@ 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] = orgid | ||
inputAsMap[constants.SNYK_INTERNAL_ORGID_ENV] = config.GetString(configuration.ORGANIZATION) | ||
|
||
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 { | ||
|
@@ -336,10 +348,9 @@ func (c *CLI) PrepareV1Command( | |
integrationVersion string, | ||
) (snykCmd *exec.Cmd, err error) { | ||
proxyAddress := fmt.Sprintf("http://%s:%[email protected]:%d", proxy.PROXY_USERNAME, proxyInfo.Password, proxyInfo.Port) | ||
orgid := c.globalConfig.GetString(configuration.ORGANIZATION) | ||
|
||
snykCmd = exec.Command(cmd, args...) | ||
snykCmd.Env, err = PrepareV1EnvironmentVariables(c.env, integrationName, integrationVersion, proxyAddress, proxyInfo.CertificateLocation, orgid) | ||
snykCmd.Env, err = PrepareV1EnvironmentVariables(c.env, integrationName, integrationVersion, proxyAddress, proxyInfo.CertificateLocation, c.globalConfig, args) | ||
|
||
if len(c.WorkingDirectory) > 0 { | ||
snykCmd.Dir = c.WorkingDirectory | ||
|
@@ -369,10 +380,14 @@ func (c *CLI) executeV1Default(proxyInfo *proxy.ProxyInfo, passThroughArgs []str | |
constants.SNYK_HTTP_PROXY_ENV_SYSTEM, | ||
constants.SNYK_HTTP_NO_PROXY_ENV_SYSTEM, | ||
constants.SNYK_ANALYTICS_DISABLED_ENV, | ||
constants.SNYK_ENDPOINT_ENV, | ||
constants.SNYK_ORG_ENV, | ||
} | ||
|
||
for _, key := range listedEnvironmentVariables { | ||
c.DebugLogger.Println(" ", key, "=", variablesMap[key]) | ||
if value, exists := variablesMap[key]; exists { | ||
c.DebugLogger.Println(" ", key, "=", value) | ||
} | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters