-
Notifications
You must be signed in to change notification settings - Fork 0
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
Devops 831 fix env var cleanup upon change #23
Conversation
introduce annotations to save agent args for future cleanup
#minor
internal/controller/helpers_test.go
Outdated
want: 0, | ||
}, | ||
{ | ||
name: "correctly finds the index of the env var", |
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 suppose this test represent a scenario where the arg envVarName is not in envVarList and therefore function return -1 , right ? in that case it's still true to name it "correctly finds the index of the env var" ? maybe test envVarName does not exist or something like that
internal/controller/patch_funcs.go
Outdated
if envVarIndex != -1 { | ||
value := strings.ReplaceAll(container.Env[envVarIndex].Value, patchedEnvValue, "") | ||
if value == "" { | ||
container.Env = append(container.Env[:envVarIndex], container.Env[envVarIndex+1:]...) |
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.
Well this confused me a bit but with some help of non-human :) I managed to get it , the logic is basically to remove environment variable from container environment variable list by applying technics of slicing all elements before but not include the index of the removed env var and all elements from the element immediately after the one at index removed environment variable to the end.
maybe we can add comment or extract this logic to function name removeEnvVar
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, there is slices.Delete
was added in go 1.21
we can use it 👍
rename test
No description provided.