1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-12-18 20:16:31 +00:00
Commit graph

142 commits

Author SHA1 Message Date
94f9a10253 Merge pull request #49 from stephen679/full_digest_output
keywords: synonyms of keywords should produce same output
2016-07-27 15:24:39 -04:00
Stephen Chung
877272303b keywords: synonyms of keywords should produce same output
Currently, if you create a manifest with, say 'sha1', and another
manifest with 'sha1digest', gomtree will produce different output
with regard to the keyword name. I.e, `sha1=[...]` vs. `sha1digest=[...]`.
If we want to use synonyms for keywords, as well as align with upstream mtree
output, specifying 'sha1' and 'sha1digest' should impact gomtree's
in the same way.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-27 10:59:58 -04:00
3d7e24b48a Merge pull request #45 from vbatts/bsd_keywords
Bsd keywords
2016-07-26 16:48:49 -04:00
919d71c105 main: add -bsd-keywords
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>
2016-07-26 14:31:39 -04:00
b790afae01 keywords: include list of upstream keywords
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-26 14:21:44 -04:00
664ad32ff6 Merge pull request #44 from vbatts/xattrs
fix xattr ERANGE
2016-07-26 14:03:16 -04:00
2685cd3cc5 xattr: fix the failure on empty list
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-26 13:55:25 -04:00
ed6b293839 debug: add an mtree.Debugf and -debug flag
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-26 13:54:45 -04:00
39f68f5be2 Merge pull request #41 from stephen679/fix_too_many_files_open
[bug fix] tar: explicitly close files after populateTree
2016-07-26 11:56:57 -04:00
2324bb8b19 Merge pull request #42 from stephen679/fix_no_arguments
cmd: gomtree no arguments
2016-07-26 11:52:03 -04:00
e31036f7e3 Merge pull request #39 from stephen679/no_duplicate_keywords
main: don't dupliate keywords
2016-07-26 11:35:43 -04:00
Stephen Chung
8e3e4c3651 cmd: gomtree no arguments
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>
2016-07-25 20:35:38 -04:00
Stephen Chung
767d4bbb4b tar: explicitly close files after populateTree
Files don't close properly when `defer`ing inside
a for loop, since the surrounding function is still
iterating in a for loop. To fix this, just close the files
explicitly after `populateTree()` in `readHeaders()`

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-25 20:04:55 -04:00
b0c1606133 Merge pull request #37 from vbatts/no_null_json
check: omitempty rather than `null`
2016-07-25 18:51:38 -04:00
Stephen Chung
843517f136 main: don't dupliate keywords
When adding keywords with -K, we don't want to
duplicate keywords in the keywords slice.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-25 18:29:10 -04:00
c74c2ed6d7 Merge pull request #38 from stephen679/vis
vis: refactor code to use Vis() and Unvis()
2016-07-25 17:59:48 -04: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
898661f983 check: omitempty rather than null
When using `-result-format=json` flag, just show populated fields.

Before:
```bash
$ gomtree -result-format=json -p ./bin -f ./bin.mtree
{"failures":[{"path":"gomtree","keyword":"size","expected":"2646101","got":"2930231"}],"Missing":null,"Extra":null}
```

After:
```bash
$ gomtree -result-format=json -p ./bin -f ./bin.mtree
{"failures":[{"path":"gomtree","keyword":"size","expected":"2646101","got":"2930231"}]}
```

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-25 15:39:55 -04:00
a63f83d94d vis/unvis: pull in exact implementation from FreeBSD
Perhaps this is not completely ideal, because it brings in cgo.
And with the flags, it can have tailored experience.

I've added a basic test to ensure that the cases we're interested in are
covered.

This does not yet integrate the usage of Vis()/Unviz() into the manifest
create and compare.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-25 15:36:29 -04:00
cc939615c7 Merge pull request #29 from stephen679/tree_tar_stream
*: creating validation manifest from archive and validating a manifest against archive
2016-07-25 15:14:56 -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
bc6f3bf902 tar_time: treat time from tar archives special
Since the field in a tar header for each file only preserves seconds
precision, not nanosecond precision, let's handle it special. This will
allow for more custom case handling in Check()

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-23 12:07:43 -04:00
Stephen Chung
decc72b335 tar: create and validate a manifest from a tar stream
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>
2016-07-23 12:07:43 -04:00
Stephen Chung
f0f15a0e49 keywords: return "link" keyword along with its value
Originally only returning `Sys.linkname` when evaluating
a tar header's link field. We want it to be in the form of
keyword=value instead.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-23 12:07:43 -04:00
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
e6bdb36de3 Merge pull request #31 from cyphar/alternate-formats
cmd: add alternate formats
2016-07-22 17:39:24 -04:00
Aleksa Sarai
119cdc314c
cmd: add --result-format=path format
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>
2016-07-22 20:06:32 +10:00
Aleksa Sarai
692f56a830
*: add --result-format=json format
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>
2016-07-22 20:06:32 +10:00
Aleksa Sarai
8cf7253132
cmd: add --result-format
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>
2016-07-22 20:06:26 +10:00
20279bacf2 Merge pull request #35 from stephen679/set_keyword_selector
[bug fix] walk: filter \set keyword correctly
2016-07-21 13:51:47 -04:00
3c52e89277 travis: more strict golint
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-21 13:40:48 -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
52a31746bf Merge pull request #27 from vbatts/list-keyword_flag
main: change `-l` to `-list-keywords`
2016-07-21 02:07:43 +09:00
247cd84075 main: change -l to -list-keywords
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>
2016-07-20 11:39:32 -04:00
61dd456524 Merge pull request #22 from stephen679/set_aliasing
check: creator.curSet pointer aliasing
2016-07-20 07:40:19 +09:00
460fce6502 Merge pull request #25 from stephen679/get_all_mode_bits
keywords: obtain all permission bits
2016-07-20 04:40:32 +09:00
738b0fed45 Merge pull request #24 from stephen679/leading_whitespace_comments
parse: ignore leading whitespace for comments
2016-07-19 09:00:56 +09:00
c5ff3d1703 Merge pull request #23 from stephen679/dir_indentation
main: 'type' keyword should always be evaluated
2016-07-19 08:51:40 +09:00
Stephen Chung
f3fc3d06d6 parse: ignore leading whitespace for comments
Comments were only ignored if the string parsed
started with "#". This commit trims leading whitespace
and tab characters to make sure all lines with "#" being the
first non-whitespace character are ignored.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-17 12:21:52 -04:00
Stephen Chung
e29b993aa2 keywords: obtain all permission bits
Fixes #7. Upper 3 bits are 'special' mode bits, and are not
included when calling info.Mode().Perm(). Need to mask
the info.Mode() with the corresponding mode bit defined
by the go library to see if these bits are set or not.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-15 15:37:52 -04:00
Stephen Chung
992a4757b0 main: 'type' keyword should always be evaluated
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>
2016-07-15 09:59:18 -04:00
Stephen Chung
c99862ee53 check: creator.curSet pointer aliasing
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>
2016-07-15 08:58:26 -04:00
a29236e678 Merge pull request #20 from stephen679/validate_correct_path
check: recognize correct path
2016-07-15 11:34:32 +09:00
30ee5d29fe Merge pull request #18 from stephen679/metadata_entries
Create and insert metadata Entry's
2016-07-15 11:25:17 +09:00
818b9227d7 Merge pull request #19 from stephen679/check_valid_keyword
check: error out on unrecognized keyword
2016-07-15 11:08:20 +09:00
Stephen Chung
a0b06e0224 check: recognize correct path
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>
2016-07-14 16:33:23 -04:00
Stephen Chung
d06c91220f check: error out on unrecognized keyword
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>
2016-07-14 12:21:47 -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
3dc8a31929 Merge pull request #17 from vbatts/improve_flag_branches
gomtree: ensure validating a populated hierarchy
2016-07-13 22:26:36 -04:00
2d227512a5 gomtree: ensure validating a populated hierarchy
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-14 02:24:29 +00:00