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

fix(venom): env variables with equal sign #721

Merged
merged 3 commits into from
Sep 28, 2023
Merged

Conversation

bramca
Copy link
Contributor

@bramca bramca commented Sep 23, 2023

This PR fixes the following issue:
VENOM_VAR_a='host=localhost'
results in a='host' because of the split on '=' and only taking the first value back

With this the var would end up like this:
a = 'host=localhost'

Making it possible to add equal signs in the variable

Copy link
Member

@yesnault yesnault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @bramca , thank you for your proposal.

Can you add a unit test about that into https://github.com/ovh/venom/blob/master/cmd/venom/run/cmd_test.go#L92 please?

Bram.Cautaerts added 2 commits September 28, 2023 09:45
Signed-off-by: Bram.Cautaerts <[email protected]>
Signed-off-by: Bram.Cautaerts <[email protected]>
@bramca
Copy link
Contributor Author

bramca commented Sep 28, 2023

Added a unit test for it

Copy link
Member

@yesnault yesnault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that SplitN is more readable than strings.Join..[1:].., '='

@@ -289,7 +289,7 @@ func initFromEnv(environ []string) ([]string, error) {
if strings.HasPrefix(env, "VENOM_VAR_") {
tuple := strings.Split(env, "=")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tuple := strings.Split(env, "=")
tuple := strings.SplitN(a, "=", 2)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, good suggestion

cmd/venom/run/cmd.go Outdated Show resolved Hide resolved
Signed-off-by: Bram.Cautaerts <[email protected]>
@yesnault
Copy link
Member

LGTM, thank you

@yesnault yesnault changed the title fix env variables with equal sign venom: fix env variables with equal sign Sep 28, 2023
@yesnault yesnault changed the title venom: fix env variables with equal sign fix(venom): env variables with equal sign Sep 28, 2023
@yesnault yesnault merged commit a95b2a9 into ovh:master Sep 28, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants