Add test cases and docString for regex in COPY command (#2773)

This commit is contained in:
JeromeJu 2023-10-10 11:07:18 -04:00 committed by GitHub
parent c8c839a527
commit b6f14ae676
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -58,6 +58,7 @@ func (c *CopyCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.Bu
return errors.Wrap(err, "getting user group from chown")
}
// sources from the Copy command are resolved with wildcards {*?[}
srcs, dest, err := util.ResolveEnvAndWildcards(c.cmd.SourcesAndDest, c.fileContext, replacementEnvs)
if err != nil {
return errors.Wrap(err, "resolving src")

View File

@ -51,6 +51,21 @@ var copyTests = []struct {
sourcesAndDest: []string{"foo", "tempCopyExecuteTest"},
expectedDest: []string{"tempCopyExecuteTest"},
},
{
name: "copy f* into tempCopyExecuteTest",
sourcesAndDest: []string{"foo*", "tempCopyExecuteTest"},
expectedDest: []string{"tempCopyExecuteTest"},
},
{
name: "copy fo? into tempCopyExecuteTest",
sourcesAndDest: []string{"fo?", "tempCopyExecuteTest"},
expectedDest: []string{"tempCopyExecuteTest"},
},
{
name: "copy f[o][osp] into tempCopyExecuteTest",
sourcesAndDest: []string{"f[o][osp]", "tempCopyExecuteTest"},
expectedDest: []string{"tempCopyExecuteTest"},
},
}
func setupTestTemp(t *testing.T) string {