-
Notifications
You must be signed in to change notification settings - Fork 64
✨ Add Proxy support to rukpak generator #1998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -115,6 +115,40 @@ func WithMutatingWebhooks(webhooks ...admissionregistrationv1.MutatingWebhook) f | |||||||
} | ||||||||
} | ||||||||
|
||||||||
// With | ||||||||
func WithProxy(httpProxy, httpsProxy, noProxy string) func(client.Object) { | ||||||||
return func(obj client.Object) { | ||||||||
switch o := obj.(type) { | ||||||||
case *appsv1.Deployment: | ||||||||
addProxyEnvVars(httpProxy, httpsProxy, noProxy, o.Spec.Template.Spec.Containers) | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
func addProxyEnvVars(httpProxy, httpsProxy, noProxy string, containers []corev1.Container) { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we nuke any preexisting proxy env vars? |
||||||||
cs := containers | ||||||||
for i := range cs { | ||||||||
Comment on lines
+129
to
+130
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed? Can't we just do
Suggested change
|
||||||||
if len(httpProxy) > 0 { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit
Suggested change
seems cleaner |
||||||||
cs[i].Env = append(cs[i].Env, corev1.EnvVar{ | ||||||||
Name: "HTTP_PROXY", | ||||||||
Value: httpProxy, | ||||||||
}) | ||||||||
} | ||||||||
if len(httpsProxy) > 0 { | ||||||||
cs[i].Env = append(cs[i].Env, corev1.EnvVar{ | ||||||||
Name: "HTTPS_PROXY", | ||||||||
Value: httpsProxy, | ||||||||
}) | ||||||||
} | ||||||||
if len(noProxy) > 0 { | ||||||||
cs[i].Env = append(cs[i].Env, corev1.EnvVar{ | ||||||||
Name: "NO_PROXY", | ||||||||
Value: noProxy, | ||||||||
}) | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
// CreateServiceAccountResource creates a ServiceAccount resource with name 'name', namespace 'namespace', and applying | ||||||||
// any ServiceAccount related options in opts | ||||||||
func CreateServiceAccountResource(name string, namespace string, opts ...ResourceCreatorOption) *corev1.ServiceAccount { | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,11 +56,16 @@ func (r ResourceGenerators) ResourceGenerator() ResourceGenerator { | |
|
||
type UniqueNameGenerator func(string, interface{}) (string, error) | ||
|
||
type Proxy struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: should we call it |
||
HTTPProxy, HTTPSProxy, NoProxy string | ||
} | ||
|
||
type Options struct { | ||
InstallNamespace string | ||
TargetNamespaces []string | ||
UniqueNameGenerator UniqueNameGenerator | ||
CertificateProvider CertificateProvider | ||
Proxy *Proxy | ||
} | ||
|
||
func (o *Options) apply(opts ...Option) *Options { | ||
|
@@ -106,6 +111,12 @@ func WithCertificateProvider(provider CertificateProvider) Option { | |
} | ||
} | ||
|
||
func WithProxy(proxy Proxy) Option { | ||
return func(o *Options) { | ||
o.Proxy = &proxy | ||
} | ||
} | ||
|
||
type BundleRenderer struct { | ||
BundleValidator BundleValidator | ||
ResourceGenerators []ResourceGenerator | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: incomplete comment