In certain circumstances (such as the manifest generation of a
filesystem as an unprivileged user) it is important to provide hooks
that override the default os.* implementation of filesystem-related
functions.
In order to avoid merging too much code from outside projects (such as
umoci) this is implemented by providing FsEval hooks to Walk() and
Check(). This allows for users of go-mtree to modify how filesystem
checks are done, without compromising the simplicity of go-mtree's code.
Signed-off-by: Aleksa Sarai <asarai@suse.de>
This removes all of the special handling code for both TarCheck() and
Check() so that everything now uses the new (generic) Compare() code. In
addition, the tests had to be modified to reflect the new classes of
errors.
Signed-off-by: Aleksa Sarai <asarai@suse.de>
Fix a bug in the parser that caused all iterators to have to handle the
/set and /unset semantics separately. In addition, provide a helper
function to correctly generate the merged set of keywords for a
particular entry.
Signed-off-by: Aleksa Sarai <asarai@suse.de>
Default behavior (according to upstream mtree) for validating symlinks
is to just validate the link itself, not to follow it.
Signed-off-by: Stephen Chung <schung@redhat.com>
Resolves#56. Now, the Entry tree will be populated
under a common root (if necessary), so that a manifest can
be accurately generate from a tar file that has been
created using multiple directories.
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>
when creating a manifest from, or validating, a stream like a tar
archive, it requires thinking about some of the functions differently
than walking a directory tree.
This is the beginning of allowing for such features.
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
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>
When iterating over creator.DH.Entries using the variable
e, and then setting creator.curSet to &e, this causes aliasing
that results in the underlying Entry of creator.curSet to
change on each iteration. Instead we want to get the address of
the actual Entry in creator.DH.Entries.
Signed-off-by: Stephen Chung <schung@redhat.com>
Fixes#11. Check() changes its working directory to `root`, which
is specified as an argument. Thus, it shouldn't open
a file using its absolute path; instead it should open the file
with the relative path to the root.
Signed-off-by: Stephen Chung <schung@redhat.com>
Make sure a keyword is valid before checking if
the keyword exists in the set of KeyVals that
Check() is supposed to validate.
Signed-off-by: Stephen Chung <schung@redhat.com>
For the most part, all the keywords for a standard mtree spec now have a
function to produce the contents for a creator.
These are used in the "walk" function, and will be used next in the
"check" logic.
This is still a WIP, as the DirectoryHierarchy produced from the current
Walk() is not all-together a valid document.
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>