Commit Graph

26 Commits

Author SHA1 Message Date
Vincent Batts 5d7f6c36e0
walk: directory is expected to be walked. A file is not.
Fixes: #166

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2022-04-23 13:40:44 -04:00
Vincent Batts 3bc8e48538
*.go: go-staticcheck linting
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2022-04-08 22:51:37 -04:00
Vincent Batts ed464af779
*: xattr can Update()
This is a gnarly patchset that has been mashed together.
It uncovered that some aspects of Check were never really working
correctly for `xattr` keywords, but also the `Update()` had been left
undone for a while.

This includes some API changes around the `Keyword` and `KeyVal` types.

Also I would like to update the signature for the `UpdateKeywordFunc` to
just accept a `KeyVal` as an argugment, rather than a keyword AND the
value. with this context there would be no need to guess on the value of
what's passed to the xattr update function of whether it needs or
already is base64 encoded.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-06-24 15:05:24 -04:00
Vincent Batts fc5450ed71
*: add an update/restore functionality
This allows for restoring some attributes of files from the state in an
mtree Manifest

Reported-by: Matthew Garrett <Matthewgarrett@google.com>
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-03-17 12:42:57 -04:00
Vincent Batts eca64ff621
walk: update the comment
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-02-16 10:44:52 -05:00
Aleksa Sarai c5ec1c9f3a
*: switch everything to govis
Now that we have govis, move everything to using govis.{Vis,Unvis} and
then remove the cvis build tags (because that code no longer exists).

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2017-02-16 03:21:43 +11:00
Aleksa Sarai e22043cb86
walk: implement FsEval hooks
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>
2016-12-14 16:26:31 +11:00
Vincent Batts 08b1000418
vis: adding a pure golang Vis()
The current Vis() and Unvis() are using the C implementation from
MTREE(8).

But that means that cgo is used, which is not always desired.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-12-07 16:12:28 -05:00
Aleksa Sarai 408b615c3c entries: comment with keyword metadata
Since not every keyword applies to every type entry, include a comment
with the keywords the manifest was generated with.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-17 23:45:45 -05:00
Vincent Batts c0a5cb25ec
-d: exclude non-directories
Adding flag, and supporting functionality for exluding entries that are
non-directories

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-17 22:43:02 -05:00
Vincent Batts 4eec68be4b
*: make Keyword and KeyVal pervasive
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-17 21:38:01 -05:00
Stephen Chung 773763fb87 vis: refactored code to reflect using vis/unvis for file names
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>
2016-07-25 16:41:06 -04:00
Stephen Chung 656e577ecc *: have gomtree always evaluate tar_time if it is present
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>
2016-07-23 12:07:43 -04:00
Vincent Batts faa80931af *: refactoring to support streams
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>
2016-07-23 12:07:43 -04:00
Stephen Chung 0223187e76 walk: filter \set keywords correctly
When checking if a new set is needed (curSet != nil),
curSet wasn't being filtered against the actual keywords
a user specifies. Thus, if `defaultSetKeywords` includes "flags", but
the `keywords` argument for Walk() doesn't include "flags", "flags"
was included in the new \set, which isn't expected behavior. Instead,
we want to use keywordSelector function to make sure that we use
intended user-specified keywords.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-21 11:31:45 -04:00
Stephen Chung 06a8e86273 Create and insert metadata Entry's
Create Entry's that detail the file spec signature.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-14 09:57:37 -04:00
Vincent Batts 410c0d60c1 walk: when directory is root, use "."
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-04-13 15:38:04 -04:00
Vincent Batts c3855dab6d travis: add travis check
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-04-06 13:57:11 -04:00
Vincent Batts 2fd41fb43f check: an initial pass at a validation check
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-03-24 16:35:09 -04:00
Vincent Batts 6db2f462a1 walk: insert comments regarding directory path
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-03-24 16:35:09 -04:00
Vincent Batts a05d8ebbbd *: cleaner Parent handling
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-03-24 16:35:09 -04:00
Vincent Batts 3b6cb6e117 *: entry linking and keyword filter
Setting up sibling and parent relationships for entries, so they can be
easier to walk.

Also, making "keyword=value" easier to parse. This helps filtering.

Both of these ready us for checking/validating a hierarchy.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-03-24 16:35:09 -04:00
Vincent Batts d1ddeb8e3d *: close to producing a validating hierarchy
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-03-24 16:35:09 -04:00
Vincent Batts 211687bcc4 keywords: added experimental "xattr" keyword
Initially only on linux platform, but could accommodate BSDs as well.
The keyword is rather a prefix of the key. So xattr keyword will have a
prefix of "xattr." followed by a suffix of its namespace and name.
The value stored in the manifest is the SHA1 digest of the extended
attribute's data.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-03-24 16:35:09 -04:00
Vincent Batts b3198b462b keywords: they deserve their own file
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-03-24 16:35:09 -04:00
Vincent Batts 455edf6d21 *: loads of walking features
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>
2016-03-24 16:35:09 -04:00