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

Refactor avoid twice parse #1041

Closed
wants to merge 2 commits into from
Closed

Refactor avoid twice parse #1041

wants to merge 2 commits into from

Conversation

antechrestos
Copy link
Contributor

@antechrestos antechrestos commented Feb 8, 2020

Fixes #692

Description

Based on @orisano work, this pull request completes his work by adding a unit test. I also rebased his work to get go.mod and integration tests in travis.

To do the unit test, I declared a private static variable that represents the stage loading. This variable is mocked during unit test and restored to its original value.

I also "privatized" calculateDependencies as it is not called elsewhere.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • [x ] Includes unit tests
  • Adds integration tests if needed.

See the contribution guide for more details.

Reviewer Notes

  • The code flow looks good.
  • Unit tests and or integration tests added.

Release Notes
Avoid parsing Dockerfile twice during build.

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added the cla: no CLA not signed by all commit authors label Feb 8, 2020
@antechrestos
Copy link
Contributor Author

@googlebot I consent

1 similar comment
@orisano
Copy link
Contributor

orisano commented Feb 8, 2020

@googlebot I consent

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes CLA signed by all commit authors and removed cla: no CLA not signed by all commit authors labels Feb 8, 2020
@antechrestos
Copy link
Contributor Author

@tejal29 @cvgw the work done by @orisano looked great yet I encountered something unfortunate.
CalculateDependencies calls command_util.UpdateConfigEnv that will do some replacement on Env command.
This fonction will be called another time while the command execution as with this change it will be called on the same structure. On all example it will be ok, however, luckily there is a test Dockerfile_test_env that reveals this problem.
The command ENV test4="a\"b" gets replaced the first time and test4 is valued to a"b. So far, so good. Yet, the second time it gets called it fails:

error building image: error building stage: failed to execute command: failed to process "a"b": unexpected end of statement while looking for matching double-quote
breaking something else

Hence, either there is a way of flaging that environment replacement was done, or refactor calculateDependencies, or implement a Clone function in Stage complex structure, or simply close the two pull requests.

@antechrestos
Copy link
Contributor Author

@tejal29 @cvgw any feedback? Just to know whether I should go deeper or close this pr (and let you close the twin one)

@tejal29
Copy link
Member

tejal29 commented Feb 28, 2020

@antechrestos Sorry. I havent had time to take a closer look at this.
IIUC, command_util.UpdateConfigEnv replaces only new environment variables set in cmd.Env.

I am not sure why the same env variable gets replaced twice. (unless a bug sneaked in)
Do you mind investigating that?

@antechrestos
Copy link
Contributor Author

@tejal29 I will. It might lead to some change

@antechrestos
Copy link
Contributor Author

Closed as #1174 was successfully merged

@antechrestos antechrestos deleted the refactor-avoid-twice-parse branch May 1, 2020 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes CLA signed by all commit authors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants