Open smoser opened 1 year ago
I'm just thinking out loud here, but here is what I would suggest for import of a directory:
## Assuming existing build directory
## /my/imports
## that has file 'fileA'
import:
# results in /etc/imports/fileA will be at /etc/imports/fileA
- path: /my/imports/
dest: /etc/imports
# rejected (no trailng / on 'path')
- path: /my/imports
dest: /etc/
# rejected (trailing / on 'dest')
- path: /my/imports/
dest: /my/etc/
# rejected because 'dest' exists (assuming that your fs has '/etc')
- path: /my/imports/
dest: /etc
questions:
should links be followed for a 'path' ? If we don't think we need the functionality of importing a link, then right now we could reject imports of a link straight away.
Thoughts?
Below is a shell script that demonstrates the issue that a directory in a 'import' path. The behavior changed between 0.4.x and 1.0.0-rc4. the '/stacker/imports' code did not actually change behavior other than moving the from '/stacker' to '/stacker/imports'.
#!/bin/sh
set -xe
rm -Rf tree
mkdir tree
mkdir -p tree/etc
mkdir -p tree/usr/bin
echo "passwd" > tree/etc/passwd
printf "#!/bin/sh\necho hello world\n" > tree/usr/bin/hello
chmod 755 tree/usr/bin/hello
cat > stacker.yaml <<"EOF"
tree:
from:
type: docker
url: docker://busybox:latest
import:
- ./tree/
run: |
for d in /stacker/imports /stacker ; do
[ -d "$d" ] && ls -l "$d" && break
done
exit 1
EOF
stacker --version
stacker --work-dir="$PWD/work.d" build
The real problem is that a directory named 'tree' doesn't exist inside the build container.
So:
stacker version | import dest |
---|---|
0.4.2 | /stacker/tree |
1.0.0-rc4 | /stacker/tree |
1.0.0-rc8 | /stacker/imports/usr /stacker/imports/etc |
The change is that trailing / on 'tree/' causes the directory to "disappear" in the container.
stacker version
v1.0.0-rc4-8e267fc
Describe the bug
I was playing with 'import' using 'path' and 'dest' and it did not behave as I would have expected.
To reproduce
Client tool used: attached go.sh.txt
Seen error
Expected behavior
I want/need/expect to be able to import directories and rename them.
I would expect for the 'dir1/' and 'dir2' imports to result in '/import1/dirA' and '/import2' directories respectively.
Screenshots
No response
Additional context
The same as a file, it is desireable to be able to specify the 'dest' name explicitly.