-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: stop deletion of contents if directory paths overlap
- Loading branch information
1 parent
3d21df2
commit f71e2b7
Showing
10 changed files
with
126 additions
and
15 deletions.
There are no files selected for viewing
Empty file.
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
examples/overlapping-dir/vendir-directory-path-overlap-1.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: vendir.k14s.io/v1alpha1 | ||
kind: Config | ||
directories: | ||
- path: vendor | ||
contents: | ||
- path: dir1 | ||
directory: | ||
path: ./some-content | ||
- path: vendor | ||
contents: | ||
- path: dir2 | ||
directory: | ||
path: ./some-content |
15 changes: 15 additions & 0 deletions
15
examples/overlapping-dir/vendir-directory-path-overlap-2.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: vendir.k14s.io/v1alpha1 | ||
kind: Config | ||
directories: | ||
- path: vendor | ||
contents: | ||
- path: dir1 | ||
lazy: true | ||
directory: | ||
path: ./some-content | ||
- path: vendor | ||
contents: | ||
- path: dir3 | ||
lazy: true | ||
directory: | ||
path: ./some-content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: vendir.k14s.io/v1alpha1 | ||
directories: | ||
- contents: | ||
- configDigest: d0aef6c75d30608bf40883a6c52adcea0e8afc62c23513e0462a059390ea9b6b | ||
directory: {} | ||
path: dir1 | ||
path: vendor | ||
- contents: | ||
- configDigest: 147cb489ce06d7fb463ed370dd6c0f41b237af66a1260fecfbd82e5c33bf6c4a | ||
directory: {} | ||
path: dir3 | ||
path: vendor | ||
kind: LockConfig |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2020 VMware, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package e2e | ||
|
||
import ( | ||
"github.com/stretchr/testify/require" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestOverlappingDirPath(t *testing.T) { | ||
env := BuildEnv(t) | ||
vendir := Vendir{t, env.BinaryPath, Logger{}} | ||
|
||
path := "../../examples/overlapping-dir" | ||
|
||
_, err := vendir.RunWithOpts([]string{"sync", "-f", "vendir-directory-path-overlap-1.yml"}, RunOpts{Dir: path, AllowError: true}) | ||
require.NoError(t, err) | ||
|
||
expectedOutputDirs := []string{ | ||
"dir1", | ||
"dir2", | ||
} | ||
|
||
filepath.WalkDir(filepath.Join(path, "vendor"), func(path string, d os.DirEntry, err error) error { | ||
if d.Name() == "vendor" { | ||
return nil | ||
} | ||
require.Contains(t, expectedOutputDirs, d.Name()) | ||
return filepath.SkipAll | ||
}) | ||
|
||
_, err = vendir.RunWithOpts([]string{"sync", "-f", "vendir-directory-path-overlap-2.yml"}, RunOpts{Dir: path, AllowError: true}) | ||
require.NoError(t, err) | ||
|
||
expectedOutputDirs = []string{ | ||
"dir1", | ||
"dir3", | ||
} | ||
|
||
filepath.WalkDir(filepath.Join(path, "vendor"), func(path string, d os.DirEntry, err error) error { | ||
if d.Name() == "vendor" { | ||
return nil | ||
} | ||
require.Contains(t, expectedOutputDirs, d.Name()) | ||
return filepath.SkipAll | ||
}) | ||
} |