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 COPY fails when multiple files are copied to path specified in ENV #3034

Merged
merged 4 commits into from
Mar 19, 2024

Conversation

Greendor1234
Copy link
Contributor

Fixes #2946

Description

The problem is that the value inside the variable sd.DestPath is not updated with the value returned from the function ResolveEnvironmentReplacementList, so when the function IsSrcsValid is called to validate the destination there is still the environment variable unsolved.

dest := srcsAndDest.DestPath
...
if !IsDestDir(dest) && totalFiles > 1 {
  return errors.New("when specifying multiple sources in a COPY command, destination must be a directory and end in '/'")
}

So I added a line that updates the sd.DestPath with the value returned from the function ResolveEnvironmentReplacementList

dests, err := ResolveEnvironmentReplacementList([]string{sd.DestPath}, envs, true)
dest := dests[0]
sd.DestPath = dest

Submitter Checklist

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

  • 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.

Copy link
Collaborator

@aaron-prindle aaron-prindle left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix here @Greendor1234!

@aaron-prindle aaron-prindle merged commit ba433ab into GoogleContainerTools:main Mar 19, 2024
10 checks 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.

COPY fails when multiple files are copied to path specified in ENV
2 participants