-
Notifications
You must be signed in to change notification settings - Fork 250
Add MapToEnvVars helper function #548
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
Conversation
|
|
||
| func MapToEnvVars(proxyConfig map[string]string) []corev1.EnvVar { | ||
| if proxyConfig == nil { | ||
| return nil |
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.
i would return empty list maybe so we can append?
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.
append works with nil too.
pkg/operator/v1helpers/helpers.go
Outdated
| return []error(agg) | ||
| } | ||
|
|
||
| func MapToEnvVars(proxyConfig map[string]string) []corev1.EnvVar { |
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: would make this env var name something generic
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.
Yeah, I forgot about that 😉
pkg/operator/v1helpers/helpers.go
Outdated
| return []error(agg) | ||
| } | ||
|
|
||
| func MapToEnvVars(proxyConfig map[string]string) []corev1.EnvVar { |
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.
godoc
|
@mfojtik updated, ptal |
|
/lgtm |
pkg/operator/v1helpers/helpers.go
Outdated
| // MapToEnvVars converts a string-string map to a slice of corev1.EnvVar-s | ||
| func MapToEnvVars(mapEnvVars map[string]string) []corev1.EnvVar { | ||
| if mapEnvVars == nil { | ||
| return []corev1.EnvVar{} |
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.
why not nil?
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.
@mfojtik convinced me it'll be easier to use this in append
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.
it is not. This has smell. Don't do magic.
pkg/operator/v1helpers/helpers.go
Outdated
| return []corev1.EnvVar{} | ||
| } | ||
|
|
||
| envVars := []corev1.EnvVar{} |
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.
make with capacity
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: mfojtik, soltysh The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Add MapToEnvVars helper function
/assign @mfojtik
since you asked for it in openshift/cluster-kube-controller-manager-operator#285 (comment) and on top of that we use it in 3 operators: kcm-o, kas-o and oas-o.
/assign @deads2k