Skip settings proxy config with WithProxy if its empty (#2242)

close #2208
This commit is contained in:
6543 2023-08-18 13:09:28 +02:00 committed by GitHub
parent a5ef372190
commit 55e98a186a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,10 @@ import (
// Option configures a compiler option.
type Option func(*Compiler)
func noopOption() Option {
return func(*Compiler) {}
}
// WithOption configures the compiler with the given option if
// boolean b evaluates to true.
func WithOption(option Option, b bool) Option {
@ -226,6 +230,11 @@ type ProxyOptions struct {
// and NO_PROXY environment variables added by default to every
// container in the pipeline.
func WithProxy(opt ProxyOptions) Option {
if opt.HTTPProxy == "" &&
opt.HTTPSProxy == "" &&
opt.NoProxy == "" {
return noopOption()
}
return WithEnviron(
map[string]string{
"no_proxy": opt.NoProxy,