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(multienv): allow commas and quoted values #3542

Conversation

inkel
Copy link
Contributor

@inkel inkel commented Jun 21, 2023

what

As first stated by @acostaedg in #2765, the multienv step was failing if a value contained a comma (,). This PR adds the capability to quote values and thus having commas as part of the value.

why

Upon inspecting the previous multienv code I've found it was using a naive algorithm that was prone to errors. At Grafana Labs we are about to use multienv steps with lots of custom environment variables, many of which can contain characters like commas, equals (=), newlines (\n), or being a full JSON object.

By using a custom algorithm to parse the output of the multienv program we can now have a more thorough test suite and also provide advanced value for this feature.

tests

I've added a full test suite for the internal algorithm. See server/core/runtime/multienv_step_runner_internal_test.go for additional information.

I've also added a regression test for the original issue reported.

references

@inkel inkel requested a review from a team as a code owner June 21, 2023 21:44
@github-actions github-actions bot added the go Pull requests that update Go code label Jun 21, 2023
@inkel inkel force-pushed the inkel/multienv/proper-parsing-value-commas-quotes branch from 8a86a78 to afdadb7 Compare June 26, 2023 13:17
@jamengual jamengual added the waiting-on-review Waiting for a review from a maintainer label Sep 8, 2023
@jamengual
Copy link
Contributor

@inkel could you fix the conflict?

Thanks.

While at it makes it more readable.

Signed-off-by: Leandro López (inkel) <[email protected]>
This new function properly deals with quotes and commas in values.

Signed-off-by: Leandro López (inkel) <[email protected]>
See runatlantis#2765 for an issue report.

Signed-off-by: Leandro López (inkel) <[email protected]>
This new function properly deals with quotes and commas in values.

Signed-off-by: Leandro López (inkel) <[email protected]>
@inkel inkel force-pushed the inkel/multienv/proper-parsing-value-commas-quotes branch from afdadb7 to c6c31ca Compare September 8, 2023 19:41
@inkel
Copy link
Contributor Author

inkel commented Sep 8, 2023

@inkel could you fix the conflict?

Thanks.

Done!

@GenPage GenPage added the feature New functionality/enhancement label Oct 6, 2023
@GenPage GenPage removed the waiting-on-review Waiting for a review from a maintainer label Oct 6, 2023
@GenPage GenPage merged commit bb18da2 into runatlantis:main Oct 6, 2023
13 checks passed
@inkel inkel deleted the inkel/multienv/proper-parsing-value-commas-quotes branch October 6, 2023 16:16
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* Make code more Go-idiomatic

While at it makes it more readable.

Signed-off-by: Leandro López (inkel) <[email protected]>

* Add internal function to parse multienv step input

This new function properly deals with quotes and commas in values.

Signed-off-by: Leandro López (inkel) <[email protected]>

* Add regression test for multienv output with comma in values

See runatlantis#2765 for an issue report.

Signed-off-by: Leandro López (inkel) <[email protected]>

* Use parseMultienvLine for parsing multienv steps output

Signed-off-by: Leandro López (inkel) <[email protected]>

* Add internal function to parse multienv step input

This new function properly deals with quotes and commas in values.

Signed-off-by: Leandro López (inkel) <[email protected]>

---------

Signed-off-by: Leandro López (inkel) <[email protected]>
Co-authored-by: PePe Amengual <[email protected]>
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* Make code more Go-idiomatic

While at it makes it more readable.

Signed-off-by: Leandro López (inkel) <[email protected]>

* Add internal function to parse multienv step input

This new function properly deals with quotes and commas in values.

Signed-off-by: Leandro López (inkel) <[email protected]>

* Add regression test for multienv output with comma in values

See runatlantis#2765 for an issue report.

Signed-off-by: Leandro López (inkel) <[email protected]>

* Use parseMultienvLine for parsing multienv steps output

Signed-off-by: Leandro López (inkel) <[email protected]>

* Add internal function to parse multienv step input

This new function properly deals with quotes and commas in values.

Signed-off-by: Leandro López (inkel) <[email protected]>

---------

Signed-off-by: Leandro López (inkel) <[email protected]>
Co-authored-by: PePe Amengual <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants