-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(import): copy folder contents #453
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -390,6 +390,130 @@ eigth: | |
[ -f /dir/file2 ] | ||
[ -f /dir/files/file3 ] | ||
EOF | ||
stacker build | ||
} | ||
|
||
@test "import with dir contents" { | ||
mkdir folder1 | ||
touch folder1/file1 | ||
mkdir folder1/subfolder2 | ||
touch folder1/subfolder2/subfile1 | ||
cat > stacker.yaml <<EOF | ||
first: | ||
from: | ||
type: oci | ||
url: $CENTOS_OCI | ||
import: | ||
- path: folder1/ | ||
dest: /folder1/ | ||
run: | | ||
[ -f /folder1/file1 ] | ||
|
||
hallyn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
second: | ||
from: | ||
type: built | ||
tag: first | ||
run: | | ||
mkdir -p /folder1 | ||
touch /folder1/file1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does this do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup. |
||
touch /folder1/file2 | ||
|
||
third: | ||
from: | ||
type: oci | ||
url: $CENTOS_OCI | ||
import: | ||
- path: stacker://second/folder1/ | ||
dest: /folder1/ | ||
run: | | ||
[ -f /folder1/file1 ] | ||
[ -f /folder1/file2 ] | ||
|
||
fourth: | ||
from: | ||
type: oci | ||
url: $CENTOS_OCI | ||
import: | ||
- path: folder1/ | ||
andaaron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dest: / | ||
run: | | ||
ls -l / | ||
[ -f /file1 ] | ||
mkdir -p /folder4/subfolder5 | ||
touch /folder4/subfolder5/subfile6 | ||
|
||
fifth: | ||
from: | ||
type: oci | ||
url: $CENTOS_OCI | ||
import: | ||
- path: folder1/subfolder2/ | ||
dest: /folder3/ | ||
- path: folder1/subfolder2 | ||
dest: /folder4 | ||
- path: stacker://fourth/folder4/subfolder5/ | ||
dest: /folder6/ | ||
- path: stacker://fourth/folder4/ | ||
dest: /folder7/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are not testing an import of a 'stacker://' path without a trailing /. You should add an import of: - path: stacker://fourth/folder4
dest: /folder8 And then a test of [ -d /folder8/folder4 ] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue is if folder8 is present then [ -d /folder8/folder4 ] will evaluate to true else false. But let me add this test and see what happens. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, yuck. i think that 'target' (the full path to the imported thing) should be fully determined by the 'dest', and not dependent on either the 'path' or the contents of the filesystem to which it is being imported. At worst, target should be determined by 'path' and 'dest', rather than 'path', 'dest' and 'target-filesystem'. that just seems the least surprising behavior to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The added test failed. The trailing slash determines what the behavior is - a trailing slash means contents, else the folder itself, applies for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
that part makes sense.
that I don't understand. |
||
run: | | ||
ls -l /folder* | ||
[ -f /folder3/subfile1 ] | ||
[ ! -e /folder3/subfolder2 ] | ||
[ -f /folder4/subfile1 ] | ||
[ -f /folder6/subfile6 ] | ||
[ ! -e /folder6/subfolder5 ] | ||
[ -f /folder7/subfolder5/subfile6 ] | ||
EOF | ||
stacker build | ||
} | ||
andaaron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@test "dir path behavior" { | ||
mkdir -p folder1 | ||
touch folder1/file1 | ||
mkdir -p folder1/subfolder2 | ||
touch folder1/subfolder2/subfile1 | ||
cat > stacker.yaml <<EOF | ||
src_folder_dest_non_existent_folder_case1: | ||
from: | ||
type: docker | ||
url: docker://ubuntu:latest | ||
import: | ||
- path: folder1 | ||
dest: /folder2 | ||
run: | | ||
[ -f /folder2/file1 ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unfortunate. Using rsync semantics:
So let's make sure to have a very clear documentation for these semantics. Right now this testcase appears to be the clearest documentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mind you I think I like the behavior you have here better. I'm surprised by what rsync is doing. So I'm not asking you to change it. Just document it :) |
||
|
||
src_folder_dest_non_existent_folder_case2: | ||
from: | ||
type: docker | ||
url: docker://ubuntu:latest | ||
import: | ||
- path: folder1/ | ||
dest: /folder2 | ||
run: | | ||
[ -f /folder2/file1 ] | ||
|
||
src_folder_dest_non_existent_folder_case3: | ||
from: | ||
type: docker | ||
url: docker://ubuntu:latest | ||
import: | ||
- path: folder1 | ||
dest: /folder2/ | ||
run: | | ||
ls -al / | ||
ls -al /folder2 | ||
[ -f /folder2/folder1/file1 ] | ||
|
||
src_folder_dest_non_existent_folder_case4: | ||
from: | ||
type: docker | ||
url: docker://ubuntu:latest | ||
import: | ||
- path: folder1/ | ||
dest: /folder2/ | ||
run: | | ||
[ -f /folder2/file1 ] | ||
EOF | ||
stacker build | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like you're not using 'idest' here at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line #35
if idest == ""