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: Update multienv_step_runner Env Var Parsing Logic (#2351) #2354

Merged
merged 2 commits into from
Jul 27, 2022

Conversation

austinsherron
Copy link
Contributor

Fixes #2351.

  • Update multienv_step_runner.go to split only on the first = character
  • Add affirmative and failing test cases

* Update multienv_step_runner.go to split only on the first = character
* Add affirmative and failing test cases
@austinsherron austinsherron requested a review from a team as a code owner July 1, 2022 23:20
@@ -22,7 +22,7 @@ func (r *MultiEnvStepRunner) Run(ctx command.ProjectContext, command string, pat
var sb strings.Builder
sb.WriteString("Dynamic environment variables added:\n")
for _, item := range envVars {
nameValue := strings.Split(item, "=")
nameValue := strings.SplitN(item, "=", 2)
if len(nameValue) == 2 {
envs[nameValue[0]] = nameValue[1]
sb.WriteString(nameValue[0])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm also finding that this list of dynamic env vars added is quite noisy, and doesn't really add much value to plans/applies. Would there be any openness to suppressing this?

Copy link
Contributor

Choose a reason for hiding this comment

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

@tapaszto is the original developer, maybe he can chime in why this is here?

Copy link
Contributor

Choose a reason for hiding this comment

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

We use multienv step to add dynamic number of environment variables coming from the result of a webservice call.
Originally we proposed to have a json string which can be parsed safely and handling the errors coming from the runstep result but later the reviewer suggested to have a simple key/value list. We modified accordingly implementing the simplest solution for our requirements and did not assume having "=" in the envvar values.
Here is the PR containing more details of our use case:
#1793

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback @tapaszto.

@jamengual As it stands, is this a reasonable bug fix to incorporate into the mainline? I think it's probably a pretty common case for env vars to contain =, as in my experience they're often base64 encoded.

Copy link
Contributor

Choose a reason for hiding this comment

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

if @tapaszto agrees that this is ok to add and does not change the use case I think it will be ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

and maybe we should update the docs if they do not explain well the use case and or the key=value structure.

Copy link
Contributor

Choose a reason for hiding this comment

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

if @tapaszto agrees that this is ok to add and does not change the use case I think it will be ok.

It's ok

Copy link
Contributor

Choose a reason for hiding this comment

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

@austinsherron check the docs and see if they will need adjustment due to this change, please.
We can merge it after

@jamengual
Copy link
Contributor

@austinsherron did you check the docs? do you think we need to update them?

@jamengual jamengual added waiting-on-response Waiting for a response from the user refactoring Code refactoring that doesn't add additional functionality labels Jul 14, 2022
@jamengual
Copy link
Contributor

@austinsherron are you still around?

@jamengual jamengual merged commit 6227b56 into runatlantis:master Jul 27, 2022
krrrr38 pushed a commit to krrrr38/atlantis that referenced this pull request Dec 16, 2022
) (runatlantis#2354)

* Update multienv_step_runner Env Var Parsing Logic

* Update multienv_step_runner.go to split only on the first = character
* Add affirmative and failing test cases

* Run gofmt
@nitrocode nitrocode added this to the v0.19.8 milestone Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code refactoring that doesn't add additional functionality waiting-on-response Waiting for a response from the user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multienv Fails if Env Vars Contain = (equals) Character
4 participants