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