Skip to content

Commit

Permalink
Removes redundant code and format
Browse files Browse the repository at this point in the history
  • Loading branch information
srikary12 authored and amisevsk committed Oct 15, 2024
1 parent 1b92604 commit a7ff239
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
1 change: 0 additions & 1 deletion pkg/cmd/options/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,5 @@ func DefaultNetworkOptions(configHome string) *NetworkOptions {
PlainHTTP: false,
TLSVerify: true,
CredentialsPath: constants.CredentialsPath(configHome),
Proxy: constants.ProxyEnvVar(),
}
}
15 changes: 0 additions & 15 deletions pkg/lib/constants/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,3 @@ func TagIndexPathForRepo(storageBase, repo string) string {
indexFileName := fmt.Sprintf("%s-tags.json", repoEncoded)
return filepath.Join(storageBase, indexFileName)
}

func ProxyEnvVar() string {
var ProxyEnvVar string
if ProxyEnvVar = os.Getenv("HTTPS_PROXY"); ProxyEnvVar != "" {
return "HTTPS_PROXY"
} else if ProxyEnvVar = os.Getenv("https_proxy"); ProxyEnvVar != "" {
return "https_proxy"
} else if ProxyEnvVar = os.Getenv("HTTP_PROXY"); ProxyEnvVar != "" {
return "HTTP_PROXY"
} else if ProxyEnvVar = os.Getenv("http_proxy"); ProxyEnvVar != "" {
return "https_proxy"
}

return ProxyEnvVar
}
12 changes: 6 additions & 6 deletions pkg/lib/network/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ func DefaultClient(opts *options.NetworkOptions) (*auth.Client, error) {
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig.InsecureSkipVerify = !opts.TLSVerify
if opts.Proxy != "" {
proxyURL, err := url.Parse(opts.Proxy)
if err != nil {
return nil, fmt.Errorf("invalid proxy URL: %w", err)
}
transport.Proxy = http.ProxyURL(proxyURL)
}
proxyURL, err := url.Parse(opts.Proxy)
if err != nil {
return nil, fmt.Errorf("invalid proxy URL: %w", err)
}
transport.Proxy = http.ProxyURL(proxyURL)
}
if opts.ClientCertKeyPath != "" && opts.ClientCertPath != "" {
cert, err := tls.LoadX509KeyPair(opts.ClientCertPath, opts.ClientCertKeyPath)
if err != nil {
Expand Down

0 comments on commit a7ff239

Please sign in to comment.