Skip to content

Commit a692443

Browse files
authored
Merge pull request #417 from anti-social/dev/copy_glob
Support glob rules for Copy and Depends commands #389
2 parents 74e18da + 22fb33d commit a692443

File tree

20 files changed

+1344
-79
lines changed

20 files changed

+1344
-79
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ todo.txt
1717
/alpine-keys.apk
1818
/alpine
1919

20-
/target
20+
target
2121

2222
/tests/image/images
2323
/tests/image/nginx

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ script:
4040
tests=($(echo $TESTS))
4141
for test in ${tests[@]}; do
4242
if [[ $test = cargo ]]; then
43-
vagga -E VAGGA_VERSION=v0.0.0-test _run rust-musl cargo test
43+
vagga -E VAGGA_VERSION=v0.0.0-test _run rust-musl cargo test --all
4444
else
4545
vagga \
4646
-E UBUNTU_MIRROR=http://mirrors.us.kernel.org/ubuntu/ \

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "vagga"
33
version = "0.7.2"
44
authors = ["Paul Colomiets"]
55

6+
[workspace]
7+
members = ["path_filter"]
8+
69
[dependencies]
710
libc = "0.2.10"
811
nix = "0.7.0"
@@ -37,6 +40,7 @@ quire = "0.2.1"
3740
lazy_static = "0.2.2"
3841
dir-signature = { git = "https://github.com/tailhook/dir-signature.git", rev = "9fd30db", optional=true }
3942
itertools = "0.5.8"
43+
path-filter = { version = "0.1.0", path = "path_filter"}
4044

4145
[features]
4246
default = ["containers"]

docs/build_steps.rst

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,11 +662,15 @@ Files and Directories
662662
path
663663
(required) Destination path
664664

665+
.. _ignore-regex:
666+
665667
ignore-regex
666668
(default ``(^|/)\.(git|hg|svn|vagga)($|/)|~$|\.bak$|\.orig$|^#.*#$``)
667669
Regular expression of paths to ignore. Default regexp ignores common
668670
revision control folders and editor backup files.
669671

672+
.. _include-regex:
673+
670674
include-regex
671675
(default ``None``)
672676
Regular expression of paths to include. When path matches both ignore and
@@ -682,6 +686,57 @@ Files and Directories
682686
unmapped users (the ones that don't belong to user's subuid/subgid range),
683687
will be set to ``nobody`` (65535).
684688

689+
.. _rules:
690+
691+
rules
692+
Leverages glob patterns instead of regular expressions to match paths.
693+
This option conflicts with ``ignore-regex`` and ``include-regex`` options.
694+
695+
The rules are similar to those which is used in
696+
`.gitignore <https://git-scm.com/docs/gitignore>`_ file but meaning of
697+
include/exclude rules is opposite. Also there are several differences:
698+
699+
* Include patterns **must** be absolute so they have to start with
700+
a leading slash. This is done for performance reasons to exclude
701+
unknown directories from traversing. If you really want to match relative
702+
paths you can prepend pattern with a slash followed by two consecutive
703+
asterisks. Thus ``/**/*.py`` pattern will match ``test.py``,
704+
``dir/main.py``, ``dir/subdir/test.py`` paths and so on.
705+
* ``!`` prefix negates the pattern. Negative patterns can be relative.
706+
Unlike `.gitignore` patterns it is possible to include a file when its
707+
parent directory was excluded. For instance rules
708+
``["!dir", "/dir/*.py"]`` will match all python files inside the ``dir``
709+
directory.
710+
* If there is no matched files inside a directory the directory itself
711+
won't be copied.
712+
* If the pattern ends with a slash, it will match only with a direcotory
713+
and paths underneath it. Also ``/dir/`` pattern will copy ``dir``
714+
directory even if it is empty.
715+
* Empty rules will match all underneath paths. But if you add only exclude
716+
rules no path will be matched. So you should explicitly add at least one
717+
include rule:
718+
719+
``[]`` will match all paths
720+
721+
``["!dir/"]`` will match nothing
722+
723+
``["!dir/", "/"]`` will match all paths except ``dir`` directories
724+
725+
By default there are some ignore rules that correspond ``ignore-regex``
726+
expression:
727+
``["!.git/", "!.hg/", "!.svn/", "!.vagga/", "!*.bak", "!*.orig", "!*~",
728+
"!#*#", "!.#*"]``
729+
730+
.. versionadded:: 0.7.3
731+
732+
.. _no-default-rules:
733+
734+
no-default-rules
735+
Disables default ignore rules which are given above. The option only works
736+
in pair with ``rules`` option.
737+
738+
.. versionadded:: 0.7.3
739+
685740
.. warning:: If the source directory starts with `/work` all the files are
686741
read and checksummed on each run of the application in the container. So
687742
copying large directories for this case may influence container startup
@@ -782,6 +837,25 @@ Meta Data
782837
if it's temporary container that depends on some generated file (sometimes
783838
useful for tests).
784839

840+
Options:
841+
842+
path
843+
(required) Relative path to directory or file inside ``/work`` directory.
844+
Matched files and directories will be checksummed to get the version of
845+
the container.
846+
847+
ignore-regex
848+
See `ignore-regex`_
849+
850+
include-regex
851+
See `include-regex`_
852+
853+
rules
854+
See `rules`_
855+
856+
no-default-rules
857+
See `no-default-rules`_
858+
785859

786860
Sub-Containers
787861
==============

path_filter/Cargo.lock

Lines changed: 231 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)