-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add 'envFrom' generic configuration for backend spec #657
Conversation
Hi @sashokbg Thanks for your contribution! I'm having a look at this right now. |
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.
Overall LGTM.
Just one minor thing, so that it works as intended.
EDIT: just had a look at the failing test, there seems to be some nil pointer problem.
@sashokbg there should probably be a check for a nil backend before accessing the |
@Kidswiss I am really sorry for the question but since it is my first time writing Go code - how should I implement the null check ?
|
@sashokbg No need to apologize :) You'll need to check the
The problem arises because you want to access a field of |
@Kidswiss thank you for your feedback - I have updated the PR to reflect the requested changes. I have tested the integration tests locally and everything passes |
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.
Hi.
Thanks for this high-quality PR! I was rather surprised to see a tutorial page :)
A few styling suggestions in the documentation, and some overlooked nil checks.
Additionally, I would love to see unit tests added that verify this nil check. Mainly to ensure that a later refactoring or code doesn't introduce a regression later on.
Hello @ccremer I will try to add a couple of unit tests to cover the null exception. Being a total novice in go this will probably take me a some time :) |
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 had a look at it again and I figured we could optimize the code a bit.
Instead of doing a nil check in every occurrence, we add a function to the spec
struct that accepts a container spec and adds the env vars. That way this should be easier to unit test and the logic is in a single place only.
Line 8 in a92ff23
type RunnableSpec struct { |
func (in *RunnableSpec) AppendEnvFromToContainer(containerSpec *corev1.ContainerSpec) {
if in.Backend != nil {
containerSpec.EnvFrom = append(containerSpec.EnvFrom, in.Backend.EnvFrom...)
}
}
then in each executor instead of the nil check call the function like this:
b.backup.Spec.AppendEnvFromToContainer(&backupJob.Spec.Template.Spec.Containers[0])
WDYT?
Hello @ccremer thank you for your time and helpful feedback. I think what you proposed is a good idea and went ahead and implemented it as you specified. I have also included a unit test that tests the new function |
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.
Actually I've found something to be missing
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 think you need to amend your commits for the DCO checks, other than that it's LGTM
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 like the idea of moving it to it's own method.
LGTM
76c7a7d
to
8c7f8bc
Compare
EnvFrom can be used to add arbitrary env varibles 'in bulk' to the job container template This feature can be useful in implementing some generic authentication Signed-off-by: Alexander KIRILOV <aleksandar.kirilov@proxym.fr> Co-authored-by: Chris <github.account@chrigel.net>
@sashokbg thank you for your contribution 🎉 |
Summary
Added envFrom configuration for backends
EnvFrom can be used to add arbitrary env variables 'in bulk' to the job container template.
This feature can be useful in implementing some generic authentication
Signed-off-by: Alexander KIRILOV aleksandar.kirilov@proxym.fr
Checklist
bug
,enhancement
,documentation
,change
,breaking
,as they show up in the changelog