Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Fix COPY fails when multiple files are copied to path specified in ENV#3034

Merged
aaron-prindle merged 4 commits intoGoogleContainerTools:mainfrom
Greendor1234:issue-2946
Mar 19, 2024
Merged

Fix COPY fails when multiple files are copied to path specified in ENV#3034
aaron-prindle merged 4 commits intoGoogleContainerTools:mainfrom
Greendor1234:issue-2946

Conversation

@Greendor1234
Copy link
Copy Markdown
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
Copy Markdown
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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