Skip to content
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

can't inject env var with a comma in it's value #724

Open
Omar-Bishtawi opened this issue Aug 21, 2023 · 4 comments
Open

can't inject env var with a comma in it's value #724

Omar-Bishtawi opened this issue Aug 21, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@Omar-Bishtawi
Copy link

Describe the bug
if you try to inject the following annotation to any deployment

appmesh.k8s.aws/sidecarEnv: '[{"sample_key_1":"value","sample_key_2":"value"}]'

you will get the follwing error

malformed annotation appmesh.k8s.aws/sidecarEnv , expected format: EnvVariableKey=EnvVariableValue

Steps to reproduce
attach any json value with multiple keys to sidecar env var .

Expected outcome
the env variable to have a valid json as it's value

Additional Context:
I think this behavior is expected since in herethe method only split by , and we can't escape this charachter in any way.

@Omar-Bishtawi Omar-Bishtawi added the bug Something isn't working label Aug 21, 2023
@dileepng
Copy link
Contributor

This is expected, this has to be in the format of this https://github.com/aws/aws-app-mesh-controller-for-k8s/blob/master/pkg/inject/constants.go#L54

@Omar-Bishtawi
Copy link
Author

Omar-Bishtawi commented Aug 24, 2023

Thanks for the info @dileepng .
are you open to the idea of supporting such feature (allow escaping of the , character if it wasn't ment to be used as a separator) ?
I can try to help in this if you don't have an issue with such a feature.

@BennettJames
Copy link
Contributor

Hey Omar,

We're not necessarily against improving the behavior here, but it's tricky to do in a fairly general way that's reasonably backwards compatible. We'd likely need to adapt a system that's capable of parsing the string such that ,, ", and = are special characters that control handling, and allow escaping of them. Maybe it'd be ok breaking some edge cases like if a current user is setting variables like A=ab"c\,B=efg, but I'm always pretty hesitant to make a change that can have unexpected consequences.

Perhaps the best answer is to add a new variable that has a more robust parsing system around it - maybe sidecarEnvJson - and let the user specify a json map of strings-to-values.

@Omar-Bishtawi
Copy link
Author

@BennettJames the idea of introducing a new env variable with robust parsing system is good one and resolve any backward compatibility issues that might arise of modifying the behavior of the old sidecarEnv.

also using JSON as a way to map env vars with there values is more robust and easier to parse in a consistent expected way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants