Skip to content

Commit

Permalink
cmd: Handle nil pointer for proxy config
Browse files Browse the repository at this point in the history
In case of podman preset the proxy setting have `nil` pointer which
cause the issue for `oc-env` command. This patch fix that.

fix: crc-org#2913
  • Loading branch information
praveenkumar committed Dec 31, 2021
1 parent 1b2f5ec commit f99dbcb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/crc/cmd/oc_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ func runOcEnv(args []string) error {
}
proxyConfig := consoleResult.ClusterConfig.ProxyConfig
fmt.Println(shell.GetPathEnvString(userShell, constants.CrcOcBinDir))
if proxyConfig.IsEnabled() {
fmt.Println(shell.GetEnvString(userShell, "HTTP_PROXY", proxyConfig.HTTPProxy))
fmt.Println(shell.GetEnvString(userShell, "HTTPS_PROXY", proxyConfig.HTTPSProxy))
fmt.Println(shell.GetEnvString(userShell, "NO_PROXY", proxyConfig.GetNoProxyString()))
if proxyConfig != nil {
if proxyConfig.IsEnabled() {
fmt.Println(shell.GetEnvString(userShell, "HTTP_PROXY", proxyConfig.HTTPProxy))
fmt.Println(shell.GetEnvString(userShell, "HTTPS_PROXY", proxyConfig.HTTPSProxy))
fmt.Println(shell.GetEnvString(userShell, "NO_PROXY", proxyConfig.GetNoProxyString()))
}
}
fmt.Println(shell.GenerateUsageHintWithComment(userShell, "crc oc-env"))
return nil
Expand Down

0 comments on commit f99dbcb

Please sign in to comment.