1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-11-17 22:28:38 +00:00
Commit graph

378 commits

Author SHA1 Message Date
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
d5aab78911 Merge pull request #9 from vbatts/fix_time_comparison
Fix time comparison
2016-06-27 13:27:10 -04:00
6adcc98b22 keywords: time keyword 9 postition decimal
Matching with the FreeBSD standard format

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-06-27 13:24:03 -04:00
fca9d4b5b6 check: failing test case for #8
https://github.com/vbatts/go-mtree/issues/8

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-06-27 13:19:23 -04:00
ac37b23f38 keywords: time can be 0
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-06-27 13:16:24 -04:00
be2b0574a6 Merge pull request #6 from vbatts/check_keywords
check: keyword filtering the checks
2016-04-13 16:08:12 -04:00
5399fd04d0 check: add an example for the docs
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-04-13 16:04:48 -04:00
b11b9c6a78 check: keyword filtering the checks
Allow for Check() to be narrowed to a set of keywords.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-04-13 15:50:59 -04:00
a544d45c4c Merge pull request #4 from vbatts/fix_base_dir_path
walk: when directory is root, use "."
2016-04-13 15:39:09 -04:00
410c0d60c1 walk: when directory is root, use "."
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-04-13 15:38:04 -04:00
9f0a9fd6c0 Merge pull request #5 from vbatts/travis_vet
travis: go1.5 and go1.6 have vet builtin
2016-04-13 15:37:21 -04:00
8240bc683b travis: go1.5 and go1.6 have vet builtin
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-04-13 15:34:50 -04:00
d3a4dc6d72 Merge pull request #3 from vbatts/add_travis
travis: add travis checks
2016-04-06 14:00:03 -04:00
c3855dab6d travis: add travis check
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-04-06 13:57:11 -04:00
b595e50fec Merge pull request #2 from vbatts/testing
Tests pass
2016-04-06 12:47:56 -04:00