Adding another test validated from the FreeBSD workflow.
Just because the keywords requested to be validated are not present in
the manifest, it is not an error.
Also, if the keywords from a new manifest are not present in a prior
manifest, then only compare the common keywords.
Fixes https://github.com/vbatts/go-mtree/issues/86
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
Due to several unsolveable problems in tar generation, such as the
size=... keyword, we have to special case quite a few things in the
checking code. We might want to move this to mtree properly (but I'm
hesitant about ignoring errors that only happen for tar DHes).
Signed-off-by: Aleksa Sarai <asarai@suse.de>
Switch the commandline to use the .Compare() API when checking
specification files against the state of a tar archive or other archive.
The main purpose is to completely remove the check.go code from being
necessary (outside of a wrapper).
Signed-off-by: Aleksa Sarai <asarai@suse.de>
To increase a user's control on how they validate a directory or
tar archive with a specification, it is helpful to know which
keywords are actually used in the spec provided. This way, the user
can see what keywords to use or not use with the '-k' or '-K' flags.
Signed-off-by: Stephen Chung <schung@redhat.com>
To support either producing or checking manifests that are compatible
with upstream FreeBSD mtree(8) keywords, this flag will only operate on
upstream keywords. Completely ignoring non-upstream keywords, though
printing out an INFO to stderr for information purposes.
Example:
```bash
INFO: ignoring "xattrs" as it is not an upstream keyword
/set type=file nlink=1 mode=0664 uid=1000 gid=100
. size=4096 type=dir mode=0755 nlink=2 time=1469556206.235575511
[...]
```
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
my tar_stream_tar_time PR accidentally put the functionality
for when gomtree has no arguments inside an unreachable block.
Signed-off-by: Stephen Chung <schung@redhat.com>
Added some more test cases for `vis`ing and `unvis`ing
strings, and a test case that walks/checks a directory with
filenames that require encoding. Had to change Path() to account
for possible errors Unvis() could return. Refactored Vis()/Unvis() into
go-mtree tar functionality as well.
Signed-off-by: Stephen Chung <schung@redhat.com>
if the keyword "tar_time" is present when evaluating
an Entry, gomtree should use the tar_time when evaluating
the "time" keyword as well. This commit also adds a test that
makes sure "tar_time" wins against "time" if both are present.
Some minor clean-ups as well, such as checking if KeywordFunc[keyword]
actually retrieves a function.
Signed-off-by: Stephen Chung <schung@redhat.com>
This commit contains added features to go-mtree that allows
user to create an mtree spec with '-T' option when specifying
a tar archive. Users can also validate an mtree spec against
a tar archive with an mtree spec. Also for the test archive,
there is a mixture of files, and folders (empty & non-empty),
and symlinks (broken & unbroken).
Signed-off-by: Stephen Chung <schung@redhat.com>
This allows for shell callers to just get a simple diff of what files
changed between the two invocations of go-mtree. This is somewhat
similar to supplying -f twice to the BSD mtree (though that compares two
specs and also gives you information about what *kind* of change
occurred).
Signed-off-by: Aleksa Sarai <asarai@suse.de>
This is far easier to parse than the default raw format, and provides
the full serialised result structure.
Signed-off-by: Aleksa Sarai <asarai@suse.de>
This allows callers to deal with multiple output formats and not require
string parsing in order to understand what the error was. The default
format is "bsd".
Signed-off-by: Aleksa Sarai <asarai@suse.de>
The FreeBSD flag `-l` is already used and has differing behavior, so
switch to not conflict
Reported-by: Aleksa Sarai <asarai@suse.de>
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
Resolves#21. When using `-k` option, gomtree should use
only the keywords specified by the user, as well as the 'type'
keyword if it wasn't specified.
Signed-off-by: Stephen Chung <schung@redhat.com>