1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-11-27 10:35:39 +00:00
Commit graph

43 commits

Author SHA1 Message Date
W. Trevor King
72ac04e7ca vendor: Replace Sirupsen/logrus with sirupsen/logrus
With:

  $ git mv vendor/github.com/{S,s}irupsen
  $ sed -i 's/Sirupsen/sirupsen/g' $(git grep -l Sirupsen)

catching up with the upstream lowercasing [1,2,3,4].  Because of the
compatibility issues discussed in [3], some consumers may prefer to
use the old uppercase version until they have time to update their
other Logrus consumers to the new lowercase form.

[1]: https://github.com/sirupsen/logrus/blame/v1.0.3/README.md#L6
[2]: https://github.com/sirupsen/logrus/pull/384
[3]: https://github.com/sirupsen/logrus/issues/570#issuecomment-313933276
[4]: https://github.com/sirupsen/logrus/issues/553
2017-11-03 12:19:19 -07:00
73be830998
*: update -u behavior
Fixes #16

In attempt to close https://github.com/vbatts/go-mtree/issues/16 I've
uncovered that the update was missing a function for symlink.
Additionally the update was not even opperating on the correct directory
hierarchy.

I've uncovered that os.Chtimes follows the symlink, and presumably only
Linux has an obscure way to set the mtime/atime on a symlink itself. So
I've made a custom lchtimes().

Also Mode follows through the symlink, and symlinks only ever have a
mode of 0777, so don't set them.

Lastly, directories need to have their mtime/atime set in a reverse
order after all other updates have been done. This is going to require
something like a `container/heap` to be unwound.

Also, each updateFunc will _only_ perform the update if it is needed. Much less
invasive this way.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-06-30 15:34:44 -04:00
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
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
21a2577f01
gomtree: allow manifest to be provided on stdin
like `gomtree -c -p /tmp/dir1 -K sha1 | gomtree -p /tmp/dir2`

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-01-20 13:13:59 -05:00
Aleksa Sarai
9cdd9152b3
cmd: gomtree: re-enable errors when there is a Modified entry
Signed-off-by: Aleksa Sarai <asarai@suse.de>
2017-01-17 00:46:28 +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
Brent Baude
1b0ba0d70f cmd/gomtree/main.go: Handle Extra and Missing cases
The BSD format needed a slight tweak to handle mtree.Extra
and mtree.Missing cases.  It currently only handled the 'Modified'
cases and therefore was not showing missing or extra files during
validation.
2016-11-18 09:55:27 -05:00
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
353436a031
main: group flag variables
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-17 22:00:23 -05:00
21723a3974
*: fix comparison of missing keywords
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>
2016-11-17 21:38:10 -05:00
4eec68be4b
*: make Keyword and KeyVal pervasive
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-17 21:38:01 -05:00
5d26726bb1
keyword: unify keyword synonyms
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-16 15:42:53 -05:00
627c6e9ddd
DirectoryHierarchy: UsedKeywords is a of the struct
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-16 14:43:05 -05:00
a8e4475c5e
*: clean up
* Get rid of the isErr func in main()
* put main() logic closer to the top

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-16 14:22:12 -05:00
Aleksa Sarai
3bfdecf467
gomtree: add special cases for tar generation checking
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>
2016-11-10 12:41:23 +11:00
Aleksa Sarai
d7f49531f8
gomtree: switch to using compare
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>
2016-11-10 11:30:06 +11:00
92b6fc1af3 main: expose the version with a flag
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-16 11:37:11 -04:00
6d8cd9fe4c gomtree: -list-used can output JSON
Piggybacking on `-result-format`:

```bash
$ tar c .git/ | gomtree -c -T - > git.mtree
$ gomtree -result-format=json -list-used -f ./git.mtree
{
  "./git.mtree": [
    "type",
    "mode",
    "uid",
    "gid",
    "tar_time",
    "size"
  ]
}
$ tar c .git/ | gomtree -c -T - -K sha512digest > git.mtree
$ gomtree -result-format=json -list-used -f ./git.mtree
{
  "./git.mtree": [
    "type",
    "mode",
    "uid",
    "gid",
    "tar_time",
    "size",
    "sha512digest"
  ]
}
```

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-11 14:50:20 -04:00
90bdfb6c29 gomtree: allow tar from stdin
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-11 14:07:07 -04:00
Stephen Chung
5372b5fc47 hierarchy: provide option to list the used keywords in a spec
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>
2016-08-05 10:50:54 -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
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
2324bb8b19 Merge pull request #42 from stephen679/fix_no_arguments
cmd: gomtree no arguments
2016-07-26 11:52:03 -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
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
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
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
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
3c52e89277 travis: more strict golint
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-21 13:40:48 -04: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
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
2d227512a5 gomtree: ensure validating a populated hierarchy
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-14 02:24:29 +00: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
05f9b75a19 check: fix the checking of a hierarchy
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-04-05 16:20:04 -04:00
b7724b906b check: populate the Result set
allowing the caller to display the results as desired

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-04-05 13:05:59 -04:00
73625f1a09 cmd/gomtree: non-relative import path
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-03-31 14:03:56 -04:00
1e18d74876 cmd/gomtree: cli with basic functionality
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-03-24 16:35:09 -04:00
16b15e1c29 *: initial thoughts
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-03-10 16:15:55 -05:00