fix(multienv): allow commas and quoted values#3542
Merged
GenPage merged 6 commits intorunatlantis:mainfrom Oct 6, 2023
Merged
Conversation
8a86a78 to
afdadb7
Compare
Contributor
|
@inkel could you fix the conflict? Thanks. |
While at it makes it more readable. Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>
This new function properly deals with quotes and commas in values. Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>
See runatlantis#2765 for an issue report. Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>
Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>
This new function properly deals with quotes and commas in values. Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com>
afdadb7 to
c6c31ca
Compare
Contributor
Author
Done! |
GenPage
approved these changes
Oct 6, 2023
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) <leandro.lopez@grafana.com> * 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) <leandro.lopez@grafana.com> * Add regression test for multienv output with comma in values See runatlantis#2765 for an issue report. Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com> * Use parseMultienvLine for parsing multienv steps output Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com> * 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) <leandro.lopez@grafana.com> --------- Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com> Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
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) <leandro.lopez@grafana.com> * 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) <leandro.lopez@grafana.com> * Add regression test for multienv output with comma in values See runatlantis#2765 for an issue report. Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com> * Use parseMultienvLine for parsing multienv steps output Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com> * 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) <leandro.lopez@grafana.com> --------- Signed-off-by: Leandro López (inkel) <leandro.lopez@grafana.com> Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
what
As first stated by @acostaedg in #2765, the
multienvstep 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
multienvcode I've found it was using a naive algorithm that was prone to errors. At Grafana Labs we are about to usemultienvsteps 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
multienvprogram 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.gofor additional information.I've also added a regression test for the original issue reported.
references