revert back to previous file to save logic
This commit is contained in:
parent
caaf6c8adf
commit
2ea28fc7f5
|
|
@ -655,15 +655,25 @@ func DoBuild(opts *config.KanikoOptions) (v1.Image, error) {
|
|||
// If a file is a symlink, it also returns the target file.
|
||||
func filesToSave(deps []string) ([]string, error) {
|
||||
srcFiles := []string{}
|
||||
srcs, err := util.ResolveSources(deps, config.RootDir)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "resolving sources to save")
|
||||
}
|
||||
for _, f := range srcs {
|
||||
if link, err := util.EvalSymLink(f); err == nil {
|
||||
srcFiles = append(srcFiles, link)
|
||||
for _, src := range deps {
|
||||
srcs, err := filepath.Glob(filepath.Join(config.RootDir, src))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, f := range srcs {
|
||||
if link, err := util.EvalSymLink(f); err == nil {
|
||||
link, err = filepath.Rel(config.RootDir, link)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, fmt.Sprintf("could not find relative path to %s", config.RootDir))
|
||||
}
|
||||
srcFiles = append(srcFiles, link)
|
||||
}
|
||||
f, err = filepath.Rel(config.RootDir, f)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, fmt.Sprintf("could not find relative path to %s", config.RootDir))
|
||||
}
|
||||
srcFiles = append(srcFiles, f)
|
||||
}
|
||||
srcFiles = append(srcFiles, f)
|
||||
}
|
||||
return srcFiles, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -376,8 +376,8 @@ func Test_filesToSave(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("error creating tmpdir: %s", err)
|
||||
}
|
||||
defer func () {
|
||||
config.RootDir = original
|
||||
defer func() {
|
||||
config.RootDir = original
|
||||
os.RemoveAll(tmpDir)
|
||||
}()
|
||||
|
||||
|
|
@ -396,11 +396,7 @@ func Test_filesToSave(t *testing.T) {
|
|||
fp.Close()
|
||||
}
|
||||
|
||||
args := []string{}
|
||||
for _, arg := range tt.args {
|
||||
args = append(args, filepath.Join(tmpDir, arg))
|
||||
}
|
||||
got, err := filesToSave(args)
|
||||
got, err := filesToSave(tt.args)
|
||||
if err != nil {
|
||||
t.Errorf("got err: %s", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue